4 Replies Latest reply on Mar 17, 2006 11:04 AM by Terry

    how to connect to JBOSS server from the client ?

    Terry Newbie

      A Jboss 4.04RC1 server is running on 192.168.0.1 .
      And the ejb3 jar files have been successfully deployed .

      I want to connect to the server and get the JNDI environment from the client 192.168.0.2 .

      How to get it ?

      Thanks

        • 1. Re: how to connect to JBOSS server from the client ?
          Jorge Salido Newbie

          First configure the following properties:

           Properties props = new Properties();
           props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
           props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
           props.put("java.naming.provider.url", "jnp://192.168.0.1:1099");
          


          Then get the InitialContext, and then you can do the lookup for your beans from your client (Replace UserManager* class names for your own):
           try {
           InitialContext ctx = new InitialContext(props);
           UserManager manager = (UserManager) ctx.lookup("appname/UserManagerImpl/remote");
           ...
          


          Then you can use your retrieved object to work with your remote beans.

          That should help you get started.

          • 2. Re: how to connect to JBOSS server from the client ?
            Terry Newbie

            Thanks .
            I have tried . But the same error broke out .
            org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection.
            at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:253)
            at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:136)
            at org.jboss.remoting.Client.invoke(Client.java:444)
            at org.jboss.remoting.Client.invoke(Client.java:407)
            at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:41)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:46)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:40)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
            at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
            at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
            at $Proxy0.add(Unknown Source)
            at test.com.terry.ejb3.testCalculator.testSayHello(testCalculator.java:33)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:585)
            at junit.framework.TestCase.runTest(TestCase.java:154)
            at junit.framework.TestCase.runBare(TestCase.java:127)
            at junit.framework.TestResult$1.protect(TestResult.java:106)
            at junit.framework.TestResult.runProtected(TestResult.java:124)
            at junit.framework.TestResult.run(TestResult.java:109)
            at junit.framework.TestCase.run(TestCase.java:118)
            at junit.framework.TestSuite.runTest(TestSuite.java:208)
            at junit.framework.TestSuite.run(TestSuite.java:203)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
            at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
            Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
            at org.jboss.remoting.transport.socket.SocketClientInvoker.createClientSocket(SocketClientInvoker.java:504)
            at org.jboss.remoting.transport.socket.SocketClientInvoker.getConnection(SocketClientInvoker.java:471)
            at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:249)
            ... 29 more
            Caused by: java.lang.NoClassDefFoundError
            at org.jboss.remoting.transport.socket.ClientSocketWrapper.createOutputStream(ClientSocketWrapper.java:91)
            at org.jboss.remoting.transport.socket.ClientSocketWrapper.createStreams(ClientSocketWrapper.java:75)
            at org.jboss.remoting.transport.socket.ClientSocketWrapper.(ClientSocketWrapper.java:54)
            ... 36 more

            • 3. Re: how to connect to JBOSS server from the client ?
              Bill Burke Master

              u r missing jars on the client side. scroll down and see the NoClassDefFound

              • 4. Re: how to connect to JBOSS server from the client ?
                Terry Newbie

                Oh, yes . You are right .
                It's ok now after I add those jars in the server lib folder .
                Thank you !