Re: [Resin-interest] Resin 4: hibernate objects in HTTP session causing org.hibernate.LazyInitializationException

2011-03-28 Thread Mattias Jiderhamn
By default Resin 4 uses Hessian for serialization of session data. 
Hessian tries to traverse uninitialized Hibernate associations by 
reflection, causing LazyInitializationException when serializing.
For that reason, we are using Java serialization instead of Hessian for 
session data.

Here is how to configure:

session-config
...
serialization-typejava/serialization-type
/session-config


/Mattias

Keith Fetterman wrote (2011-03-25 23:42):
 We have a custom Authenticator that extends resin's
 com.caucho.server.security.AbstractAuthenticator.  In our custom
 authenticator, I am storing a Hibernate object that contains a HashSet
 of other Hibernate objects in my HTTP session.  When I restart Resin
 (Resin 4.0.16), I am getting the following stack trace that is caused by
 a org.hibernate.LazyInitializationException when I access the first
 Web page after the server is started.

 It looks like resin is deserializing the Hibernate object from resin's
 session persistence and then trying to populate the Set of associated
 Hibernate objects, but the Set object that originally contained the
 associated Hibernate objects does not exist.  I am guessing that is the
 problem because I see the following cause:
 [11-03-25 14:56:04.683] {http://*:8082-1}
 com.caucho.hessian.io.HessianFieldException:
 com.marinersupply.common.authentication.ApplicationUser.roles:
 java.util.Set cannot be assigned from null
 I am using the java.util.HashSet to contain the associated Hibernate
 objects.  If this is the problem, why isn't resin also serializing the
 HashSet?

 Doesn't Resin's session serialization serialize objects associated with
 objects that are in the HTTP session?

 Does resin's session persistence mechanism invoke the methods on the
 objects stored in the session when it serializes or unserializes the
 objects from the session store?

 The reason that I ask this problem is that I get the following Exception:
 Caused by: org.hibernate.LazyInitializationException: failed to
 lazily initialize a collection, no session or session was closed
 Why is resin invoking Hibernate to perform a lazy load of associated
 objects on my hibernate object?  I've seen cause the error above when it
 tried to persist the hibernate object at the end of processing an HTTP
 request.  We use a servlet filter to close the Hibernate session.  It
 looks like the act of persisting the session is occurring after resin
 has returned from this filter because the Hibernate session was closed.
 My question again is why is resin invoking the methods on the object
 that in turn makes a request to hibernate to lazy load the associated
 objects?

 Is resin using Hibernate as a part of its default session persistence
 implementation?

 We didn't see any of these errors when we were running Resin 3.0.28.
 But, in Resin 3.0.28, we were using Resin's MySQL session persistence.
 In resin 4.0.16, we are using Resin's default session persistence store.

 I would appreciate any ideas on what might be going so I can track down
 the problem.

 Thanks,
 Keith
 [11-03-25 14:56:04.680] {http://*:8082-1}
 com.caucho.hessian.io.HessianFieldException:
 com.marinersupply.common.authentication.ApplicationUser.roles:
 java.util.Set cannot be assigned from null
at
 com.caucho.hessian.io.UnsafeDeserializer.logDeserializeError(UnsafeDeserializer.java:790)
at
 com.caucho.hessian.io.UnsafeDeserializer$ObjectFieldDeserializer.deserialize(UnsafeDeserializer.java:421)
at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:239)
at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:150)
at
 com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2212)
at
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1719)
at
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1703)
at
 com.caucho.hessian.io.UnsafeDeserializer$ObjectFieldDeserializer.deserialize(UnsafeDeserializer.java:417)
at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:239)
at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:150)
at
 com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2212)
at
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2133)
at
 

Re: [Resin-interest] Resin 4: hibernate objects in HTTP session causing org.hibernate.LazyInitializationException

2011-03-28 Thread Keith Fetterman
Hi Mattias,

Thanks for the help.  That did it.

It is unfortunate that Hessian serialization does this because a lot Web 
development is based on hibernate.  We'd have to create non-hibernate 
clones of our persistent objects for storing in the session.

Keith

On 03/28/2011 02:30 AM, Mattias Jiderhamn wrote:
 By default Resin 4 uses Hessian for serialization of session data. 
 Hessian tries to traverse uninitialized Hibernate associations by 
 reflection, causing LazyInitializationException when serializing.
 For that reason, we are using Java serialization instead of Hessian 
 for session data.

 Here is how to configure:

 session-config
 ...
 serialization-typejava/serialization-type
 /session-config


 /Mattias

 Keith Fetterman wrote (2011-03-25 23:42):
 We have a custom Authenticator that extends resin's
 com.caucho.server.security.AbstractAuthenticator.  In our custom
 authenticator, I am storing a Hibernate object that contains a HashSet
 of other Hibernate objects in my HTTP session.  When I restart Resin
 (Resin 4.0.16), I am getting the following stack trace that is caused by
 a org.hibernate.LazyInitializationException when I access the first
 Web page after the server is started.

 It looks like resin is deserializing the Hibernate object from resin's
 session persistence and then trying to populate the Set of associated
 Hibernate objects, but the Set object that originally contained the
 associated Hibernate objects does not exist.  I am guessing that is the
 problem because I see the following cause:
 [11-03-25 14:56:04.683] {http://*:8082-1}
 com.caucho.hessian.io.HessianFieldException:
 com.marinersupply.common.authentication.ApplicationUser.roles:
 java.util.Set cannot be assigned from null
 I am using the java.util.HashSet to contain the associated Hibernate
 objects.  If this is the problem, why isn't resin also serializing the
 HashSet?

 Doesn't Resin's session serialization serialize objects associated with
 objects that are in the HTTP session?

 Does resin's session persistence mechanism invoke the methods on the
 objects stored in the session when it serializes or unserializes the
 objects from the session store?

 The reason that I ask this problem is that I get the following 
 Exception:
 Caused by: org.hibernate.LazyInitializationException: failed to
 lazily initialize a collection, no session or session was closed
 Why is resin invoking Hibernate to perform a lazy load of associated
 objects on my hibernate object?  I've seen cause the error above when it
 tried to persist the hibernate object at the end of processing an HTTP
 request.  We use a servlet filter to close the Hibernate session.  It
 looks like the act of persisting the session is occurring after resin
 has returned from this filter because the Hibernate session was closed.
 My question again is why is resin invoking the methods on the object
 that in turn makes a request to hibernate to lazy load the associated
 objects?

 Is resin using Hibernate as a part of its default session persistence
 implementation?

 We didn't see any of these errors when we were running Resin 3.0.28.
 But, in Resin 3.0.28, we were using Resin's MySQL session persistence.
 In resin 4.0.16, we are using Resin's default session persistence store.

 I would appreciate any ideas on what might be going so I can track down
 the problem.

 Thanks,
 Keith
 [11-03-25 14:56:04.680] {http://*:8082-1}
 com.caucho.hessian.io.HessianFieldException:
 com.marinersupply.common.authentication.ApplicationUser.roles:
 java.util.Set cannot be assigned from null
at
 com.caucho.hessian.io.UnsafeDeserializer.logDeserializeError(UnsafeDeserializer.java:790)
  

at
 com.caucho.hessian.io.UnsafeDeserializer$ObjectFieldDeserializer.deserialize(UnsafeDeserializer.java:421)
  

at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:239)
  

at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:150)
  

at
 com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2212)
  

at
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1719)
at
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1703)
at
 com.caucho.hessian.io.UnsafeDeserializer$ObjectFieldDeserializer.deserialize(UnsafeDeserializer.java:417)
  

at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:239)
  

at
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:150)
  

  

[Resin-interest] Resin 4: hibernate objects in HTTP session causing org.hibernate.LazyInitializationException

2011-03-25 Thread Keith Fetterman
We have a custom Authenticator that extends resin's 
com.caucho.server.security.AbstractAuthenticator.  In our custom 
authenticator, I am storing a Hibernate object that contains a HashSet 
of other Hibernate objects in my HTTP session.  When I restart Resin 
(Resin 4.0.16), I am getting the following stack trace that is caused by 
a org.hibernate.LazyInitializationException when I access the first 
Web page after the server is started.

It looks like resin is deserializing the Hibernate object from resin's 
session persistence and then trying to populate the Set of associated 
Hibernate objects, but the Set object that originally contained the 
associated Hibernate objects does not exist.  I am guessing that is the 
problem because I see the following cause:
 [11-03-25 14:56:04.683] {http://*:8082-1} 
 com.caucho.hessian.io.HessianFieldException: 
 com.marinersupply.common.authentication.ApplicationUser.roles: 
 java.util.Set cannot be assigned from null
I am using the java.util.HashSet to contain the associated Hibernate 
objects.  If this is the problem, why isn't resin also serializing the 
HashSet?

Doesn't Resin's session serialization serialize objects associated with 
objects that are in the HTTP session?

Does resin's session persistence mechanism invoke the methods on the 
objects stored in the session when it serializes or unserializes the 
objects from the session store?

The reason that I ask this problem is that I get the following Exception:
Caused by: org.hibernate.LazyInitializationException: failed to 
 lazily initialize a collection, no session or session was closed

Why is resin invoking Hibernate to perform a lazy load of associated 
objects on my hibernate object?  I've seen cause the error above when it 
tried to persist the hibernate object at the end of processing an HTTP 
request.  We use a servlet filter to close the Hibernate session.  It 
looks like the act of persisting the session is occurring after resin 
has returned from this filter because the Hibernate session was closed.  
My question again is why is resin invoking the methods on the object 
that in turn makes a request to hibernate to lazy load the associated 
objects?

Is resin using Hibernate as a part of its default session persistence 
implementation?

We didn't see any of these errors when we were running Resin 3.0.28.  
But, in Resin 3.0.28, we were using Resin's MySQL session persistence.  
In resin 4.0.16, we are using Resin's default session persistence store.

I would appreciate any ideas on what might be going so I can track down 
the problem.

Thanks,
Keith
 [11-03-25 14:56:04.680] {http://*:8082-1} 
 com.caucho.hessian.io.HessianFieldException: 
 com.marinersupply.common.authentication.ApplicationUser.roles: 
 java.util.Set cannot be assigned from null
   at 
 com.caucho.hessian.io.UnsafeDeserializer.logDeserializeError(UnsafeDeserializer.java:790)
   at 
 com.caucho.hessian.io.UnsafeDeserializer$ObjectFieldDeserializer.deserialize(UnsafeDeserializer.java:421)
   at 
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:239)
   at 
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:150)
   at 
 com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2212)
   at 
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1719)
   at 
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1703)
   at 
 com.caucho.hessian.io.UnsafeDeserializer$ObjectFieldDeserializer.deserialize(UnsafeDeserializer.java:417)
   at 
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:239)
   at 
 com.caucho.hessian.io.UnsafeDeserializer.readObject(UnsafeDeserializer.java:150)
   at 
 com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2212)
   at 
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2133)
   at 
 com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:2117)
   at 
 com.caucho.server.session.HessianSessionDeserializer.readObject(HessianSessionDeserializer.java:79)
   at 
 com.caucho.server.session.SessionImpl.load(SessionImpl.java:686)
   at 
 com.caucho.server.session.SessionImpl.load(SessionImpl.java:642)
   at