1 Reply Latest reply on Jun 1, 2014 1:15 PM by Francesco Marchioni

    javax.naming.NamingException: Failed to connect to any server

    Mylos Kathos Master

      Hi all!

      I'm trying to code a remote JMS client using WildFly 8.1.0 CR2. When I try to connect to the remote server the following exception is raised:

      javax.naming.NamingException: Failed to connect to any server. Servers tried: [http-remoting://localhost:8080].

      I have the following InitialContext properties:

      final Properties env = new Properties();

        

      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

      env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, "http-remoting://localhost:8080"));

      env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));

      env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));

      context = new InitialContext(env);

       

      Additionally, I have included in my pom.xml the following dependencies:

       

      <dependencyManagement>

        <dependencies>

        <dependency>

        <groupId>org.wildfly.bom</groupId>

        <artifactId>jboss-javaee-7.0-with-all</artifactId>

        <version>8.0.0.Final</version>

        <type>pom</type>

        <scope>import</scope>

        </dependency>

       

        <dependency>

        <groupId>org.wildfly</groupId>

        <artifactId>wildfly-ejb-client-bom</artifactId>

        <version>8.0.0.Final</version>

        <type>pom</type>

        <scope>import</scope>

        </dependency>

        </dependencies>

       

      </dependencyManagement>

       

      <dependencies>

        <dependency>

        <groupId>org.jboss.xnio</groupId>

        <artifactId>xnio-api</artifactId>

        <scope>runtime</scope>

        </dependency>

       

        <dependency>

        <groupId>org.jboss.xnio</groupId>

        <artifactId>xnio-nio</artifactId>

        <scope>runtime</scope>

        </dependency>

       

        <dependency>

        <groupId>org.jboss.remoting</groupId>

        <artifactId>jboss-remoting</artifactId>

        <scope>runtime</scope>

        </dependency>

       

        <dependency>

        <groupId>org.jboss</groupId>

        <artifactId>jboss-remote-naming</artifactId>

        </dependency>

       

        <dependency>

        <groupId>org.jboss.spec.javax.jms</groupId>

        <artifactId>jboss-jms-api_2.0_spec</artifactId>

        </dependency>

       

        <dependency>

        <groupId>org.jboss.spec.javax.ejb</groupId>

        <artifactId>jboss-ejb-api_3.2_spec</artifactId>

        <scope>provided</scope>

        </dependency>

       

      </dependencies>

      I have also setup an username and a password in the ApplicationRealm with the "guest" role. Yet it seems I'm still not even hitting the server.

      Any idea what could be the issue?

      Thanks!

        • 1. Re: javax.naming.NamingException: Failed to connect to any server
          Francesco Marchioni Apprentice

          Hi,

          do not use the wildfly-ejb-bom but instead use:

              <dependencies>

                  <dependency>

                      <groupId>org.wildfly</groupId>

                      <artifactId>wildfly-jms-client-bom</artifactId>

                      <version>${version.wildfly}</version>

                      <type>pom</type>

                  </dependency>

              </dependencies>

          Remove as well all transport dependencies (include just the ejb3 if you are deploying MDBs) and see if it works.....

          Hope it hellps