3 Replies Latest reply on May 23, 2017 2:19 AM by Srinivasa Papana

    EJB Remote Client - javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:8080]

    Srinivasa Papana Newbie

      Hi,

       

      I have created  a sample Stateless session bean and deployed to Wildfly 10.x.

      Then I wrote a standalone clinet program to invoke the ejb, but it got failed with below error.

      Could you please help.

      Attached the server and standalone client logs.

       

      5373 [main] DEBUG org.jboss.naming.remote.client.InitialContextFactory  - jboss.naming.client.connect.options. has the following options {org.xnio.Options.SASL_POLICY_NOPLAINTEXT=>false}

      10381 [main] DEBUG org.jboss.naming.remote.client.HaRemoteNamingStore  - Failed to connect to server remote://localhost:8080

      java.lang.RuntimeException: Operation failed with status WAITING

        at org.jboss.naming.remote.protocol.IoFutureHelper.get(IoFutureHelper.java:89)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:193)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:144)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:125)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:241)

        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)

        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)

        at javax.naming.InitialContext.lookup(Unknown Source)

        at WildflyEJBClient.RemoteClient.main(RemoteClient.java:44)

      Exception in thread "main" javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:8080]

        at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:213)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:144)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:125)

        at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:241)

        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:79)

        at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:83)

        at javax.naming.InitialContext.lookup(Unknown Source)

        at WildflyEJBClient.RemoteClient.main(RemoteClient.java:44)

       

       

      Client code:

       

      Properties props = new Properties();

       

       

        // For local wildfly

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

        props.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

        props.put("jboss.naming.client.ejb.context", true);

        props.put("java.naming.provider.url","remote://localhost:8080");

        props.put(Context.SECURITY_PRINCIPAL, "XXXX");// passed valid values from add-user.bat

        props.put(Context.SECURITY_CREDENTIALS, "XXX");// passed valid values from add-user.bat

       

        InitialContext context = new InitialContext(props);

       

        HelloWorldRemote exampleBean = (HelloWorldRemote) context.lookup("SampleEJBProj/HelloWorld!com.ejbs.HelloWorldRemote");

        System.out.println(exampleBean.getMessage());

        • 1. Re: EJB Remote Client - javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:8080]
          Srinivasa Papana Newbie

          Could someone please help me..

          Client is sitting one me...i have spent 2 days on this .. couldn't succeed..

          Same program I could able to connect to JBOSS EAP 6.4 server and able to do EJB lookup.

          I am not sure what is wrong with my code w.r.t Wildfly 10.x

          Need urgent help..

           

          I have tried with IP address 127.0.0.1 and with diff ports like 4447/9990 ..still no luck.

           

          Thanks in advance.

          • 2. Re: EJB Remote Client - javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:8080]
            Srinivasa Papana Newbie

            Thanks Wolfgang.

             

            I have changed to use http-remoting://localhost:8080, then I got the error as below:

             

            Caused by: java.io.IOException: JBREM000202: Abrupt close on Remoting connection 6c2d068b to localhost/127.0.0.1:8080 of endpoint "config-based-naming-client-endpoint" <9f70c54>

              at org.jboss.remoting3.remote.ClientConnectionOpenListener$Greeting.handleEvent(ClientConnectionOpenListener.java:171)

              at org.jboss.remoting3.remote.ClientConnectionOpenListener$Greeting.handleEvent(ClientConnectionOpenListener.java:157)

              at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)

              at org.xnio.channels.TranslatingSuspendableChannel.handleReadable(TranslatingSuspendableChannel.java:198)

              at org.xnio.channels.TranslatingSuspendableChannel$1.handleEvent(TranslatingSuspendableChannel.java:112)

             

            Exception in thread "main" javax.naming.CommunicationException: Failed to connect to any server. Servers tried: [http-remoting://localhost:8080 (java.io.IOException: JBREM000202: Abrupt close on Remoting connection 6c2d068b to localhost/127.0.0.1:8080 of endpoint "config-based-naming-client-endpoint" <9f70c54>)]

              at org.jboss.naming.remote.client.HaRemoteNamingStore.failOverSequence(HaRemoteNamingStore.java:244)

              at org.jboss.naming.remote.client.HaRemoteNamingStore.namingStore(HaRemoteNamingStore.java:149)

              at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:130)

              at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272)

              at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104)

              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93)

              at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146)

              at javax.naming.InitialContext.lookup(Unknown Source)

              at RemoteClient.main(RemoteClient.java:41)

            • 3. Re: EJB Remote Client - javax.naming.NamingException: Failed to connect to any server. Servers tried: [remote://localhost:8080]
              Srinivasa Papana Newbie

              I could able to do ejb loopup from my client:

               

              Earlier I was running the Wildfly(installed locally) on the Eclipse IDE in my local machine.

              Not sure what is wrong with localhost/127.0.0.1/machine-name/machine-ip-address, somehow this address couldn't be resolved.

              Even I have tried with different wildfly running ports like 8080/4447/9990, still couldn't make a connection.

              Was always getting the error for some reason.

               

              1) used url protocol to use "http-remoting" like http-remoting://XXXXXX:8080

              2) Referenced the jboss-client.jar file from \wildfly-10.1.0.Final\bin\client and give highest precedence over all other jars.You can change this by going to applicatio build path->configure build path->Order and Export

              3) Finally I could run the Wildfly on the one of DEV server (not local machine) and able to do ejb lookup.