You can add to the deployment's Manifest:
Dependencies: org.infinispan export
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.
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.
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.
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.
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
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:
Jaikiran just told me that lookup-name in the standard ejb-jar.xml should also work.
Create a jboss-deployment-structure.xml file in your ear's META-INF directory:
For datasources, we also add (inside the dependencies node):
...although we had to create our own net.sourceforge.jtds module (with the JBoss documentation it wasn't very difficult)...