[flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output
Eric, I am also very interested in getting on a beta program too. I have sent you an email with contact details for me. Regards Simon --- In flexcoders@yahoogroups.com, "Eric D Anderson" <[EMAIL PROTECTED]> wrote: > > Hi PW, > > > > I'd suggest that we add you to the latest Data Services beta because > either we have fixed this issue, or we will fix this issue in the next > release. Can you contact me off-list and I'll add you to the beat so > you can test DS with the latest DS and hibernate assembler. > > > > Thanks > > > Eric > > > > Flex PM > > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of parkerwhirlow > Sent: Friday, February 16, 2007 7:06 PM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Re: FDS/Hibernate - LazyInitializationException > when writing AMF output > > > > This is happening from FDS... flex.data.assemblers.HibernateAssembler > uses a function called fetchObjectProperties() that's supposed to load > them all while the session is open right? > > I've seen in other posts that FDS eager fetches the properties in the > Assembler, so that they are available during serialization... > > am I missing something here? > > thanks, > PW > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > , Dima Gutzeit wrote: > > > > Hi, > > > > You have to initialize the collections before AMF serializes them. The > > > problem occurs since you closing Hibernate session without first > > initializing the arrays, and since you are using lazy initialization > the > > problem arise. > > > > You have two options : > > > > 1. Use lazy=false > > 2. Better one, is calling > /Hibernate.initialize(your_array_reference);/ > > before you close the Hibernate session. > > > > Regards, > > Dima Gutzeit. > > > > parkerwhirlow wrote: > > > > > > Hi again =) > > > > > > I've just started getting this exception inconsistently... sometimes > > > it happens 3 times in a row, other times I can go all afternoon > > > without getting it. Once the exception occurs, it will occur every > > > time the client loads until FDS is restarted. > > > > > > Note this occurs on multiple collections. I tried setting the > > > "offending" collection to lazy=false (in Hibernate), and the > exception > > > occurred on a different collection. I can't set every one of my > > > collections to lazy=false. Especially since at this point, they HAVE > > > to be lazy for the updateItem via hierarchical values to almost > work. > > > > > > I also noticed that the collection does not necessarily need to have > > > any items in it. (And possibly is caused specifically by NOT having > > > any items in it, I can't tell for sure). The collection referenced > in > > > the exception below has no values, and there's another collection in > > > that same class with values that doesn't seem to cause the > exception. > > > > > > See below the hibernate mapping, and exception output when this > > > occurs. (Note there are no FDS managed associations for this > collection) > > > > > > Thanks for any insight you have as to what is causing this. > > > > > > PW > > > _ > > > > > > > > > > > > > > > > > > > > inverse="false" > > > cascade="all-delete-orphan" > > > > > > > > > > > > > > > > > > > ... > > > > > > > > > 10:19:42,093 WARN ProxyWarnLog - Narrowing proxy to class > > > config.test.Adult - this operation breaks == > > > 10:19:44,687 ERROR LazyInitializationException - failed to lazily > > > initialize a collection of role: config.test.Adult.children, no > > > session or session was closed > > > org.hibernate.LazyInitializationException: failed to lazily > initialize > > > a collection of role: config.test.Adult.children, no session or > > > session was closed > > > at > > > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ > ationException(AbstractPersistentCollection.java:358) > > > at > > > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ > ationExceptionIfNotConnected(
RE: [flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output
Hi PW, I'd suggest that we add you to the latest Data Services beta because either we have fixed this issue, or we will fix this issue in the next release. Can you contact me off-list and I'll add you to the beat so you can test DS with the latest DS and hibernate assembler. Thanks Eric Flex PM From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of parkerwhirlow Sent: Friday, February 16, 2007 7:06 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output This is happening from FDS... flex.data.assemblers.HibernateAssembler uses a function called fetchObjectProperties() that's supposed to load them all while the session is open right? I've seen in other posts that FDS eager fetches the properties in the Assembler, so that they are available during serialization... am I missing something here? thanks, PW --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , Dima Gutzeit <[EMAIL PROTECTED]> wrote: > > Hi, > > You have to initialize the collections before AMF serializes them. The > problem occurs since you closing Hibernate session without first > initializing the arrays, and since you are using lazy initialization the > problem arise. > > You have two options : > > 1. Use lazy=false > 2. Better one, is calling /Hibernate.initialize(your_array_reference);/ > before you close the Hibernate session. > > Regards, > Dima Gutzeit. > > parkerwhirlow wrote: > > > > Hi again =) > > > > I've just started getting this exception inconsistently... sometimes > > it happens 3 times in a row, other times I can go all afternoon > > without getting it. Once the exception occurs, it will occur every > > time the client loads until FDS is restarted. > > > > Note this occurs on multiple collections. I tried setting the > > "offending" collection to lazy=false (in Hibernate), and the exception > > occurred on a different collection. I can't set every one of my > > collections to lazy=false. Especially since at this point, they HAVE > > to be lazy for the updateItem via hierarchical values to almost work. > > > > I also noticed that the collection does not necessarily need to have > > any items in it. (And possibly is caused specifically by NOT having > > any items in it, I can't tell for sure). The collection referenced in > > the exception below has no values, and there's another collection in > > that same class with values that doesn't seem to cause the exception. > > > > See below the hibernate mapping, and exception output when this > > occurs. (Note there are no FDS managed associations for this collection) > > > > Thanks for any insight you have as to what is causing this. > > > > PW > > _ > > > > > > > > > > > > > inverse="false" > > cascade="all-delete-orphan" > > > > > > > > > > > > > ... > > > > > > 10:19:42,093 WARN ProxyWarnLog - Narrowing proxy to class > > config.test.Adult - this operation breaks == > > 10:19:44,687 ERROR LazyInitializationException - failed to lazily > > initialize a collection of role: config.test.Adult.children, no > > session or session was closed > > org.hibernate.LazyInitializationException: failed to lazily initialize > > a collection of role: config.test.Adult.children, no session or > > session was closed > > at > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ ationException(AbstractPersistentCollection.java:358) > > at > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializ ationExceptionIfNotConnected(AbstractPersistentCollection.j > > ava:350) > > at > > org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractP ersistentCollection.java:97) > > at > > org.hibernate.collection.PersistentSet.size(PersistentSet.java:139) > > at java.util.ArrayList.(ArrayList.java:133) > > at > > flex.messaging.io.ArrayCollection.(ArrayCollection.java:44) > > at > > flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:40 7) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:147) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:215 ) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:495) > > at > > flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:46
RE: [flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output
The HibernateAssembler uses the "fetchObjectProperties" method to walk down the object graph of data that will be serialized to the client. It calls this while the session is open so that it can be sure to fetch everything that will be serialized. There must be a bug in this method which is preventing it from fetching all of the state in one of your objects.It stops if it is a lazy="true" association property. For non-association properties, it goes recursively down the property tree (keeping track of objects it has visited to avoid cycles). The algorithm is trying to mimic the path taken by our serialization code but when the session is open but without the memory overhead of serializing the data. I thought the code was handling the types of collections and stuff that hibernate can handle but maybe I'm missing something? I'll look at the serialization code to try and figure out what is different. In the meantime, your domain model has some state which is just not being fetched. You can override the HibernateAssember's fetchObjectProperties method (you'll unfortunately need to copy the source and change the package name since this is currently private) to "touch" the objects needed (just call the getX method or whatever). In this case it is trying to fetch an object of type: "config.test.Adult.children" but that is not telling us which path it is taking to hit that type unfortunately. If you can figure out the path, just put the calls e.g. getChildren into your fetchObjectProperties method. Jeff From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Carlos Rovira Sent: Sunday, February 18, 2007 3:19 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output I found that error when some complex object graph return to FDS and FDS can't deal with that complex object, so throws that huge error stack. I solve it returning a more simple object or String. Hope that helps... On 2/17/07, parkerwhirlow <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: This is happening from FDS... flex.data.assemblers.HibernateAssembler uses a function called fetchObjectProperties() that's supposed to load them all while the session is open right? I've seen in other posts that FDS eager fetches the properties in the Assembler, so that they are available during serialization... am I missing something here? thanks, PW --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , Dima Gutzeit <[EMAIL PROTECTED]> wrote: > > Hi, > > You have to initialize the collections before AMF serializes them. The > problem occurs since you closing Hibernate session without first > initializing the arrays, and since you are using lazy initialization the > problem arise. > > You have two options : > > 1. Use lazy=false > 2. Better one, is calling /Hibernate.initialize(your_array_reference);/ > before you close the Hibernate session. > > Regards, > Dima Gutzeit. > > parkerwhirlow wrote: > > > > Hi again =) > > > > I've just started getting this exception inconsistently... sometimes > > it happens 3 times in a row, other times I can go all afternoon > > without getting it. Once the exception occurs, it will occur every > > time the client loads until FDS is restarted. > > > > Note this occurs on multiple collections. I tried setting the > > "offending" collection to lazy=false (in Hibernate), and the exception > > occurred on a different collection. I can't set every one of my > > collections to lazy=false. Especially since at this point, they HAVE > > to be lazy for the updateItem via hierarchical values to almost work. > > > > I also noticed that the collection does not necessarily need to have > > any items in it. (And possibly is caused specifically by NOT having > > any items in it, I can't tell for sure). The collection referenced in > > the exception below has no values, and there's another collection in > > that same class with values that doesn't seem to cause the exception. > > > > See below the hibernate mapping, and exception output when this > > occurs. (Note there are no FDS managed associations for this collection) > > > > Thanks for any insight you have as to what is causing this. > > > > PW > > _ > > > > > > > > > > > > > inverse="false" > > cascade="all-delete-orphan" > > > > > > > > > > > > > ... > >
Re: [flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output
I found that error when some complex object graph return to FDS and FDS can't deal with that complex object, so throws that huge error stack. I solve it returning a more simple object or String. Hope that helps... On 2/17/07, parkerwhirlow <[EMAIL PROTECTED]> wrote: This is happening from FDS... flex.data.assemblers.HibernateAssembler uses a function called fetchObjectProperties() that's supposed to load them all while the session is open right? I've seen in other posts that FDS eager fetches the properties in the Assembler, so that they are available during serialization... am I missing something here? thanks, PW --- In flexcoders@yahoogroups.com , Dima Gutzeit <[EMAIL PROTECTED]> wrote: > > Hi, > > You have to initialize the collections before AMF serializes them. The > problem occurs since you closing Hibernate session without first > initializing the arrays, and since you are using lazy initialization the > problem arise. > > You have two options : > > 1. Use lazy=false > 2. Better one, is calling /Hibernate.initialize(your_array_reference);/ > before you close the Hibernate session. > > Regards, > Dima Gutzeit. > > parkerwhirlow wrote: > > > > Hi again =) > > > > I've just started getting this exception inconsistently... sometimes > > it happens 3 times in a row, other times I can go all afternoon > > without getting it. Once the exception occurs, it will occur every > > time the client loads until FDS is restarted. > > > > Note this occurs on multiple collections. I tried setting the > > "offending" collection to lazy=false (in Hibernate), and the exception > > occurred on a different collection. I can't set every one of my > > collections to lazy=false. Especially since at this point, they HAVE > > to be lazy for the updateItem via hierarchical values to almost work. > > > > I also noticed that the collection does not necessarily need to have > > any items in it. (And possibly is caused specifically by NOT having > > any items in it, I can't tell for sure). The collection referenced in > > the exception below has no values, and there's another collection in > > that same class with values that doesn't seem to cause the exception. > > > > See below the hibernate mapping, and exception output when this > > occurs. (Note there are no FDS managed associations for this collection) > > > > Thanks for any insight you have as to what is causing this. > > > > PW > > _ > > > > > > > > > > > > > inverse="false" > > cascade="all-delete-orphan" > > > > > > > > > > > > > ... > > > > > > 10:19:42,093 WARN ProxyWarnLog - Narrowing proxy to class > > config.test.Adult - this operation breaks == > > 10:19:44,687 ERROR LazyInitializationException - failed to lazily > > initialize a collection of role: config.test.Adult.children, no > > session or session was closed > > org.hibernate.LazyInitializationException: failed to lazily initialize > > a collection of role: config.test.Adult.children, no session or > > session was closed > > at > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException (AbstractPersistentCollection.java:358) > > at > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected (AbstractPersistentCollection.j > > ava:350) > > at > > org.hibernate.collection.AbstractPersistentCollection.readSize( AbstractPersistentCollection.java:97) > > at > > org.hibernate.collection.PersistentSet.size(PersistentSet.java:139) > > at java.util.ArrayList.(ArrayList.java:133) > > at > > flex.messaging.io.ArrayCollection.(ArrayCollection.java:44) > > at > > flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:407) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:147) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:215) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:495) > > at > > flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:467) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:165) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectArray(Amf3Output.java:730) > > at > > flex.messaging.io.amf.Amf3Output.writeAMFArray(Amf3Output.java:386) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:151) > > at > > flex.messaging.io.ArrayCollection.writeExternal(ArrayCollection.java:97) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:485) > > at > > flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:414) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:147) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:215) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:495) > > at > > flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:467) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3
[flexcoders] Re: FDS/Hibernate - LazyInitializationException when writing AMF output
This is happening from FDS... flex.data.assemblers.HibernateAssembler uses a function called fetchObjectProperties() that's supposed to load them all while the session is open right? I've seen in other posts that FDS eager fetches the properties in the Assembler, so that they are available during serialization... am I missing something here? thanks, PW --- In flexcoders@yahoogroups.com, Dima Gutzeit <[EMAIL PROTECTED]> wrote: > > Hi, > > You have to initialize the collections before AMF serializes them. The > problem occurs since you closing Hibernate session without first > initializing the arrays, and since you are using lazy initialization the > problem arise. > > You have two options : > > 1. Use lazy=false > 2. Better one, is calling /Hibernate.initialize(your_array_reference);/ > before you close the Hibernate session. > > Regards, > Dima Gutzeit. > > parkerwhirlow wrote: > > > > Hi again =) > > > > I've just started getting this exception inconsistently... sometimes > > it happens 3 times in a row, other times I can go all afternoon > > without getting it. Once the exception occurs, it will occur every > > time the client loads until FDS is restarted. > > > > Note this occurs on multiple collections. I tried setting the > > "offending" collection to lazy=false (in Hibernate), and the exception > > occurred on a different collection. I can't set every one of my > > collections to lazy=false. Especially since at this point, they HAVE > > to be lazy for the updateItem via hierarchical values to almost work. > > > > I also noticed that the collection does not necessarily need to have > > any items in it. (And possibly is caused specifically by NOT having > > any items in it, I can't tell for sure). The collection referenced in > > the exception below has no values, and there's another collection in > > that same class with values that doesn't seem to cause the exception. > > > > See below the hibernate mapping, and exception output when this > > occurs. (Note there are no FDS managed associations for this collection) > > > > Thanks for any insight you have as to what is causing this. > > > > PW > > _ > > > > > > > > > > > > > inverse="false" > > cascade="all-delete-orphan" > > > > > > > > > > > > > ... > > > > > > 10:19:42,093 WARN ProxyWarnLog - Narrowing proxy to class > > config.test.Adult - this operation breaks == > > 10:19:44,687 ERROR LazyInitializationException - failed to lazily > > initialize a collection of role: config.test.Adult.children, no > > session or session was closed > > org.hibernate.LazyInitializationException: failed to lazily initialize > > a collection of role: config.test.Adult.children, no session or > > session was closed > > at > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358) > > at > > org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.j > > ava:350) > > at > > org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97) > > at > > org.hibernate.collection.PersistentSet.size(PersistentSet.java:139) > > at java.util.ArrayList.(ArrayList.java:133) > > at > > flex.messaging.io.ArrayCollection.(ArrayCollection.java:44) > > at > > flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:407) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:147) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:215) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:495) > > at > > flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:467) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:165) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectArray(Amf3Output.java:730) > > at > > flex.messaging.io.amf.Amf3Output.writeAMFArray(Amf3Output.java:386) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:151) > > at > > flex.messaging.io.ArrayCollection.writeExternal(ArrayCollection.java:97) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:485) > > at > > flex.messaging.io.amf.Amf3Output.writeArrayCollection(Amf3Output.java:414) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:147) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectProperty(Amf3Output.java:215) > > at > > flex.messaging.io.amf.Amf3Output.writePropertyProxy(Amf3Output.java:495) > > at > > flex.messaging.io.amf.Amf3Output.writeCustomObject(Amf3Output.java:467) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:165) > > at > > flex.messaging.io.amf.Amf3Output.writeObjectArray(Amf3Output.java:730) > > at > > flex.messaging.io.amf.Amf3Output.writeAMFArray(Amf3Output.java:386) > > at > > flex.messaging.io.amf.Amf3Output.writeObject(Amf3Output.java:151) > > at > > flex