Note that there are some explanatory texts on larger screens.

plurals
  1. POLazyInitializationException with session scoped bean
    primarykey
    data
    text
    <p>I'm getting LazyInitializationException with session scoped bean in my service layer. If I load the same bean using a regular dao in my method, I can access it's lazy collections without problems. But if I inject it in my service bean, and then try to access one of its lazy collection, I have a LazyInitializationException. </p> <p>I'm using JPA + Hibernate + Spring + struts. I have configured OpenEntityManagerInViewFilter. Futhermore, I can clearly see in the logs that the transaction and the session are opened.</p> <p>Is there something special that I have to do in the configuration for session-scoped bean with lazy collections?</p> <p>Here are the logs:</p> <pre><code> org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:lookupEntityManagerFactory:146 - Using EntityManagerFactory 'entityManagerFactory' for OpenEntityManagerInViewFilter org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter:doFilterInternal:101 - Opening JPA EntityManager in OpenEntityManagerInViewFilter org.springframework.orm.jpa.JpaTransactionManager:doGetTransaction:285 - Found thread-bound EntityManager [org.hibernate.ejb.EntityManagerImpl@17ab5c0] for JPA transaction org.springframework.transaction.support.AbstractPlatformTransactionManager:getTransaction:371 - Creating new transaction with name [com.xx.action.spring.service.SearchService.loadCurrencyCode]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly org.hibernate.impl.SessionImpl:&lt;init&gt;:247 - opened session at timestamp: 5093202578464768 org.hibernate.transaction.JDBCTransaction:begin:82 - begin org.hibernate.jdbc.ConnectionManager:openConnection:444 - opening JDBC connection org.hibernate.transaction.JDBCTransaction:begin:87 - current autocommit status: true org.hibernate.transaction.JDBCTransaction:begin:90 - disabling autocommit org.springframework.orm.jpa.JpaTransactionManager:doBegin:348 - Exposing JPA transaction as JDBC transaction [SimpleConnectionHandle: com.mchange.v2.c3p0.impl.NewProxyConnection@9b537f] org.hibernate.LazyInitializationException:&lt;init&gt;:42 - could not initialize proxy - no Session org.hibernate.LazyInitializationException: could not initialize proxy - no Session at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:86) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:190) at com.xxx.api.jpa.bean.CurrencyBean_$$_javassist_29.getHtmlSymbol(CurrencyBean_$$_javassist_29.java) </code></pre> <p>Here are the configuration of the bean:</p> <pre><code>&lt;bean id="currentUserBean" class="com.xxx.action.spring.CurrentUserBean" scope="session"&gt; &lt;aop:scoped-proxy /&gt; &lt;/bean&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload