6 Replies Latest reply on May 23, 2006 6:21 PM by Clebert Suconic

    SerializationException, not sure about the source

    Henrique Sousa Newbie

      Hi, guys.
      I'm receiving an exception, apparently with the return value of a remote call to a session bean. This is the exception stack trace:

      org.jboss.serial.exception.SerializationException
       at org.jboss.serial.persister.PrivateWritePersister.readData(PrivateWritePersister.java:134)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:167)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:55)
       at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:657)
       at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:204)
       at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:151)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:167)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:55)
       at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:657)
       at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:204)
       at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:151)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:167)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:55)
       at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:657)
       at org.jboss.serial.io.JBossObjectInputStream.readObjectOverride(JBossObjectInputStream.java:85)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333)
       at org.jboss.serial.io.MarshalledObject.get(MarshalledObject.java:68)
       at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
       at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
       ... 46 more
      Caused by: java.lang.reflect.InvocationTargetException
       at sun.reflect.GeneratedMethodAccessor203.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.jboss.serial.persister.PrivateWritePersister.readData(PrivateWritePersister.java:124)
       ... 65 more
      Caused by: org.jboss.serial.exception.SerializationException
       at org.jboss.serial.persister.PrivateWritePersister.readData(PrivateWritePersister.java:134)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:167)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:55)
       at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:657)
       at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:204)
       at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:151)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:167)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:55)
       at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:657)
       at org.jboss.serial.persister.ObjectInputStreamProxy.readObjectOverride(ObjectInputStreamProxy.java:65)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333)
       at java.util.HashSet.readObject(HashSet.java:278)
       ... 69 more
      Caused by: java.lang.reflect.InvocationTargetException
       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:585)
       at org.jboss.serial.persister.PrivateWritePersister.readData(PrivateWritePersister.java:124)
       ... 80 more
      Caused by: java.lang.NullPointerException
       at sun.util.calendar.BaseCalendar.getCalendarDateFromFixedDate(BaseCalendar.java:407)
       at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:2054)
       at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:1971)
       at java.util.Calendar.setTimeInMillis(Calendar.java:1066)
       at java.util.Calendar.setTime(Calendar.java:1032)
       at java.text.SimpleDateFormat.parseAmbiguousDatesAsAfter(SimpleDateFormat.java:733)
       at java.text.SimpleDateFormat.readObject(SimpleDateFormat.java:1869)
       ... 85 more

      The last call in my session is to EntityManager.persist(). All listeners are executed, database is modified and the transaction is committed. So I assume it has nothing to do with persistence. My next guess is the remote call itself. Since I did some RMI in the past, I made sure of some things before posting:
      1. The object returned implements java.io.Serializable, and so do all of its non-transient member variables. It also has a static long serialVersionUID.
      2. Client (.war) and server (ejb-jar) modules are packaged together (.ear) and use the same single .class for the parameter and return types.
      3. I cleared all compiled files from my app, stopped JBoss, removed tmp and work directories, deployed my application and started JBoss again to make sure there was no caching going on.
      Still the error lingers here. Do you people have any idea of what is going on? I'm desperate here

        • 2. Re: SerializationException, not sure about the source
          Henrique Sousa Newbie

          Since I cannot delete this topic, let me just say that I solved the problem. The thing is, as the error suggests, that I had a SimpleDateFormat that was not serializable. I declared it in a class as '"DateFormat fmt", and assigned a value to it as DateFormat.getDateInstance(). It was used to format some dates in toString(), so I made it static final and everything works. The world would be so perfect if I didn't do these stupidities.

          • 3. Re: SerializationException, not sure about the source
            Clebert Suconic Master

            You could have added the word transient on the field declaratio, this way JBossSerialization wont have used it.

            I asked you about the version because there were some problems with JBossSerialization used on JBoss 4.0.4 RCLatest.

            I created a testcase serializing a SimpleDateFormat, and it works fine. If you upgraded your version you would probably have your test working.

            Also, just some TIPs non related to your post:

            - be careful on moving SimpleDateFormat to a static class since it's non multi-thread.

            - I actually (as a programmer) would recommend to not use SimpleDateFormat unless your formatting is stored in a database field since its performance is pretty bad, hence Apache created some FastDateFormat classes.

            Two cents from someone who wrote a Profiler.

            • 4. Re: SerializationException, not sure about the source
              Henrique Sousa Newbie

              I guess we posted at the same time :)
              I'm using JBoss 4.0.4.CR2 (can't upgrade to GA right now because of some bad collection mapping; not my fault). Thanks for the tips, they are certainly very useful. I'm using that DateFormat just for debugging and intend to remove it soon -- as soon as everything else works. Thanks again

              • 5. Re: SerializationException, not sure about the source
                Jens Elkner Apprentice

                 

                "clebert.suconic@jboss.com" wrote:

                - I actually (as a programmer) would recommend to not use SimpleDateFormat unless your formatting is stored in a database field since its performance is pretty bad
                .

                Hmmm, would say, that depends. Its probably not as fast as Integer.toString(), but IMHO its still pretty fast and quite comfortable (especially if you have to consider timezone conversion etc.).

                What I've seen is, that the way hibernate uses SimpleDateFormat is often inefficient and actually that results in bad performance. E.g. hibernate often creates a new SimpleDateFormat when it needs one. Better would be to clone a static instance (since pattern is the same) and adjust its timezone if neccessary. This would safe the relative expensive compilation of the underlying format pattern, which is done for each new instance of a simpledateformat ...



                • 6. Re: SerializationException, not sure about the source
                  Clebert Suconic Master

                  Ok, ok... I forgot about timezone conversion.

                  But putting a hat of a customer I was once, on a system I was writting, simply using Calendars to do such conversions were much faster than using SimpleDateFormat. There is a lot of expression parser and compilations as you said, and if you don't need that avoiding it would improve performance.