2 Replies Latest reply on Jan 24, 2012 11:40 PM by jaikiran pai

    java.io.InvalidObjectException with EJB JNDI over Remoting in 7.1.0

    Will Reichert Newbie

      I deployed a sample EJB application with a simple remote EJB to test the remote EJB JNDI lookup using Remoting. Whenever I try and call a method on the EJB I encounter the following exception on the server:

      10:38:39,921 (Controller Boot Thread) INFO  [org.jboss.as] JBoss AS 7.1.0.CR1b "Flux Capacitor" started in 8967ms - Started 926 of 1018 services (86 services are passive or on-demand)
      10:48:54,148 (Remoting "t520" task-4) ERROR [org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver] Exception on channel Channel ID 45b074ce (inbound) of Remoting connection 67db3f45 to /127.0.0.1:47056 from message org.jboss.remoting3.remote.InboundMessage$3@7830b95f: java.io.InvalidObjectException: ObjectTable org.jboss.as.ejb3.remote.protocol.versionone.ProtocolV1ObjectTable cannot find an object for object index 1
                at org.jboss.as.ejb3.remote.protocol.versionone.ProtocolV1ObjectTable.readObject(ProtocolV1ObjectTable.java:61)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:351)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
                at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1673)
                at org.jboss.marshalling.river.RiverObjectInputStream.defaultReadObject(RiverObjectInputStream.java:73)
                at org.jboss.ejb.client.EJBLocator.readObject(EJBLocator.java:209)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_b147-icedtea]
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_b147-icedtea]
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_b147-icedtea]
                at java.lang.reflect.Method.invoke(Method.java:601) [:1.7.0_b147-icedtea]
                at org.jboss.marshalling.reflect.SerializableClass.callReadObject(SerializableClass.java:211) [jboss-marshalling-1.3.4.GA.jar:1.3.4.GA]
                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1576)
                at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1553)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1231)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:272)
                at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
                at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:37) [jboss-marshalling-1.3.4.GA.jar:1.3.4.GA]
                at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:131)
                at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:147)
                at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:409) [jboss-remoting-3.2.0.CR8.jar:3.2.0.CR8]
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_b147-icedtea]
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_b147-icedtea]
                at java.lang.Thread.run(Thread.java:722) [:1.7.0_b147-icedtea]
      Caused by: an exception which occurred:
                in field appName
                in object of type org.jboss.ejb.client.StatelessEJBLocator
      

       

      The error occurs for several EJBs in various applications but does not occur when using the same client code and ear in a SNAPSHOT build from 7.1.0 master. I assume this means the problem was already fixed with a change to master but I thought I would ask to make sure I am not missing something. The client code for the sample application is as follows:

      Hashtable<String,String> prop = new Hashtable<String,String>();
      prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
      prop.put(Context.PROVIDER_URL, "localhost:1099");
      prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
      prop.put("com.sun.appserv.iiop.endpoints", "localhost:1099");
      prop.put("org.omg.CORBA.ORBInitialHost", "localhost");
      prop.put("org.omg.CORBA.ORBInitialPort", "1099");
      prop.put("networkaddress.cache.ttl", "0");
      prop.put("sun.net.inetaddr.ttl", "0");
      InitialContext context = new InitialContext(prop);
      RemoteHelloRemote obj = (RemoteHelloRemote) context.lookup("ejb:sampleRemoteEAR/sampleRemoteEJB//RemoteHello!org.sample.remote.ejb.RemoteHelloRemote");
      System.out.println(obj.getMessage());
      

       

      and jboss-ejb-client.properties:

      endpoint.name=client-endpoint
      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
      remote.connections=default
      remote.connection.default.host=localhost
      remote.connection.default.port=4447
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      
        • 1. Re: java.io.InvalidObjectException with EJB JNDI over Remoting in 7.1.0
          Prasad Deshpande Expert

          Can you please check your jboss-remoting-3.2.0.xxxx.jar is correct in your remote client classpath & is matching with the server that you are trying to connect to?

           

          Also, you don't need following properties while creating initial context, unless you purposely added them..

          Hashtable<String,String> prop = new Hashtable<String,String>();
          prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
          prop.put(Context.PROVIDER_URL, "localhost:1099");
          prop.put("com.sun.appserv.iiop.endpoints", "localhost:1099");
          prop.put("org.omg.CORBA.ORBInitialHost", "localhost");
          prop.put("org.omg.CORBA.ORBInitialPort", "1099");
          prop.put("networkaddress.cache.ttl", "0");
          prop.put("sun.net.inetaddr.ttl", "0");
          InitialContext context = new InitialContext(prop);
          RemoteHelloRemote obj = (RemoteHelloRemote) context.lookup("ejb:sampleRemoteEAR/sampleRemoteEJB//RemoteHello!org.sample.remote.ejb.RemoteHelloRemote");
          System.out.println(obj.getMessage());
          

           

          All you need is prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); & jboss-ejb-client.properties in your remote client classpath.

          • 2. Re: java.io.InvalidObjectException with EJB JNDI over Remoting in 7.1.0
            jaikiran pai Master

            Like Prasad says, this appears to be a jar version conflict issue. My guess is that you are using an incorrect version of jboss-ejb-client.jar (and probably others too) on the client classpath as compared to what you have on server.