2 Replies Latest reply on Sep 18, 2003 2:45 AM by Jon Barnett

    Who can tell me what lead to this strange error?

    wprusty Newbie

      First, I deploy my J2EEServerRemote ejb successfully.
      Then I make a client java file to test that ejb and I also add that ejb obeserver-ejb.jar to CALSSPATH.The test file as follow:
      import java.util.Hashtable;

      import javax.ejb.CreateException;
      import javax.naming.Context;
      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.rmi.PortableRemoteObject;

      import org.obe.client.api.rmi.J2EEServerRemote;
      import org.obe.client.api.rmi.J2EEServerRemoteHome;

      /**
      * @author Administrator
      *
      * To change the template for this generated type comment go to
      * Window>Preferences>Java>Code Generation>Code and Comments
      */
      public class Test {
      public static void main(String[] args){
      Hashtable h = new Hashtable();
      final J2EEServerRemote client;


      h.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");



      h.put(Context.PROVIDER_URL, "jnp://localhost:1099");


      h.put(Context.SECURITY_PRINCIPAL, "sa");


      h.put(Context.SECURITY_CREDENTIALS, "sa");
      try {
      Context ctx = new InitialContext(h);
      Object obj = ctx.lookup(J2EEServerRemoteHome.JNDI_NAME);
      J2EEServerRemoteHome home = (J2EEServerRemoteHome)
      PortableRemoteObject.narrow(obj,
      J2EEServerRemoteHome.class);
      System.out.println("begin");
      client = home.create();
      System.out.println("end");
      } catch (NamingException e) {
      System.out.println("error");
      e.printStackTrace();
      } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (CreateException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      }

      }
      Then I got an error just like follow:
      error
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:652)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.(InitialContext.java:195)
      at com.Test.main(Test.java:46)
      Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
      at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:219)
      at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
      ... 4 more
      So who can tell me what I should do to solve this problem? Thank you very much!

        • 1. Re: Who can tell me what lead to this strange error?
          wprusty Newbie

          Sorry,I got another error:
          error
          javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.proxy.ejb.GenericEJBInterceptor; local class incompatible: stream classdesc serialVersionUID = 3844706474734439975, local class serialVersionUID = 4582256576523491346]
          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:597)
          at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:443)
          at javax.naming.InitialContext.lookup(InitialContext.java:347)
          at com.Test.main(Test.java:47)
          Caused by: java.io.InvalidClassException: org.jboss.proxy.ejb.GenericEJBInterceptor; local class incompatible: stream classdesc serialVersionUID = 3844706474734439975, local class serialVersionUID = 4582256576523491346
          at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)
          at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
          at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
          at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
          at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
          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 org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:104)
          at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
          at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
          at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
          at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
          at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
          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:483)
          ... 3 more
          Who can help me?Thanks!

          • 2. Re: Who can tell me what lead to this strange error?
            Jon Barnett Master

            It looks like you are either using different client classes to that supplied with JBoss - the class UID is different between the one you are using in the client versus the one that JBoss is using. Look for your local library (client-side) that contains this class, org.jboss.proxy.ejb.GenericEJBInterceptor, and replace that with the library from your running JBoss distribution.

            If that is not the issue, most likely your client JVM is an old JDK. I remember that there was a problem where UIDs generated in newer JDKs are different to those generated in some older JDKs. However, it is not a situation I have encountered for several years now.