Erlend Birkenes | 1 Mar 01:05 2012

Serialization problem

Hi

I'm trying to serialize my Cayenne entities using JBoss Marshaller, but I
get the following errors (keeping them short as the details are not
important, see further explanation below):

Serverside: java.io.NotActiveException: Fields were never written
...

Clientside: EOFException: Read past end of file
     [java]     at
org.jboss.marshalling.SimpleDataInput.eofOnRead(SimpleDataInput.java:126)
     [java]     at
org.jboss.marshalling.SimpleDataInput.readUnsignedByteDirect(SimpleDataInput.java:263)
     [java]     at
org.jboss.marshalling.SimpleDataInput.readUnsignedByte(SimpleDataInput.java:224)
     [java]     at
org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:209)
     [java]     at
org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1677)
     [java]     at
org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1593)
     [java]     at
org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1235)
     ....

While googling the problem I came across this issue:
https://issues.jboss.org/browse/JBMAR-67 indicating what the problem might
be.
I checked the Cayenne source and CayenneDataObject do indeed implement
(Continue reading)

Andrus Adamchik | 5 Mar 00:56 2012

Re: Serialization problem

You might be right indeed. Cayenne serialization behavior was implemented based on the description from
java.io.Serializable javadocs, which does not mention a call to 'defaultWriteObject' as required. So
it is skipped... Sure enough that has never caused us any problems with the JDK (there's lots of
serialization tests in our unit test suite). 

But of course alternative serialization solutions are free to complain about this behavior, and that
seems to be the case with River marshaller. 

Appreciate if you can open a bug report in Cayenne Jira. I think we can fix it...

Andrus

On Feb 29, 2012, at 7:05 PM, Erlend Birkenes wrote:
> Hi
> 
> I'm trying to serialize my Cayenne entities using JBoss Marshaller, but I
> get the following errors (keeping them short as the details are not
> important, see further explanation below):
> 
> Serverside: java.io.NotActiveException: Fields were never written
> ...
> 
> Clientside: EOFException: Read past end of file
>     [java]     at
> org.jboss.marshalling.SimpleDataInput.eofOnRead(SimpleDataInput.java:126)
>     [java]     at
> org.jboss.marshalling.SimpleDataInput.readUnsignedByteDirect(SimpleDataInput.java:263)
>     [java]     at
> org.jboss.marshalling.SimpleDataInput.readUnsignedByte(SimpleDataInput.java:224)
>     [java]     at
(Continue reading)

Erlend Birkenes | 5 Mar 12:53 2012

Re: Serialization problem

Hi Andrus

2012/3/5 Andrus Adamchik <andrus <at> objectstyle.org>

> You might be right indeed. Cayenne serialization behavior was implemented
> based on the description from java.io.Serializable javadocs, which does not
> mention a call to 'defaultWriteObject' as required. So it is skipped...
> Sure enough that has never caused us any problems with the JDK (there's
> lots of serialization tests in our unit test suite).
>

Yeah, I ended up building my own version of River commenting out just the
lines (in RiverObjectOutputStream and RiverObjectInputStream) where the
exception is thrown and it works just fine.

>
> But of course alternative serialization solutions are free to complain
> about this behavior, and that seems to be the case with River marshaller.
>

Yes, that is the case, and I'm not sure what is the correct way to do this.
I'm leaning more and more towards that River is way too strict on this.
There is probably a reason this is only in the spec and not strictly
enforced anywhere else.
The spec says: "the behavior of instance deserialization is undefined in
cases where the ObjectInputStream cannot resolve the class which defined
the writeObject method". I don't know which cases those are, but this is
not one of them. It works fine in Cayenne when I disable the exceptions. As
you said, the Serializable javadoc says that you CAN invoke
defaultWriteObject, not that you must. This is all very vague and I'm not
(Continue reading)

Durchholz, Joachim | 5 Mar 13:26 2012
Picon

RE: Serialization problem

> One thing to consider is that River is doing marshalling,
> which apparently is slightly different from serialization,

In my book, they are both the same: convert an object to an untyped data (byte/word/whatever) stream and
back, restoring the original functionality of the serialized/marshalled object.

> but the actual difference is not clear to me. I don't know if that is important.

That depends on what the definitions are in River's book.
It looks like River isn't spelling these out clearly enough.

Andrus Adamchik | 5 Mar 14:40 2012

Re: Serialization problem


On Mar 5, 2012, at 6:53 AM, Erlend Birkenes wrote:

>> 
>> 
>> Appreciate if you can open a bug report in Cayenne Jira. I think we can
>> fix it...
>> 
> 
> I can do that, but I'm not yet sure that it is a Cayenne problem. Cayenne
> tries to serialize only the ObjectId if possible, and by calling
> defaultWriteObject wouldn't you lose that functionality? Wouldn't it then
> serialize all the fields every time? I don't think we want that. Or did you
> have another solution in mind?

I think I we can achieve compliant serialization behavior by using "transient" on fields that are
serialized manually. But yeah, this is certainly low priority, especially since you've found a workaround.

Andrus

Erlend Birkenes | 5 Mar 14:54 2012

Re: Serialization problem

2012/3/5 Durchholz, Joachim <Joachim.Durchholz <at> hennig-fahrzeugteile.de>

> > One thing to consider is that River is doing marshalling,
> > which apparently is slightly different from serialization,
>
> In my book, they are both the same: convert an object to an untyped data
> (byte/word/whatever) stream and back, restoring the original functionality
> of the serialized/marshalled object.
>
> > but the actual difference is not clear to me. I don't know if that is
> important.
>
> That depends on what the definitions are in River's book.
> It looks like River isn't spelling these out clearly enough.
>

Yeah, I agree on that. I will take this up with the River people and see
what they say about it.

-Erlend
Erlend Birkenes | 5 Mar 15:01 2012

Re: Serialization problem

2012/3/5 Andrus Adamchik <andrus <at> objectstyle.org>

>
> I think I we can achieve compliant serialization behavior by using
> "transient" on fields that are serialized manually.

Yes, I think that is probably the "correct" way to do this. I think that is
what the spec means by "optional fields".

> But yeah, this is certainly low priority, especially since you've found a
> workaround.
>

Agreed, even though I don't feel having to build a custom jar is a good
workaround, but it will do for right now.
I'll take this up with the River developers and I can create a Jira issue
after that if necessary.

-Erlend
cghersi | 5 Mar 16:57 2012

Temporary ID hasn't been replaced on commit

Hi all,

I'm using Cayenne 3.0. For more then 1 year we hadn't got any issue; now,
suddenly, sometimes it appears a strange Exception: "Temporary ID hasn't
been replaced on commit".
It appears on an object whose table has an autogenerated PK.

What can I do to avoid such a situation?

Thank you very much.
Best
cghersi

--
View this message in context: http://cayenne.195.n3.nabble.com/Temporary-ID-hasn-t-been-replaced-on-commit-tp3801043p3801043.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

cghersi | 5 Mar 16:57 2012

Temporary ID hasn't been replaced on commit

Hi all,

I'm using Cayenne 3.0. For more then 1 year we hadn't got any issue; now,
suddenly, sometimes it appears a strange Exception: "Temporary ID hasn't
been replaced on commit".
It appears on an object whose table has an autogenerated PK.

What can I do to avoid such a situation?

Thank you very much.
Best
cghersi

--
View this message in context: http://cayenne.195.n3.nabble.com/Temporary-ID-hasn-t-been-replaced-on-commit-tp3801044p3801044.html
Sent from the Cayenne - User mailing list archive at Nabble.com.

cghersi | 5 Mar 17:01 2012

Temporary ID hasn't been replaced on commit

Hi all,

I'm using Cayenne 3.0. For more then 1 year we hadn't got any issue; now,
suddenly, sometimes it appears a strange Exception: "Temporary ID hasn't
been replaced on commit".
It appears on an object whose table has an autogenerated PK.

What can I do to avoid such a situation?

Thank you very much.
Best
cghersi

--
View this message in context: http://cayenne.195.n3.nabble.com/Temporary-ID-hasn-t-been-replaced-on-commit-tp3801058p3801058.html
Sent from the Cayenne - User mailing list archive at Nabble.com.


Gmane