0 Replies Latest reply on Jan 23, 2003 5:06 AM by Ingmar Stein

    Deserializing large files

    Ingmar Stein Newbie

      Hi all,

      I'm experiencing a strange problem concerning the deserialization of large files.

      When I try to read from an ObjectInputStream whose
      underlying buffer is larger than a certain threshold
      (it works with 300k, but fails with 900k), then I
      get a NullPointerException.
      It doesn't matter if the ObjectInputStream operates
      on a FileInputStream or a ByteArrayInputStream, the
      error occurs in the readObject method.

      The exact location where the Exception is thrown is

      public int hashCode() {
      >>> return getName().hashCode();

      For some reason, the name field is set to null
      although it is non-null in the serialized class.

      What is even more confusing is the fact that it
      works fine outside JBoss, i.e. as a standalone
      console application.

      This is JBoss' stacktrace:

      10:50:29,111 ERROR [STDERR] java.lang.NullPointerException
      10:50:29,111 ERROR [STDERR] at Entry.hashCode(Unknown Source)
      10:50:29,111 ERROR [STDERR] at java.util.HashMap.hash(HashMap.java:257)
      10:50:29,111 ERROR [STDERR] at java.util.HashMap.putForCreate(HashMap.java:400)
      10:50:29,111 ERROR [STDERR] at java.util.HashMap.readObject(HashMap.java:987)
      10:50:29,111 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      10:50:29,157 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      10:50:29,157 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      10:50:29,157 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
      10:50:29,157 ERROR [STDERR] at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:824)
      10:50:29,157 ERROR [STDERR] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
      10:50:29,157 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      10:50:29,157 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      10:50:29,157 ERROR [STDERR] at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
      10:50:29,157 ERROR [STDERR] at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
      10:50:29,173 ERROR [STDERR] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
      10:50:29,173 ERROR [STDERR] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
      10:50:29,173 ERROR [STDERR] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
      10:50:29,173 ERROR [STDERR] at ....
      10:50:29,173 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      As you can see, the following code in HashMap.java

      for(int i=0; i<size; i++) {
      Object key = s.readObject();
      Object value = s.readObject();
      putForCreate(key, value)

      "key" is read correcly, but it is probably invalidated inside putForCreate().

      Thanks in advance,