6 Replies Latest reply on Sep 4, 2003 6:28 PM by scttu

    Usage of RMIConnector!

    scttu

      I am using the RMIConnector to retrieve a static Object in my mbean. This static object itself contain some static fields. Whenever i try to invoke the method to return the object i get the following errors.

      Whereas, if i try to return an object which doesn't contain static object in itself. it's works fine.

      Could someone show me, if i have done it wrong!

      Thanks

      java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
      java.io.InvalidClassException: my.com.shinyang.eply.context.AbstractContextManager; local class incompatible: stream classdesc serialVersionUID = -5693566174795313008, local class serialVersionUID = -5598626853284665873
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)
      at org.jboss.jmx.adaptor.rmi.RMIAdaptorImpl_Stub.invoke(Unknown Source)
      at org.jboss.jmx.connector.rmi.RMIConnectorImpl.invoke(RMIConnectorImpl.java:459)
      at my.com.shinyang.eply.test.MBeanTest.getContext(MBeanTest.java:137)
      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 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:392)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
      Caused by: java.io.InvalidClassException: my.com.shinyang.eply.context.AbstractContextManager; local class incompatible: stream classdesc serialVersionUID = -5693566174795313008, local class serialVersionUID = -5598626853284665873
      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)object is null

      at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:297)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:146)
      ... 18 more

        • 1. Re: Usage of RMIConnector!

          Make sure you have the same version of the class file (serialization compatible) on both the server and client side... ?

          -- Juha

          • 2. Re: Usage of RMIConnector!
            scttu

            Juha,

            Yeah, i solve the serialization problems.

            another question, this is what i intended to do. I have static object in the mbean. The static object itself contains a static HashMap. Whever i use RMIConnector to invoke a method to get the static object in the mbean. I got the object successfully, however, the static HashMap is empty. I'm sure HashMap in the mbean at server is not empty.

            How should i do this correctly???

            Please help

            Thanks





            • 3. Re: Usage of RMIConnector!

              Sounds like you're doing a shallow copy of the map rather than a deep copy (only creating a copy of the map but not copies of its content).

              You need to have your object implement the Serializable interface and make sure to create a deep copy of the map in the writeObject() implementation (and recreate the map in the readObject() impl.)

              -- Juha

              • 4. Re: Usage of RMIConnector!
                scttu

                Juha,

                Do you have any example of how to do HashMap marshalling?

                In my implementation, i have all the object in the HashMap implement Serializable, but the Values of the HashMap just doesn't get copy over.

                Thanks

                • 5. Re: Usage of RMIConnector!

                  I looked at the HashMap implementation it does attempt to serialize all the keys and values stored in the map. So as long as you're key value pairs are serializable it should copy them over.

                  I'm not sure why you're getting an empty map on the client side.

                  -- Juha

                  • 6. Re: Usage of RMIConnector!
                    scttu

                    I have successfully get it working. Thanks Juha. You have being very helpful.