When accessing Infinispan resources via JNDI, you should access them via resource references. This ensures that the associated services are started before you application is deployed (and stopped when your application is undeployed).

e.g.

In your deployment descriptor, e.g. web.xml, ejb-jar.xml, etc:

<resource-ref>

<res-ref-name>infinispan/foo</res-ref-name>

<lookup-name>java:jboss/infinispan/cache/foo/bar</lookup-name><!-- references the "bar" cache of the "foo" container -->

</resource-ref>

Alternatively, you can reference the default cache of a given container using:

<resource-ref>

<res-ref-name>infinispan/foo</res-ref-name>

<lookup-name>java:jboss/infinispan/cache/foo/default</lookup-name><!-- references the default cache of the "foo" container -->

</resource-ref>

You can then lookup your cache via JNDI using an application namespace.

If you'd rather create caches via the parent cache manager, you'll need a resource-ref for both the cache container and the cache configuration you intend to use - this ensures that your desired cache configuration is actually installed. However, if you do this, you must manage the lifecycle of the cache yourself.