2 Replies Latest reply on Aug 13, 2007 9:50 AM by alrubinger

    Using an EJB from an remote app client does not work

    hauptlorenz

      Hi,

      I've created an EJB with both an local and remote-interface and deployed it
      (stateless session bean).

      Now I want to use it from an remote application client (swing app).
      I've using this jndi.properties-file (which is used, I see in the exceptions):

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming.client
      java.naming.provider.url=jnp://132.180.60.3:1099
      j2ee.clientName=sImplex-app-client



      I'm using the following java code to use the EJB. The problem:
      if the client is running on the same machine as the jboss server it is running. If it is running on an different client I get only exceptions.

      What could be the problem?

      Thank you very much,
      Frank


      Properties properties = new Properties();
      
       Context context;
       try {
       context = new InitialContext();
       userRemote myUser = (userRemote) context.lookup(userBean.RemoteJNDIName);
       String a = myUser.getUser();
       jTextPane1.setText(jTextPane1.getText()+"\n"+a);
       } catch (NamingException e) {
       e.printStackTrace();
       /* I rethrow it as runtimeexception as there is really no need to continue if an exception happens and I
       * do not want to catch it everywhere.
       */
       throw new RuntimeException(e);
       }
      





        • 1. Re: Using an EJB from an remote app client does not work
          hauptlorenz

          Hi,

          I found out, that the JBOSS Server must be started with the -b 0.0.0.0
          param to enable the server on all interfaces.

          I get now these Exceptions:
          C:\Dokumente und Einstellungen\haupt_f\Desktop\dist\build>java -jar sImplex-app-
          client.jar
          Exception in thread "AWT-EventQueue-0" org.jboss.remoting.CannotConnectException
          : Can not get connection to server. Problem establishing socket connection for I
          nvokerLocator [socket://127.0.0.1:3873/]
          at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transpor
          t(MicroSocketClientInvoker.java:530)
          at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientI
          nvoker.java:122)
          at org.jboss.remoting.Client.invoke(Client.java:1550)
          at org.jboss.remoting.Client.invoke(Client.java:530)
          at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemot
          eInterceptor.java:62)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPr
          opagationInterceptor.java:61)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityC
          lientInterceptor.java:53)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.
          java:72)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteP
          roxy.java:103)
          at $Proxy0.getUser(Unknown Source)
          at org.simplex.ui.main.mainFrame.onStartButton(mainFrame.java:88)
          at org.simplex.ui.main.mainFrame.access$000(mainFrame.java:18)
          at org.simplex.ui.main.mainFrame$1.mouseClicked(mainFrame.java:58)
          at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
          at java.awt.Component.processMouseEvent(Unknown Source)
          at javax.swing.JComponent.processMouseEvent(Unknown Source)
          at java.awt.Component.processEvent(Unknown Source)
          at java.awt.Container.processEvent(Unknown Source)
          at java.awt.Component.dispatchEventImpl(Unknown Source)
          at java.awt.Container.dispatchEventImpl(Unknown Source)
          at java.awt.Component.dispatchEvent(Unknown Source)
          at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
          at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
          at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
          at java.awt.Container.dispatchEventImpl(Unknown Source)
          at java.awt.Window.dispatchEventImpl(Unknown Source)
          at java.awt.Component.dispatchEvent(Unknown Source)
          at java.awt.EventQueue.dispatchEvent(Unknown Source)
          at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
          at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
          at java.awt.EventDispatchThread.run(Unknown Source)
          Caused by: java.net.ConnectException: Connection refused: connect
          at java.net.PlainSocketImpl.socketConnect(Native Method)
          at java.net.PlainSocketImpl.doConnect(Unknown Source)
          at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
          at java.net.PlainSocketImpl.connect(Unknown Source)
          at java.net.SocksSocketImpl.connect(Unknown Source)
          at java.net.Socket.connect(Unknown Source)
          at org.jboss.remoting.transport.socket.SocketClientInvoker.createSocket(
          SocketClientInvoker.java:187)
          at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.getConne
          ction(MicroSocketClientInvoker.java:801)
          at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transpor
          t(MicroSocketClientInvoker.java:526)
          at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientI
          nvoker.java:122)
          at org.jboss.remoting.Client.invoke(Client.java:1550)
          at org.jboss.remoting.Client.invoke(Client.java:530)
          at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemot
          eInterceptor.java:62)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPr
          opagationInterceptor.java:61)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityC
          lientInterceptor.java:53)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.
          java:72)
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
          java:101)
          at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteP
          roxy.java:103)
          at $Proxy0.getUser(Unknown Source)
          at org.simplex.ui.main.mainFrame.onStartButton(mainFrame.java:88)
          at org.simplex.ui.main.mainFrame.access$000(mainFrame.java:18)
          at org.simplex.ui.main.mainFrame$1.mouseClicked(mainFrame.java:58)
          at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
          at java.awt.Component.processMouseEvent(Unknown Source)
          at javax.swing.JComponent.processMouseEvent(Unknown Source)
          at java.awt.Component.processEvent(Unknown Source)
          at java.awt.Container.processEvent(Unknown Source)
          at java.awt.Component.dispatchEventImpl(Unknown Source)
          at java.awt.Container.dispatchEventImpl(Unknown Source)
          at java.awt.Component.dispatchEvent(Unknown Source)
          at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
          at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
          at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
          at java.awt.Container.dispatchEventImpl(Unknown Source)

          • 2. Re: Using an EJB from an remote app client does not work
            alrubinger

            Looks like the client is obtaining the Proxy from the remote server, but the Proxy is attempting to invoke upon localhost (127.0.0.1).

            ...Proxy Obtained:

            at $Proxy0.getUser(Unknown Source)


            ...Invoking on localhost:

            Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://127.0.0.1:3873/]


            I wonder if by manually setting "-b" at startup, you instruct JBoss to have the Property "jboss.bind.address" set to localhost, which is where the InvokerLocator will bind to. Might be best to set -b to 132.180.60.3 if possible, or look at your machine's IP Configuration in /etc/hosts and remove this switch alltogether..

            S,
            ALR