0 Replies Latest reply on Jul 3, 2018 10:27 AM by Sebastian Götz

    WildFly 13 - HTTP JNDI EJB Client - No provider for found for URI: ejb

    Sebastian Götz Newbie

      Hi. I'm trying to realize a simple java client, which calls a stateless session bean running in WildFly 13 via JNDI.

      The client looks like this:

       

      import java.util.Hashtable;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      
      import de.jexam.server.TestMgrRemote;
      
      public class TestClient {
          public static void main(String[] args) {
              try {
                  TestMgrRemote r = lookupTestMgrBean();
                  r.test();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      
          private static TestMgrRemote lookupTestMgrBean() throws NamingException {
              Context ctx = createInitialContext();
              return (TestMgrRemote) ctx.lookup("ejb:/jexam-server-ejb//TestMgr!de.jexam.server.TestMgrRemote");
          }
      
          private static Context createInitialContext() throws NamingException {
              Hashtable<string, object=""> env = new Hashtable<>();
              env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
              env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
              env.put(Context.PROVIDER_URL, "remote+http://127.0.0.1:8080");
              InitialContext ctx = new InitialContext(env);
              return ctx;
          }
      }

       

      The pom.xml looks like this:

      <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <parent>
              <groupId>de.jexam.server</groupId>
              <artifactId>jexam-server</artifactId>
              <version>0.0.1-SNAPSHOT</version>
          </parent>
          <artifactId>jexam-client</artifactId>
          <name>jexam-client</name>
      
          <dependencyManagement>
              <dependencies>
                  <dependency>
                      <groupId>org.wildfly</groupId>
                      <artifactId>wildfly-ejb-client-bom</artifactId>
                      <version>12.0.0.Final</version>
                  </dependency>
              </dependencies>
          </dependencyManagement>
      
          <dependencies>
              <dependency>
                  <groupId>de.jexam.server</groupId>
                  <artifactId>jexam-server-ejb</artifactId>
                  <version>0.0.1-SNAPSHOT</version>
                  <type>ejb</type>
              </dependency>
      
      
              <dependency>
                  <groupId>org.wildfly</groupId>
                  <artifactId>wildfly-naming-client</artifactId>
                  <version>1.0.9.Final</version>
              </dependency>
          </dependencies>
      
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>3.7.0</version>
                      <configuration>
                          <!-- enforce Java 8 -->
                          <source>1.8</source>
                          <target>1.8</target>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </project>
      
      
      
      

      I also added a META-INF/wildfly-config.xml, which looks like this:

       <configuration>  
          <authentication-client xmlns="urn:elytron:1.0">  
              <authentication-rules>  
                  <rule use-configuration="default"/>  
              </authentication-rules>  
              <authentication-configurations>  
                  <configuration name="default">  
                      <set-user-name name="appuser"/>  
                      <credentials>  
                          <clear-password password="apppwd"/>  
                      </credentials>  
                  </configuration>  
              </authentication-configurations>  
          </authentication-client>  
          <jboss-ejb-client xmlns="urn:jboss:wildfly-client-ejb:3.0">  
              <connections>  
                  <connection uri="remote+http://127.0.0.1:8080" />  
              </connections>  
          </jboss-ejb-client>  
      </configuration>
      

       

      Running the client gives me an OperationNotSupportedException. The client log looks like this:

       

      Jul 03, 2018 4:05:36 PM org.wildfly.naming.client.Version 
      INFO: WildFly Naming version 1.0.9.Final
      Jul 03, 2018 4:05:36 PM org.wildfly.security.Version 
      INFO: ELY00001: WildFly Elytron version 1.1.0.Final
      Jul 03, 2018 4:05:36 PM org.xnio.Xnio 
      INFO: XNIO version 3.5.1.Final
      Jul 03, 2018 4:05:36 PM org.xnio.nio.NioXnio 
      INFO: XNIO NIO Implementation Version 3.5.1.Final
      Jul 03, 2018 4:05:37 PM org.jboss.remoting3.EndpointImpl 
      INFO: JBoss Remoting version 5.0.0.Final
      javax.naming.OperationNotSupportedException: WFNAM00026: No provider for found for URI: ejb
          at org.wildfly.naming.client.WildFlyRootContext.getProviderContext(WildFlyRootContext.java:811)
          at org.wildfly.naming.client.WildFlyRootContext.lookup(WildFlyRootContext.java:140)
          at javax.naming.InitialContext.lookup(Unknown Source)
          at TestClient.lookupTestMgrBean(TestClient.java:22)
          at TestClient.main(TestClient.java:12)

       

      What's my mistake?