Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » AnnotationFormatError: what does it means and how to solve it?
AnnotationFormatError: what does it means and how to solve it? [message #635554] Wed, 27 October 2010 06:45 Go to next message
guofeng zhang is currently offline guofeng zhang
Messages: 49
Registered: July 2009
Member
One bundle defined an interface:
@Repository
public interface HelloWorldRepository extends ReadWriteJpaRepository<HelloWorld, Long> {

	@GenericQuery(query = "select e from HelloWorld e")
	public List<HelloWorld> listAll();
	
}


By using Sping AOP introduction, this interface is add some implementation and published as service:
   <bean id="repositoryFactory" class="org.codehaus.grepo.query.jpa.repository.JpaRepositoryFactoryBean" abstract="true" >
       <property name="entityManagerFactory" ref="entityManagerFactory" />
   </bean>
   
   <bean id="helloWorldRepositoryBean" parent="repositoryFactory">
       <property name="proxyClass" value="org.planner.repository.member.HelloWorldRepository" />
   </bean>
    <service id="helloWorldRepository"
             ref="helloWorldRepositoryBean"
             interface="org.planner.repository.member.HelloWorldRepository" />


Another bundle reference this service:
   <reference id="helloWorldRepositoryrRef" interface="org.planner.repository.member.HelloWorldRepository" />


But an error displayed says that helloWorldRepositoryrRef cannot be created:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'helloWorldRepositoryrRef': Post-processing of the FactoryBean's object failed; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.codehaus.grepo.query.commons.annotation.GenericQuery.resultConverter()
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:165)
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1414)
......

Where resultConverter is a element in GenericQuery.

If I removed the annonation from the listAll() method, it works without any error.

I donot know what cause it, and how to solve it.

Your help is appreciated.
Re: AnnotationFormatError: what does it means and how to solve it? [message #635841 is a reply to message #635554] Thu, 28 October 2010 06:48 Go to previous messageGo to next message
guofeng zhang is currently offline 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?


Re: AnnotationFormatError: what does it means and how to solve it? [message #636059 is a reply to message #635841] Fri, 29 October 2010 04:23 Go to previous messageGo to next message
guofeng zhang is currently offline guofeng zhang
Messages: 49
Registered: July 2009
Member
This issue is solved.

The third party bundle does not export "org.codehaus.grepo.query.commons.annotation". Exporting this package solved this issue.

I thought this might be class loader issue because it worked in standalone application, it would be easier to figure it out if the error message could indicate directly by NoClassDefFoundError.


Re: AnnotationFormatError: what does it means and how to solve it? [message #636082 is a reply to message #636059] Fri, 29 October 2010 05:15 Go to previous message
guofeng zhang is currently offline guofeng zhang
Messages: 49
Registered: July 2009
Member
A typo.

The third party bundle does not export "org.codehaus.grepo.core.converter", which reference by resultConverter() as the default value.
Previous Topic:How to inject EntityManager in each bundle?
Next Topic:Virgo 2.1.0 Release Available
Goto Forum:
  


Current Time: Wed Jul 30 09:16:06 EDT 2014

Powered by FUDForum. Page generated in 0.02174 seconds