In the absence of a kit which integrates directly with the EAP subsystem, you need to either use the JCA adapter or embed (start/stop the repository programmatically) ModeShape in your own webapp/EAR.
That being said, whenever a repository starts up, it always attempts to register itself in JNDI (using a new InitialContext() without properties) under:
a) java:jcr/local/<repositoryName> if the JSON configuration does not contain a "jndiName" attribute
b) whatever the value of "jndiName" attribute is in the JSON configuration file.
So in the context of EAP, this should (in theory) always bind a repository in JNDI. That being said, since it doesn't integrate directly with EAP's JNDI subsystem, there may be some quirks (for example the default namespace under which it's bound). You need to try this locally and figure out what the exact JNDI url is (the code is modeshape/modeshape-jcr/src/main/java/org/modeshape/jcr/JcrRepository.java at modeshape-3.7.1.Final · ModeShape/modeshap…)
ModeShape 4 will provide a kit for integrating with Wildfly 8.1.
Since JBoss EAP is not able to bind to the default modshape JNDI space that seemed to be my major problem. Once I set the jndiName in the repository configuration I got it to work. The folllowing jndiName value worked: "java:global/jcr/<repo-name>".
Is it possible for an application embedded modeshape repository to use inifinispan caches defined on the JBoss server (e.g. defined in standalone.xml) ? or do the infinispan caches have to be defined as part of the repository configuration.
When I embed modeshape into my application shall I also embed the inifinispan jars or should the infinispan jars on the server "be used"?
Most likely EAP 6.2, like Wildfly 8.1, don't support custom namespaces, which is why "java:jcr" (the default) would not work.
Once you "embed" Modeshape, you need to embed everything else as well: Infinispan/ JGroups / etc; you won't be able to interface with any of the EAP-defined subsystems.
Jar wise, I don't think you have to embed anything (I'm using the embed term loosely here): if you install the ModeShape kit in EAP, your application should (in theory) work just by adding a jboss-deployment-descriptor.xml file where you list the modules you depend on (from EAP). You just need to manage the repository from your own code.
However, if this doesn't work, then you need to add not only the ModeShape jars, but also the Infinispan, JGroups and all the other dependencies to your application.
Thanks, this is valuable information.