Could not initialize proxy - No Session again
Asked Answered
I

1

8

I get these error log when viewing a page

ERROR [TP-Processor11] (LazyInitializationException.java:42) - could not initialize proxy - no Session
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
    at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:132)
    at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:174)
    at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190)
    at org.osmoz.contents.model.enm.ContentType_$$_javassist_71.getDefaultShortMode(ContentType_$$_javassist_71.java)
    at org.osmoz.contents.web.tapestry.components.EnmContentZone.getTemplate(EnmContentZone.java:67)
    at org.osmoz.contents.web.tapestry.base.AbstractRawContentZone.getContent(AbstractRawContentZone.java:67)
    at $PropertyConduit_1276091af82.get($PropertyConduit_1276091af82.java)
    at org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:58)
    at org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:510)
    at org.apache.tapestry5.internal.structure.InternalComponentResourcesImpl$1.read(InternalComponentResourcesImpl.java:496)
    at org.apache.tapestry5.corelib.components.OutputRaw._$read_parameter_value(OutputRaw.java)
    at org.apache.tapestry5.corelib.components.OutputRaw.beginRender(OutputRaw.java:43)
    at org.apache.tapestry5.corelib.components.OutputRaw.beginRender(OutputRaw.java)
    at

I know the problem is Session has been closed. But I really don't know why this error occur not so often that why I don't know the root cause is.

Enviroment:

Tapestry5, JPA, Hibernate 3.3.2.GA

I've set

<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>

in web.xml also

Indistinct answered 18/3, 2010 at 12:17 Comment(4)
Did you see this - #346205Reichsmark
give all the relevant parts of web.xml, not only this line.Bilection
The case is so simple. We want to get a "lazy" field and display it in view. In this case we have object ContentType and field "defaultShortMode". Since we call lazy in view, we open another session by using OpenEntityManagerInViewFilter. The main problem is: This bug occurs sometimes. Sometime it runs smoothly. I guess other factors involved such as Tapestry thread?, using transaction? using Hibernate Level 2 Cache? It would help someone points out what could be wrong here. Thanks.Indistinct
Yes, I read it that why my title is No Session again. I know this issue comes from many reason. In your link, the reason is using transaction. I guess other factors involved such as Tapestry thread?, using transaction? using Hibernate Level 2 Cache? But I don't know how to change transaction at what level? tapestry or Spring ( I'm using Spring service). I'm still investigating and hope someone could help me. RegardsIndistinct
P
5

Use @Transactional on a method in layer annotated with @Service(Spring service).

Panier answered 19/3, 2011 at 21:21 Comment(2)
it's not @Transaction, it's @Transactional (org.springframework.transaction.annotation.Transactional)Howard
@Howard i am using org.springframework.transaction.annotation.Transactional but still getting an error. here is my question #27901365Gasbag

© 2022 - 2024 — McMap. All rights reserved.