5 Replies Latest reply on Mar 8, 2004 4:13 AM by dennislee

    javax.naming.CommunicationException

    vidhmani

      hi
      i am using jboss3.2.2
      i tried to invoke a ejb in the remote server.In my client i have installed security manager and also set the jndi properties.

      My client code is

      public class Client
      {
      public static void main(String args[]) throws Exception
      {
      if (System.getSecurityManager()== null)
      System.setSecurityManager(new RMISecurityManager());
      System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      System.setProperty("java.naming.provider.url","jnp://192.168.100.30:1099/");
      System.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      Properties props=System.getProperties();
      try{
      InitialContext jndiContext = new InitialContext(props);
      Object ref = jndiContext.lookup("account");
      AccountHome he= (AccountHome)PortableRemoteObject.narrow(ref,AccountHome.class);
      Account rem=he.create();
      int sum=rem.add(args[0],args[1]);
      System.out.println("Sum is"+sum);
      }
      catch(Exception e1)
      { e1.printStackTrace();}
      }
      }


      My error is (AccountHome is name of the home interface)


      javax.naming.CommunicationException. Root exception is java.lang.ClassNotFoundException: AccountHome
      at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:217)
      at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:703)
      at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:647)
      at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:584)
      at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:639)
      at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:309)
      at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:241)
      at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1469)
      at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1432)
      at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
      at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
      at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:30)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:550)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
      at javax.naming.InitialContext.lookup(InitialContext.java:347)
      at Client.main(Client.java:56)

      Can u help?
      thanks in advance
      vidhya

        • 1. Re: javax.naming.CommunicationException

          There is a bug in 3.2.2 where it doesn't bind the web classloader properly.
          It is fixed in 3.2.3 and you can also workaround the problem
          by specifying the host name when you start jboss.

          ./run.sh --host=your ip address or host name

          Regards,
          Adrian

          • 2. Re: javax.naming.CommunicationException
            vidhmani

            hi
            thanx , i gave the ip address when starting the jboss,but still it is showing following error

            ERROR [SecurityInterceptor] Authentication exception, principal=null
            ERROR [LogInterceptor] EJBException, causedBy:
            java.lang.SecurityException: Authentication exception, principal=null
            at org.jboss.ejb.plugins.SecurityInterceptor.checkSecurityAssociation(SecurityInterceptor.java:164)
            at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:81)
            at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
            at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
            at org.jboss.ejb.StatelessSessionContainer.internalInvokeHome(StatelessSessionContainer.java:319)
            at org.jboss.ejb.Container.invoke(Container.java:720)
            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:324)
            at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
            at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
            at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
            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:324)
            at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
            at sun.rmi.transport.Transport$1.run(Transport.java:148)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
            at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
            at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
            at java.lang.Thread.run(Thread.java:536)

            Regards,
            vidhya

            • 3. Re: javax.naming.CommunicationException

              That is a different error.
              You haven't logged in before accessing a secured ejb.

              Regards,
              Adrian

              • 4. Re: javax.naming.CommunicationException
                vidhmani

                hi
                will u pls tell me how to login to access secured ejb.
                thanx

                Regards,
                vidhya

                • 5. Re: javax.naming.CommunicationException
                  dennislee

                  try to do like following way

                  add following parameter in your JVM
                  -Djava.rmi.server.hostname=172.16.20.45(instead your server ip)