-
1. Re: Possible to express jndi dependencies without @Resource ?
emmartins Nov 7, 2012 11:42 AM (in response to trondgzi)You can add to the deployment's Manifest:
Dependencies: org.infinispan export
-
2. Re: Possible to express jndi dependencies without @Resource ?
trondgzi Nov 7, 2012 2:34 PM (in response to emmartins)Nope, that doesn't work (tested with 7.1.3.Final). And even if it did work, the problem repeats itself when I try to look up other resources from jndi e.g. ConnectionFactory and DataSource.
-
3. Re: Possible to express jndi dependencies without @Resource ?
emmartins Nov 7, 2012 2:58 PM (in response to trondgzi)AS7 sets automatic dependencies on injection or through XML (if your component descriptor allows it), if that's not the case then you have to use the MANIFEST.MF, where you need to add dependencies for all modules which define the resources which you will lookup.
Take a look at https://docs.jboss.org/author/display/AS71/Developer+Guide#DeveloperGuide-ClassloadinginJBossAS7 for a better understanding of how AS7 classloading works.
-
4. Re: Possible to express jndi dependencies without @Resource ?
trondgzi Nov 7, 2012 3:21 PM (in response to emmartins)I appreciate your efforts Eduardo, but my problem is not classloading related. My issue is that my application depends on a jboss service beeing started before it can work. Maybe I didn't express myself clear enough in my first post...
What happens is that when my application is started it basically does new InitialContext().lookup("java:jboss/infinispan/container/hibernate") and then a javax.naming.NameNotFoundException is thrown saying "service jboss.naming.context.java.jboss.infinispan.container.hibernate is not started". If the same is expressed with @Resource(mappedName = "java:jboss/infinispan/container/hibernate") then jboss understands that the service must be started before my application is started, and the manual jndi lookup will work. So the problem is that my application depends on a service being available, not a class being available.
-
5. Re: Possible to express jndi dependencies without @Resource ?
emmartins Nov 7, 2012 9:18 PM (in response to trondgzi)I believe it's me that misread your question, try declaring a ref to the resource in the ejb xml deployment descriptor, AS7 should apply same behavior as @Resource injection.
-
6. Re: Possible to express jndi dependencies without @Resource ?
trondgzi Nov 8, 2012 2:24 AM (in response to emmartins)After declaring a resource-ref in ejb-jar.xml I get this warning: "[org.jboss.as.ee] (MSC service thread 1-5) JBAS011001: Could not resolve resource-env-ref java:jboss/infinispan/container/hibernate". Which according to the docs should not be a surprise since res-ref-name should be relative to java:comp/env
-
7. Re: Possible to express jndi dependencies without @Resource ?
emmartins Nov 8, 2012 7:25 AM (in response to trondgzi)I did not try it, but I think you need to use a jboss-ejb3.xml descriptor for such resource-ref, as in:
Here is a similar forum thread, even if related with web components:
-
8. Re: Possible to express jndi dependencies without @Resource ?
emmartins Nov 8, 2012 7:32 AM (in response to emmartins)Jaikiran just told me that lookup-name in the standard ejb-jar.xml should also work.
-
9. Re: Possible to express jndi dependencies without @Resource ?
shadowcreeper Feb 20, 2013 5:01 PM (in response to trondgzi)Create a jboss-deployment-structure.xml file in your ear's META-INF directory:
<jboss-deployment-structure>
<sub-deployment name="your-ejb.jar">
<dependencies>
<module name="org.infinispan"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
For datasources, we also add (inside the dependencies node):
<module name="net.sourceforge.jtds"/>...although we had to create our own net.sourceforge.jtds module (with the JBoss documentation it wasn't very difficult)...