-
1. Re: Cannot inject field annotated with @Resource annotation in JBOSS 6
amberjboss1999 Oct 10, 2011 4:55 PM (in response to amberjboss1999)ANY feedback is appreciated. I cannot imagine I am the only one who has a WebService on SLSB, and injected jndi @Resources for runtime lookup. I am also looking into Arquillian for integration testing, but I'd like to see if there is a simple fix here, as I struggle with the dependencies set up of arquillian in JBoss 6.
-
2. Re: Cannot inject field annotated with @Resource annotation in JBOSS 6
amberjboss1999 Oct 11, 2011 11:26 AM (in response to amberjboss1999)I built a Arqullian test case using <arquillian.version>1.0.0.Alpha5</arquillian.version> and <jboss.version>6.0.0.Final</jboss.version>, and annotate a
@Resource(mappedName = "java:testDataSource")
protected DataSource dataSource;
mvn -e test -Pjbossas-managed-6
assert not null on dataSource.getConnection() and the test passed. I am lost as to why when I deployed on JBoss 6 and ran my test using the web services stub that it fails with :
10:17:00,093 ERROR [org.jboss.wsf.common.injection.InjectionException] Resource 'testDataSource' not found: javax.naming.NameNotFoundException: testDataSource not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771) [:5.0.5.Final]
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779) [:5.0.5.Final]
when server starts up, the jndi DS is bound:
10:16:19,865 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=testDataSource' to JNDI name 'java:testDataSource'
Can someone help, please?! What does it take to get a little help here?
-
3. Re: Cannot inject field annotated with @Resource annotation in JBOSS 6
ropalka Oct 17, 2011 4:51 AM (in response to amberjboss1999)EJB3 is responsible for injection on SLSB endpoints.
Anyway, can I see your full stack trace? I'm curious why
jbossws-common InjectionHelper is in the stack trace.
-
4. Re: Cannot inject field annotated with @Resource annotation in JBOSS 6
amberjboss1999 Mar 23, 2012 9:12 AM (in response to ropalka)I think a lot of developers would probably appreciate the solution. This is simply solved by not using @Resource, instead you can use @Autowired, and/or with combination of @Qualifier, with the point being taking component scanning of @Resource out of the equation.