Marshalling an EntityManager using the river marshaller and the default MarshallingConfiguration generates the following error:
Caused by: java.io.NotActiveException: Fields were never written
at org.jboss.marshalling.river.RiverObjectOutputStream.finish(RiverObjectOutputStream.java:174)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:985)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:890)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1040)
at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:995)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:890)
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:392)
at org.jboss.ejb3.serial.entity.EntityAwareMarshalledObject.<init>(EntityAwareMarshalledObject.java:93)
at org.jboss.ejb3.stateful.StatefulBeanContext.writeExternal(StatefulBeanContext.java:979)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1421)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1390)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
at org.jboss.cache.marshall.CacheMarshaller200.marshallObject(CacheMarshaller200.java:460)
at org.jboss.cache.marshall.CacheMarshaller300.marshallObject(CacheMarshaller300.java:47)
at org.jboss.cache.marshall.CacheMarshaller200.marshallCommand(CacheMarshaller200.java:519)
at org.jboss.cache.marshall.CacheMarshaller200.marshallObject(CacheMarshaller200.java:314)
at org.jboss.cache.marshall.CacheMarshaller300.marshallObject(CacheMarshaller300.java:47)
at org.jboss.cache.marshall.CacheMarshaller200.marshallCommand(CacheMarshaller200.java:519)
at org.jboss.cache.marshall.CacheMarshaller200.marshallObject(CacheMarshaller200.java:314)
at org.jboss.cache.marshall.CacheMarshaller300.marshallObject(CacheMarshaller300.java:47)
at org.jboss.cache.marshall.CacheMarshaller200.objectToObjectStream(CacheMarshaller200.java:191)
at org.jboss.cache.marshall.CacheMarshaller200.objectToObjectStream(CacheMarshaller200.java:136)
at org.jboss.cache.marshall.VersionAwareMarshaller.objectToBuffer(VersionAwareMarshaller.java:182)
at org.jboss.cache.marshall.VersionAwareMarshaller.objectToBuffer(VersionAwareMarshaller.java:52)
at org.jboss.cache.marshall.CommandAwareRpcDispatcher$ReplicationTask.call(CommandAwareRpcDispatcher.java:369)
The problematic object is org.hibernate.impl.SessionImpl, which is Serializable, and has its own writeObject(OOS) method. Looking at RiverObjectOutputStream, in order for the State to not equal UNWRITTEN_FIELDS when finish(State) is called, something must call either defaultWriteObject() or writeFields(), neither of which are triggered by SessionImpl's writeObject(...) method.