You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Benson Margulies <be...@basistech.com> on 2016/08/07 13:12:25 UTC

ObjectInputStreams, class loaders, OSGi

I've OSGi'ed a body of code that reads a model from an ObjectInputStream. I
didn't adjust the TCCL, and I didn't make a custom object input stream that
respects the TCCL, as per
http://tech-tauk.blogspot.com/2010/05/thread-context-classlaoder-in.html.
Yet, it works.

Except, strangely, when it does not. Under circumstances I am struggling to
isolate, it fails to read the object. This is not helped by the fact that
OIS, in this case, does not set the exception cause to reveal what actually
went wrong.

The exception is not a class-not-found at all. Has anyone else seen
anything like this?

java.lang.IllegalStateException: unread block data
at
java.io.ObjectInputStream$BlockDataInputStream.setBlockDataMode(ObjectInputStream.java:2431)[:1.8.0_60]
at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1383)[:1.8.0_60]
at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2000)[:1.8.0_60]