1 Reply Latest reply on Oct 16, 2015 9:12 AM by rvwijngaarden

    Connect to Modeshape on Wildfly via JNDI


      This was originally asked here: Connect to Modeshape on JBoss via JNDI


      I'm trying to connect to a Modeshape 4.0 repo via (remote) JNDI. I'm using Wildfly 8.1 and in the administration console I can see that a JNDI entry for the repos has been set:



      I followed the guidelines on https://docs.jboss.org/author/display/WFLY8/Remote+JNDI+Reference


      My java program is a simple application built with Gradle. These are the dependencies:


      dependencies {
           compile group: 'org.jboss.xnio', name: 'xnio-api', version: '3.3.0.Final'
           compile group: 'org.jboss.xnio', name: 'xnio-nio', version: '3.3.0.Final'
           compile group: 'org.wildfly', name: 'wildfly-ejb-client-bom', version:  '8.1.0.Final'


      Should be all that is necessary. Now this is my Java program:


      public void startRemoteRepo() throws NamingException, RepositoryException {
          final Properties env = new Properties();
          env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
          env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
          env.put(Context.SECURITY_PRINCIPAL, "admin");
          env.put(Context.SECURITY_CREDENTIALS, "admin");
          InitialContext initCtx = new InitialContext(env);
          Context envCtx = (Context) initCtx.lookup("java:/jcr");


      The "admin" user is set up in Wildfly and has the "connect" role and is also added to ApplicationRealm.


      Now executing the test I get this:


      18:02:26,482  INFO XNIO version 3.3.0.Final
      18:02:26,577  INFO XNIO NIO Implementation Version 3.3.0.Final
      18:02:26,902  INFO JBoss Remoting version 4.0.3.Final
      javax.naming.NameNotFoundException: jcr -- service jboss.naming.context.java.jboss.exported.jcr
        at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:202)
        at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)
        at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
        at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)


      I don't really get this message. XNIO seems to be fine, but it can't find the JCR. Any idea hwat the reason could be?