3 Replies Latest reply on Nov 20, 2014 1:56 AM by Horia Chiorean

    Connect to Modeshape on JBoss via JNDI

    Jan Petzold Newbie

      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:

       

      jndi.png

      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:

       

      @Test
      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("jboss.naming.client.ejb.context", true);
      
      
          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:

       

      15:05:21,680  INFO XNIO Version 3.0.0.GA
      javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.IllegalArgumentException: No matching XNIO provider found]
        at org.jboss.naming.remote.client.ClientUtil.namingException(ClientUtil.java:51)
        at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:151)
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
        at javax.naming.InitialContext.init(InitialContext.java:242)
        at javax.naming.InitialContext.<init>(InitialContext.java:216)
        at de.doksafe.securerepo.JndiTest.startRemoteRepo(JndiTest.java:30)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
      Caused by: java.lang.IllegalArgumentException: No matching XNIO provider found
        at org.xnio.Xnio.doGetInstance(Xnio.java:192)
        at org.xnio.Xnio.getInstance(Xnio.java:146)
        at org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:73)
        at org.jboss.naming.remote.client.EndpointCache.get(EndpointCache.java:44)
        at org.jboss.naming.remote.client.InitialContextFactory.createEndpoint(InitialContextFactory.java:223)
        at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateEndpoint(InitialContextFactory.java:204)
        at org.jboss.naming.remote.client.InitialContextFactory.getOrCreateNamingStore(InitialContextFactory.java:168)
      at org.jboss.naming.remote.client.InitialContextFactory.getInitialContext(InitialContextFactory.java:134)
        ... 31 more
      
      

       

      Now when you Google for this you get quite a few results, however I feel that I've tried everything mentioned there. Dependencies should be right, users are valid and so on.

       

      I tried debugging this a bit and it seems that just no default XNIO provider is set. Doesn't it take the default one if nothing else is configured? If not, how can I set a default XNIO provider?

       

      Thanks,

       

      Jan