Reputation: 7031
I am trying to add REST support to my Spring 3 + Hibernate application.
I have created the REST support using the wizard from Netbeans, at it has put a @Autowire annotation (not @autowired) above my Resource class. Getting the @Autowire annotation from Spring causes the error
incompatible types
found : org.springframework.beans.factory.annotation.Autowire
required: java.lang.annotation.Annotation
Getting @Autowire from JAX-RS should be only for Spring 2.5 as far as I understand from here. I get the following error if I include it, which I think is related to Spring 2.5 being loaded:
SEVERE: Exception while loading the app : java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception
parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml];
nested exception is java.lang.NoSuchMethodError:
org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/
Object;)Lorg/springframework/beans/MutablePropertyValues;
Could someone point me on how to add this annotation, and make JAX-RS work with Spring? Also, I was using a SessionFactory and the autogenerated code refers to a entityManagerFactory in the applicationcontext. Can those be used interchangingly?
PS: Allow me to say that I hate Java EE with a passion so far in my three week journey with the platform, major stumbling blocks at every level, sorry for the rant.
Upvotes: 2
Views: 3034
Reputation: 42849
You are using the wrong Autowire
. The 'Netbeans REST wizard' looks like it would be using com.sun.jersey.api.spring.Autowire
(last image, very bottom of page), and from your message above, you are using org.springframework.beans.factory.annotation.Autowire
which appears to be an Enum
used in Spring 2.0.
From what I can tell, this may be a specific thing to Spring 2.0 anyways. Perhaps you should take a look at doing the REST JAX-RS stuff yourself (using Jersey), as it is not that difficult.
Upvotes: 2