9 Replies Latest reply on Sep 20, 2006 5:45 AM by romanchr

    org.jboss.remoting.CannotConnectException: Can not get conne

    romanchr

      Hi all,

      I am experiencing a strange problem: I can not execute any business methods on my ejb 3.0 stateless session bean. Looking up the remote interface is no problem but any executed remote method leads to a CannotConnectException.

      Here is my client side code:

      public void testRemoteMethod()
      {
      Properties properties = new Properties();
      properties.pu("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      properties.put("java.naming.factory.url.pkgs","=org.jboss.naming:org.jnp.interfaces");
      properties.put("java.naming.provider.url","localhost:1299");
      Context context;
      try
      {
      context = new InitialContext(properties);
      RemoteFacade beanRemote = (RemoteFacade)context.lookup("ejb/RemoteFacade");
      beanRemote.callBusinessMethod();
      }
      catch (Exception e)
      {
      e.printStackTrace();
      }
      }

      I get the following exception:

      org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection.
      at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:230)
      at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:112)
      at org.jboss.remoting.Client.invoke(Client.java:226)
      at org.jboss.remoting.Client.invoke(Client.java:189)
      at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
      at $Proxy0.runTournament(Unknown Source)
      at com.tas.unit.testcase.RemoteTester.testRemoteMethod(RemoteTester.java:49)

      System: Windows XP 5.1 (SP2), JBoss 4.0.4 GA, with EJB 3.0 extension (out of the box installation with provided installer).

      Any help appreciated!

      Regards

      Christoph

        • 1. Re: org.jboss.remoting.CannotConnectException: Can not get c
          peterj

          First, the standard JBoss JNDI port is 1099, not 1299. Di you change the port number? The error you are getting is that noone is listening on port 1299.

          Second, remove the euqual sign from the value of the second property setting:

          properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

          Third, you cannot cast a remote interface directly, use PortableRemoteObject.narrow.

          Object obj = context.lookup("ejb/RemoteFacade");
          RemoteFacade beanRemote = (RemoteFacade)PortableRemoteObject.narrow(obj, RemoteFacade.class);

          • 2. Re: org.jboss.remoting.CannotConnectException: Can not get c
            romanchr

            Hi,

            Thanks for your answer. When going through my initial poste I noticed that i forgot to mention the JVM used. Both server and client are running on the same JVM version (1.5.0_06-b05).

            Now to the results of your suggestions.
            Port:
            Our server is listing on Port 1299 (we do not use the default config). As we can perform the lookup of the remote object without getting an exception the server is listening on this port.

            java.naming.factory.url.pkgs:
            I tried "java.naming.factory.url.pkgs" with and without equal sign, but it had no effect whatsorever.

            PortableRemoteObject.narrow:
            I inserted PortableRemoteObject.narrow but still the call on the remote method fails.

            As I see it there must be another problem. It could be related to RMI or even on a lower level as the error message states "Problem establishing socket connection".
            Another reason could be that we are using the wrong libraries. Currently we are using the following libraries (all provided with JBoss 4.0.4GA):
            jbossall-client.jar
            jboss-ejb3-client.jar
            jboss-aspect-library-jdk50.jar
            jboss-aop-jdk50.jar

            Any further help is greatly appreciated :-)

            Regards

            Christoph

            • 3. Re: org.jboss.remoting.CannotConnectException: Can not get c
              peterj

              Do you have a firewall? What operating system are you using?

              In the standard JBoss installation, the port 1099 and 1098 are required for RMI. Perhaps port 1098 (or its equivalent, if you changed the port) is blocked.

              Other ports to consider are 4444 and 4445. I know I had to open those also, but can't recall if that was necessary only for accessing MBeans, or for EJBs also.

              • 4. Re: org.jboss.remoting.CannotConnectException: Can not get c
                romanchr

                I am on Windows 5.1 (XP with SP2). I somehow have the same feeling as you: it looks like as if the internal windoze firewall is blocking my calls.

                I had try on another machine and there I had absolutely no problems.

                Therefore I will examine my firewall a bit closer. Funy enough that my JBoss 4.0.3 SP1 runs without any hassle.

                Regards

                Christoph

                • 5. Re: org.jboss.remoting.CannotConnectException: Can not get c
                  romanchr

                  I forgot to mention that the 4.0.3SP1 instance is running on other ports (default +100, means 8180, 1199 1198, etc). Therefore the ports 1298, 1299, etc are not taken by this instance.

                  Regards

                  Christoph

                  • 6. Re: org.jboss.remoting.CannotConnectException: Can not get c
                    romanchr

                    I finally find out what the problem is:

                    It is a damned annoying bug in JBoss. JBoss version 4.0.4GA RC8 can't handle different ports settings other the ports-default.
                    The bug will be fixed in RC9. See http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3969990#3969990 if you want to know more.

                    Regards

                    Christoph

                    • 7. Re: org.jboss.remoting.CannotConnectException: Can not get c
                      alrubinger

                      ....and you're not using @Service? That's what the issue you've linked to involves.

                      If you find me on this AIM screen name you can send me your EJB. I'll see if it's related to that same issue, and if so, send you a patched EJB3 JAR for 4.0.4GA that corrects the JBoss bug until Bill-n-co release EJB3 RC9.

                      S,
                      ALR

                      • 8. Re: org.jboss.remoting.CannotConnectException: Can not get c
                        romanchr

                        Hi,

                        I'd like to apologize for my late answer due to my vacation last week.

                        And yes I do not use @Service. Just @Remote in the remote interface and @Stateless in the bean.

                        AS RC9 is out I gonna have another try. I come back when I know more.

                        Regards,

                        Christoph

                        • 9. Re: org.jboss.remoting.CannotConnectException: Can not get c
                          romanchr

                          Hi all,

                          With updating to EJB3.0 RC9 our problem has been solved. JBoss handles the ports settings correctly now and we can run it with others then just ports-default.

                          I truly hope the guys from JBoss make it this time to keep the faulty code out and not merge it in again in a later release....

                          Regards

                          Christoph

                          PS: and thanks for RC9 ;-)