Hi Rafael,

Thanks for your answer.

AppFuse (at least version 2.0) does use a OpenSessionInViewFilter
ServletFilter, as far as I'm aware.
Things are working just fine when the JSF Bean in question is executed in
Jetty's container - its just when its executed as a test, that there are
problems!

Alex


rafanami wrote:
> 
> This is mainly because appfuse is based on a ContextLoaderListener, that
> didn't initialize POJO data. For a solution, you have to either implement
> an
> OpenSessionInViewFilter (just a ServletFilter to initialize all your
> hibernate data) or keep using the ContextLoaderListener, but initializing
> the lazy data on your DAO layer with Hibernate.initialize(<your bean>);
> 
> Best Regards
> 
> Rafael Nami
> 
> 2007/4/24, hetjongetje <[EMAIL PROTECTED]>:
>>
>>
>> Hi, I'm encountering a LazyInitializationException in my web tests. This
>> error is encountered when trying to get aggregated collections within an
>> FormAction class:
>>
>> For example, I have a an ArrayList field named fields in a POJO named
>> Screen:
>> assertNotNull(bean.getScreen().getFields()) passes
>> but trying to iterate over the collection, or get an item (e.g.
>> bean.getScreen().getFields().get(0) - i get a
>> LazyInitializationException.
>>
>> Getting basic attributes (Strings, Integers, etc.) works just fine.
>>
>> I don't get the Exception when I execute the same code in its container
>> (which I think comes down to the work done by OpenSessionInViewFilter).
>> I'm
>> trying to work out if other people have had the same issue? Whether there
>> is
>> an easy way around this. I Googled the issue and came up with this old
>> Struts1 issue: http://issues.appfuse.org/browse/APF-58.
>>
>> I need to keep the session open for the lifecycle of the test: this looks
>> like it might help:
>>
>> http://www.thearcmind.com/confluence/display/RandomThoughts/Hibernate_Spring+OpenSessionInViewFilter+simulation+in+a+JUnit+test
>>
>> Any thoughts or ideas would be really helpful!
>> --
>> View this message in context:
>> http://www.nabble.com/LazyInitializationException-and-JSF-web-JUnit-tests-tf3641426s2369.html#a10169863
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/LazyInitializationException-and-JSF-web-JUnit-tests-tf3641426s2369.html#a10171219
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to