PDA

View Full Version : persistence in SWF2 m4



ivan2007
Mar 27th, 2008, 05:54 PM
Hi,

I am having a problem with persisting an entity within a persistence context.
I get the following error:

org.springframework.webflow.execution.repository.c ontinuation.ContinuationCreationException: Could not serialize flow execution; make sure all objects stored in flow or flash scope are serializable; nested exception is java.io.NotSerializableException: org.hibernate.util.MarkerObject

java.io.NotSerializableException: org.hibernate.util.MarkerObject

Why is it trying to serialize a org.hibernate.util.MarkerObject object?
I want to point out that all my objects implement Serializable.

I made a small test application to illustrate my issue.
The following is my flow definition:

<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

<persistence-context/>

<view-state id="step1" view="echtgenoot">
<on-render>
<evaluate expression="echtgenootFormAction.setupForm"/>
</on-render>
<transition on="next" to="confirmView">
<evaluate expression="echtgenootFormAction.bindAndValidate"/>
<evaluate expression="mainService.saveOrFind(echtgenoot)"/>
</transition>
</view-state>

<view-state id="confirmView" view="successAangifte"/>

<end-state id="end" view="externalRedirect:../testing/main"/>

<global-transitions>
<transition on="exit" to="end"/>
</global-transitions>
<bean-import resource="test-context.xml"/>
</flow>

test-context.xml :

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="echtgenootFormAction" class="org.springframework.webflow.action.FormAction">
<property name="formObjectClass" value="Echtgenoot" />
<property name="formObjectName" value="echtgenoot"/>
<property name="validator" ref="personValidator"/>
</bean>
</beans>

I am working on a major project which uses webflow extensively and this really needs to be fixed. Maybe I am doing something wrong.
Can someone help me out?
I am willing to share a small test application (which I've made to investigate this) if necessary.

Thanks in advance.

Keith Donald
Mar 27th, 2008, 08:57 PM
What version of Hibernate? That would be helpful to reproduce.

Keith

ivan2007
Mar 27th, 2008, 09:02 PM
Thanks Keith,

I have Hibernate 3.2.6.
I could also send you my application files if necessary.

Marten Deinum
Mar 28th, 2008, 03:09 AM
My guess is that you are trying to store an object (retrieved by hibernate) in flow or conversation scope. Which would lead to serializaton of all the objects. Now the pesky thing hibernate is is that not everything from hibernate is serializable.

ivan2007
Mar 28th, 2008, 10:27 AM
Indeed. My code stores an object with hibernate but I need that object again to continue the flow. As you've seen in the flow definition, I call the saveOrFind method of the mainService.

This is something like:

public Echtgenoot saveOrFind(Echtgenoot e) {
Echtgenoot echtgenoot = echtgenootDao.get(e.getId());

if (echtgenoot != null) {

//Do some work .......

echtgenootDao.save(echtgenoot);

return echtgenoot;
} else {
echtgenootDao.save(e);
return e;
}
}

This method returns an object which is saved by hibernate. I need it to continue the flow. Echtgenoot implements Serializable. So I don't understand why this is still a problem. How should I solve this problem?
Is it a bad practice? If so, what is the best practice?

Marten Deinum
Mar 28th, 2008, 10:37 AM
When posting code please use [ code][/code ] tags.

Your object is Serializable but that doesn't mean that all the objects it references are Serializable! Next to that Hibernate does quite some modification on your object. And that is probably where it goes wrong.

ivan2007
Mar 28th, 2008, 10:51 AM
Thanks for your tip.



Your object is Serializable but that doesn't mean that all the objects it references are Serializable!


All my references are Serializable.
It looks something like this:



/**
* @hibernate.joined-subclass table="echtgenoot"
* @hibernate.joined-subclass-key column="person_id"
*/
public class Echtgenoot extends Person {

private boolean zelfinkomen;
private String beroep;
private boolean vermLB;

// Other booleans
// Getters and setters
}
/**
* @hibernate.class table="person"
*/
public class Person extends Base {

private String id;
private String name;
private String lastname;
private String address;
private String phone;
private String workphone;
private char gender = 'M';
private String endDate;
private String beginDate;
private Set<Authority> privileges;

// Getters and setters

}

public class Base implements Serializable {

@Override
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}
/**
* @hibernate.class table="authority"
*/
public class Authority extends Base {

private Long id;
private String name;
// Getters and setters
}




Next to that Hibernate does quite some modification on your object. And that is probably where it goes wrong.


If this is the case, how do I solve this problem??
I really would like to know how others are doing this.

Keith Donald
Mar 28th, 2008, 03:55 PM
Can you post this on the Hibernate forums and maybe JIRA and see if you get any useful info?

Keith

iwtolall
Jun 25th, 2008, 06:27 AM
I'm faced with exactly the same issue.

Any updates?

- Peter

ivan2007
Jun 25th, 2008, 10:04 AM
I posted this on the Hibernate forum but no replies.
I've patched the hibernate3.jar by making the org.hibernate.util.MarkerObject Serializable. Maybe you could try that in the mean time.

iwtolall
Jul 15th, 2008, 07:14 AM
I was faced again with this problem but this time it looks like due to serializing the persistence-context (I'm using the <persistence-context> for lazy loading).


Caused by: java.io.NotSerializableException: org.hibernate.util.MarkerObject
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at org.hibernate.engine.StatefulPersistenceContext.se rialize(StatefulPersistenceContext.java:1219)


I have now also patched the hibernate3.jar but long term this is not really a solution. Checking http://opensource.atlassian.com/projects/hibernate/browse/HHH-3239 I have realized that it does not yet have an assignee :(

- Peter

ivan2007
Jul 15th, 2008, 11:07 AM
The error message clearly states that the org.hibernate.util.MarkerObject class does not implement java.io.Serializable interface. Please make sure that your patch is in the classpath and not the original version.

iwtolall
Jul 15th, 2008, 03:46 PM
The error message clearly states that the org.hibernate.util.MarkerObject class does not implement java.io.Serializable interface.

With the patched hibernate3.jar it's working fine but long term I would like to have it solved without modifying the sources. I hope Hibernate will just make it serializable.

- Peter

Keith Donald
Jul 15th, 2008, 04:29 PM
Perhaps the EclipseLink team would be more responsive

Keith

rydl
Jul 23rd, 2008, 05:31 AM
I've got the same problem but I'm using Seam instead of SWF.
Where can I download the patched version? It should be quite easy to solve this, isn't it?
What's the role of the eclipse link team here?

iwtolall
Jul 23rd, 2008, 07:02 AM
Where can I download the patched version? It should be quite easy to solve this, isn't it?

Just download the hibernate sources and modify the related class (add implements serializable).



What's the role of the eclipse link team here?


It's just a different persistence provider which probably would react faster than the Hibernate team.

I really like the Criteria API from Hibernate :/

- Peter

rydl
Jul 24th, 2008, 05:27 AM
ok thanks, then i'll rather try to make a work around here

iwtolall
Jul 24th, 2008, 05:30 AM
ok thanks, then i'll rather try to make a work around here

Let me know if you have found one!

- Peter

vossgeraldo
Sep 25th, 2008, 12:15 PM
Hi,

Can you send me your hibernate jar file , please. I've tried to create one but it is not working for me.

thanks