|
Re: AnnotationFormatError: what does it means and how to solve it? [message #635841 is a reply to message #635554] |
Thu, 28 October 2010 10:48 |
guofeng zhang Messages: 49 Registered: July 2009 |
Member |
|
|
I made some test.
First in my bundle I defined:
public interface UserRepository //extends ReadWriteJpaRepository<User, Long>
{
@GenericQuery
User getByUsername(String username);
}
I added the following code to my bundle's Activator:
try
{
Class c = UserRepository.class ;
AnnotatedElement elem = c.getMethod("getByUsername", String.class);
LOGGER.info( "---get-annotation---" ) ;
GenericQuery ann = elem.getAnnotation(GenericQuery.class);
LOGGER.info( "---annotation---: " + ann ) ;
} catch (Throwable t )
{
t.printStackTrace() ;
}
Only GenericQuery is defined in another bundle provided by the third party.
I got the following similar error:
org.planner.service.member.management.impltest.Activator ---get-annotation---
System.err java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.codehaus.grepo.query.commons.annotation.GenericQuery.resultConverter()
System.err at java.lang.reflect.Method.getDefaultValue(Method.java:726)
System.err at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:99)
System.err at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:66)
System.err at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:202)
System.err at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
System.err at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
System.err at java.lang.reflect.Method.declaredAnnotations(Method.java:693)
System.err at java.lang.reflect.Method.getAnnotation(Method.java:679)
System.err at org.planner.service.member.management.impltest.Activator$1.run(Activator.java:46)
System.err at java.lang.Thread.run(Thread.java:619)
If I only copy the GenericQuery to my bundle, the above code worked. It returned:
@org.codehaus.grepo.query.commons.annotation.GenericQuery(re sultConverter=class org.codehaus.grepo.core.converter.PlaceHolderResultConverter , queryGenerator=class org.codehaus.grepo.query.commons.generator.PlaceHolderQueryG enerator, firstResult=-1, resultValidator=class org.codehaus.grepo.core.validator.PlaceHolderResultValidator , queryName=, query=, queryExecutor=class org.codehaus.grepo.query.commons.executor.PlaceHolderQueryEx ecutor, maxResults=-1, isNativeQuery=false)
I do not know why it works in the late case.
Could any one kind give me some advice?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04098 seconds