0

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

Community
  • 1
  • 1
adi
  • 1,711
  • 3
  • 29
  • 50

2 Answers2

1

Actually your problem is that JBoss doesn't ignore @Resource annotations - 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 @Resource with @Autowired or @Inject.

axtavt
  • 239,438
  • 41
  • 511
  • 482
  • Thanks. I am using Spring 3.0.5. Will @Inject work straight away? Or do I need JSR 330 as the Spring docs says. If I do need it, where will I get it? cant seem to find it on maven.. – adi Apr 11 '12 at 13:18
  • @adi: It's [`javax.inject`](http://mvnrepository.com/artifact/javax.inject/javax.inject/1) on Maven. – axtavt Apr 11 '12 at 13:24
  • thanks got it. And any comment on how to fix JBoss to handle this? – adi Apr 11 '12 at 13:29
  • @adi: I don't know as I'm not familiar with JBoss. – axtavt Apr 11 '12 at 15:01
0

Sounds like java annotations need namespace support.

Then it would be @Spring:Resource or @EJB:Resource.

Oracle, are you listening?

Short of namespace for Annotations, you could possibly try changing the order of the libraries in your classpath so java would see the Spring annotations first (or last), whichever ends up providing the desired outcome.

Rodney P. Barbati
  • 1,883
  • 24
  • 18