Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not initialize proxy - No Session again

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

like image 632
Iapilgrim Avatar asked Mar 18 '10 12:03

Iapilgrim


1 Answers

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

like image 159
milbr Avatar answered Oct 06 '22 07:10

milbr