Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-6107 Update JBoss Serialization in JBoss EAP 5.1.1
  3. JBPAPP-6102

JDK 6_19 update breaks deserialization of java.io.File results in ClassCastException

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Done
    • Major
    • EAP_EWP 5.1.1
    • EAP 5.0.0, EWP 5.0.0, EAP 5.0.1, EWP 5.0.1, EAP_EWP 5.1.0
    • EJB
    • None
    • JBoss EAP 5.0 on Sun JDK 6_19 and higher

    • Release Notes
    • Hide
      If you use JDK 6 update19 or newer, and your application sends or receives <classname>java.io.File</classname> objects, a serialization exception may occur. This exception can also happen if you are using clustering with a stateful session containing a <classname>java.io.File</classname> object.

      To prevent this exception, a new property has been added. Set the system property <property>-Dorg.jboss.serial.SYNC_SERIALIZATION_BINARY_FORMATS=true</property>, for all JBoss instances that communicate with each other.
      Show
      If you use JDK 6 update19 or newer, and your application sends or receives <classname>java.io.File</classname> objects, a serialization exception may occur. This exception can also happen if you are using clustering with a stateful session containing a <classname>java.io.File</classname> object. To prevent this exception, a new property has been added. Set the system property <property>-Dorg.jboss.serial.SYNC_SERIALIZATION_BINARY_FORMATS=true</property>, for all JBoss instances that communicate with each other.
    • Documented as Resolved Issue

    Description

      JBoss Serialization fails because the JDK 6 update 19 changes the way java.io.File deserializes. java.io.File uses defaultWriteObject when serializing and uses defaultReadObject prior to update 19. For 19 and higher, it uses defaultWriteObject when serializing and uses readFields when deserializing. JBoss Serialzation's format is not binary compatiable when using defaultWriteObject and then using readFields. This causes EJB clients that are running in the same JVM as the EJB to fail with the ClassCastException below.

      JDK 6_18
      private synchronized void readObject(java.io.ObjectInputStream s)
      throws IOException, ClassNotFoundException

      { s.defaultReadObject(); char sep = s.readChar(); // read the previous separator char if (sep != separatorChar) this.path = this.path.replace(sep, separatorChar); this.path = fs.normalize(this.path); this.prefixLength = fs.prefixLength(this.path); }

      ****************************************************************************************
      JDK 6_19
      private synchronized void readObject(java.io.ObjectInputStream s)
      throws IOException, ClassNotFoundException

      { ObjectInputStream.GetField fields = s.readFields(); String pathField = (String)fields.get("path", null); char sep = s.readChar(); // read the previous separator char if (sep != separatorChar) pathField = pathField.replace(sep, separatorChar); this.path = fs.normalize(pathField); this.prefixLength = fs.prefixLength(this.path); }

      The exception is:

      Caused by: java.lang.reflect.UndeclaredThrowableException
      at $Proxy71.hello(Unknown Source)
      at com.jboss.examples.ejb3.gui.BackingBean.hello(BackingBean.java:62)
      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:597)
      at org.apache.el.parser.AstValue.invoke(AstValue.java:172)
      at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
      ... 26 more
      Caused by: java.io.IOException
      at org.jboss.serial.persister.RegularObjectPersister.readSlotWithMethod(RegularObjectPersister.java:107)
      at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:269)
      at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:241)
      at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      at org.jboss.serial.persister.RegularObjectPersister.readSlotWithFields(RegularObjectPersister.java:353)
      at org.jboss.serial.persister.RegularObjectPersister.defaultRead(RegularObjectPersister.java:273)
      at org.jboss.serial.persister.RegularObjectPersister.readData(RegularObjectPersister.java:241)
      at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
      at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
      at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readObject(DataContainer.java:845)
      at org.jboss.serial.io.MarshalledObjectForLocalCalls.get(MarshalledObjectForLocalCalls.java:60)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:96)
      at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:107)
      ... 36 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:597)
      at org.jboss.serial.persister.RegularObjectPersister.readSlotWithMethod(RegularObjectPersister.java:103)
      ... 52 more
      Caused by: org.jboss.serial.exception.SerializationException: Excepted to be int
      at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readInt(DataContainer.java:1048)
      at org.jboss.serial.persister.ObjectInputStreamProxy.readInt(ObjectInputStreamProxy.java:156)
      at org.jboss.serial.objectmetamodel.FieldsContainer.readMyself(FieldsContainer.java:214)
      at org.jboss.serial.persister.ObjectInputStreamProxy.readFields(ObjectInputStreamProxy.java:224)
      at java.io.File.readObject(File.java:1927)
      ... 57 more
      Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.jboss.serial.finalcontainers.IntegerContainer
      at org.jboss.serial.objectmetamodel.DataContainer$DataContainerInput.readInt(DataContainer.java:1044)
      ... 61 more

      Attachments

        Activity

          People

            rhn-support-bmaxwell Brad Maxwell
            rhn-support-bmaxwell Brad Maxwell
            Misty Stanley-Jones Misty Stanley-Jones (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: