I am working on an application using Spring 3 and Hibernate 3.5 with Java 1.6.
So far I’ve been using JBoss 4.2.1 and everything was fine.
Now while migrating to JBoss 5.1, I encountered lot of issues. One of them is that JBoss is ignoring the Spring @Resource annotation. I get the following exception:
java.lang.RuntimeException: mapped-name is required for serviceManager of deployment pol-1.0.war
at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXmlResourceEnvRefs(WebResourceHandler.java:287)
at org.jboss.web.tomcat.service.injection.WebResourceHandler.loadXml(WebResourceHandler.java:325)
at org.jboss.web.tomcat.service.TomcatInjectionContainer.processMetadata(TomcatInjectionContainer.java:550)
at org.jboss.web.tomcat.service.WebCtxLoader.start(WebCtxLoader.java:158)
It expects mapped-name for each @Resource like some ejb.
I’ve seen similar questions but they are without any answer e.g.:
@Resource annotation not working properly with JBoss5.0.1
Please advise.
Adi
Actually your problem is that JBoss doesn’t ignore
@Resourceannotations – it tries to handle them according to EJB rules instead of leaving them to Spring.Perhaps this feature can be disabled somewhere in JBoss configuration, but the simpliest solution would be to replace
@Resourcewith@Autowiredor@Inject.