9 Replies Latest reply on Apr 8, 2008 10:42 AM by Anand Ramadurg

    Aspectized replicable POJO, could not serialize to send a co

    Bahata Mukhopadhyay Newbie

      Hi
      The problem is that once any POJO class is aspectized, if I try to serialize it to send it over to my Fat Clients , a NotSerializable exception is thrown as the interceptor fields added to POJO due to aspectization are not serializable. I tried cloning the pOJOs to work around the problem, but did not succeed.

      My current application architecture is that we have fat clients (jvms) running at client machines. At server side we have 2 server nodes, with POJO cache REPLICATED in the two nodes. The fat clients , initially takes a copy of a subset of the POJO object graph stored in server cache by sending a request to the HTTP servlet. The servlet then copies the required part of the cache and sends it over to the client.

      Whenever the client commits any change, it sends that delta of information to the server and the server updates its POJO cache accordingly. The change is then replicated to the other server node as the POJO cache is replicable (configured with replSync-service.xml)

      Now the problem is that at Fat-Clients I do not want the replicable aspectized pojo but my original POJO. Please let me know if there is any work around ,
      or any feature can be added to clone the POJO without its aspectized features!

      Kindly note that : I have also read the post "How do I serialized an POJO stored in the cache" at http://www.jboss.com/index.html?module=bb&op=viewtopic&t=94405. Here what Ben Wang says that "removing the object from cache" before trying to serialize it would help. But 1) In my case it is not only the proxy field problem, but that the class has the interceptor fields into it as I made the pojos replicable using @org.jboss.cache.pojo.annotation.Replicable annotation.

        • 1. Re: Aspectized replicable POJO, could not serialize to send
          Jason Greene Master

          What version of POJO Cache are you running?

          As long as your object is marked serializable, it should work. Current versions of JBoss AOP only add transient fields.

          • 2. Re: Aspectized replicable POJO, could not serialize to send
            Bahata Mukhopadhyay Newbie

            Hi
            Thank you so much for the reply. I am using JBossCache-pojo-2.0.0.GA.

            Below is the Exceptions stack trace . Kindly help.



            ----------------------------------------------------------------------------------
            ----------------------------------------------------------------------------------
            Message: I/O error occured while reading packet!

            java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.jboss.cache.pojo.interceptors.dynamic.CachedListInterceptor
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.readObject(Unknown Source)
            at java.util.ArrayList.readObject(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
            at java.io.ObjectInputStream.readSerialData(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
            at java.io.ObjectInputStream.readSerialData(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
            at java.io.ObjectInputStream.readSerialData(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.readObject(Unknown Source)
            at java.util.HashMap.readObject(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
            at java.io.ObjectInputStream.readSerialData(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
            at java.io.ObjectInputStream.readSerialData(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
            at java.io.ObjectInputStream.readSerialData(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.readObject(Unknown Source)
            at ft.common.ServletUtilities.readMessagePacket(ServletUtilities.java:281)
            at ft.common.ServletUtilities.sendMessagePacket(ServletUtilities.java:150)
            at ft.oots.controller.ServerController.sendMessagePacket(ServerController.java:143)
            at ft.oots.controller.ServerController.sendMessagePacket(ServerController.java:133)
            at ft.oots.controller.ServerController.loadDataModel(ServerController.java:214)
            at ft.oots.controller.SynchronizationController.loadDataModel(SynchronizationController.java:62)
            at ft.oots.Application.(Application.java:130)
            at ft.oots.Application.main(Application.java:522)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at com.sun.javaws.Launcher.executeApplication(Unknown Source)
            at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
            at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
            at com.sun.javaws.Launcher.run(Unknown Source)
            at java.lang.Thread.run(Unknown Source)
            Caused by: java.io.NotSerializableException: org.jboss.cache.pojo.interceptors.dynamic.CachedListInterceptor
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.writeObject(Unknown Source)
            at java.util.ArrayList.writeObject(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
            at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
            at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
            at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
            at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
            at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
            at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.writeObject(Unknown Source)
            at java.util.HashMap.writeObject(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
            at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
            at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
            at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
            at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
            at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
            at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
            at java.io.ObjectOutputStream.writeObject0(Unknown Source)
            at java.io.ObjectOutputStream.writeObject(Unknown Source)
            at ft.common.ServletUtilities.writeMessagePacket(ServletUtilities.java:321)
            at ft.oots.servlet.CoreServlet.doPost(CoreServlet.java:327)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
            ... 1 more
            java.io.ObjectInputStream@1f45f2a
            16:59:18,453 INFO javawsApplicationMain ServerController.sendMessagePacket() - Data is back: null
            #### Java Web Start Error:
            #### null

            • 3. Re: Aspectized replicable POJO, could not serialize to send
              Jason Greene Master

              This looks like an issue with the ClassicInstrumentor in JBoss AOP 1.5. Could you try using 2.1.0 (just released)?

              • 4. Re: Aspectized replicable POJO, could not serialize to send
                Jason Greene Master

                To clarify I mean POJO Edition 2.1.0

                • 5. Re: Aspectized replicable POJO, could not serialize to send
                  Anand Ramadurg Newbie

                  hello bahata,

                  I am facing the same problem, were u able to solve the problem?

                  If yes, could please explain me how??

                  Regards
                  Anand

                  • 6. Re: Aspectized replicable POJO, could not serialize to send
                    Anand Ramadurg Newbie

                    I have tried with JBoss2.1 version, still getting following excpetion

                    Caused by: java.io.NotSerializableException: org.jboss.cache.pojo.interceptors.dynamic.CachedListInterceptor
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject(Ljava.lang.Object;)V(Unknown Source)
                    at java.util.ArrayList.writeObject(ArrayList.java:569)
                    at java.lang.LangAccessImpl.writeObject(Ljava.lang.Class;Ljava.lang.Object;Ljava.io.ObjectOutputStream;)V(Unknown Source)
                    at java.io.ObjectStreamClass.invokeWriteObject(Ljava.lang.Object;Ljava.io.ObjectOutputStream;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeSerialData(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(Ljava.lang.Object;Ljava.io.ObjectStreamClass;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.defaultWriteFields(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeSerialData(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(Ljava.lang.Object;Ljava.io.ObjectStreamClass;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.defaultWriteFields(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeSerialData(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(Ljava.lang.Object;Ljava.io.ObjectStreamClass;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.defaultWriteFields(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeSerialData(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(Ljava.lang.Object;Ljava.io.ObjectStreamClass;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.defaultWriteFields(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeSerialData(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(Ljava.lang.Object;Ljava.io.ObjectStreamClass;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject(Ljava.lang.Object;)V(Unknown Source)
                    at java.util.HashMap.writeObject(Ljava.io.ObjectOutputStream;)V(Unknown Source)
                    at java.lang.LangAccessImpl.writeObject(Ljava.lang.Class;Ljava.lang.Object;Ljava.io.ObjectOutputStream;)V(Unknown Source)
                    at java.io.ObjectStreamClass.invokeWriteObject(Ljava.lang.Object;Ljava.io.ObjectOutputStream;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeSerialData(Ljava.lang.Object;Ljava.io.ObjectStreamClass;)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(Ljava.lang.Object;Ljava.io.ObjectStreamClass;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject0(Ljava.lang.Object;Z)V(Unknown Source)
                    at java.io.ObjectOutputStream.writeObject(Ljava.lang.Object;)V(Unknown Source)

                    • 8. Re: Aspectized replicable POJO, could not serialize to send
                      Jason Greene Master

                      Serialization is not currently possible with collections, however you can work around it by using a copy constructor on a collection i.e.

                      new ArrayList(cachedCollection);

                      If you don't want the copying, you can also implement your own collection class that implements Externalizable, and just writes out every entry in the list.

                      I scheduled real support for this in 2.2:
                      http://jira.jboss.com/jira/browse/PCACHE-66

                      • 9. Re: Aspectized replicable POJO, could not serialize to send
                        Anand Ramadurg Newbie

                        Thanks a lot for your reply.

                        Regards
                        Anand