Hi!
I have problem and I didn't found any solution after few days of searching
When I'm trying to any lazy initialized collection or object I've got sth
like that:
-----------cut----------------------
ERROR - LazyInitializationException.<init>(19) | could not initialize proxy
- the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the
owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(
AbstractLazyInitializer.java:60)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(
AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(
CGLIBLazyInitializer.java:172)
at org.saweko.om.security.model.Role$$EnhancerByCGLIB$$50c1ce29.fillDTO
(<generated>)
at org.saweko.om.security.model.User.fillDTO(User.java:195)
...
-----------cut----------------------
I'm using Spring 2.05 with XFire 1.6 and Hibernate 3.2.0
I'm using JSR181 anotations to expose my SecurityService(interface) and
SecurityServiceImpl(Implementation class) as XFire WS
My application structure:
[Permissions]----(Set)many-to-one----[User]---(Set)many-to-one---[Role]
<Persistent>, collections are bi-directional
next I've DAO's objects that operates on POJO's, mostly CRUD operations, one
persistent object type - one DAO to perform operations
DAO classes are used by one class named Security Controller that perform
more complicated operations
next Security Controller is wrapped using TransactionProxyFactoryBean for
proper handling transactions
and finally there is interface called SecurityService and implementing it
class SecurityServiceImpl that uses proxied SecurityController class for
exposing
it's operations as web service using JSR181
Operations performed on simple data types works perfectly, operations
working with collections of simple data types like Set<String> works good
too but
when I try access any of lazy initialized objects exception occurs
My applicationContext.xml:
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
<bean id="xfire.annotationServiceFactory"
class="org.codehaus.xfire.annotations.AnnotationServiceFactory">
<constructor-arg index="0">
<ref bean="xfire.commonsAnnotations" />
</constructor-arg>
<constructor-arg index="1">
<ref bean="xfire.transportManager" />
</constructor-arg>
<constructor-arg index="2">
<ref bean="xfire.aegisBindingProvider" />
</constructor-arg>
</bean>
<bean id="xfire.commonsAnnotations"
class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations"
/>
<bean id="LocalDB"
...connection 2 local postgresql db .../>
<bean id="HBSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
....hibernate session factory
</bean>
<bean id="userDAOtarget"
.../>
<bean id="roleDAOtarget"
.../>
<bean id="permissionDAOtarget"
.../>
<bean id="securityCtrlTarget"
class="org.saweko.om.security.ctrl.impl.SecurityController">
<property name="userDAO">
<ref bean="userDAOtarget" />
</property>
<property name="roleDAO">
<ref bean="roleDAOtarget" />
</property>
<property name="permissionDAO">
<ref bean="permissionDAOtarget" />
</property>
</bean>
<bean id="securityControllerProxy"
class="
org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="target">
<ref bean="securityCtrlTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<bean id="transactionManager"
class="
org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="HBSessionFactory" />
</property>
</bean>
<bean id="securityServiceBean"
class="org.saweko.om.service.impl.SecurityServiceImpl">
<property name="securityController">
<ref bean="securityControllerProxy" />
</property>
</bean>
<bean id="securityServiceXfire"
class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceBean">
<ref bean="securityServiceBean" />
</property>
<property name="serviceClass">
<value>
org.saweko.om.service.impl.SecurityServiceImpl
</value>
</property>
<property name="serviceFactory">
<ref bean="xfire.annotationServiceFactory" />
</property>
</bean>
<bean id="addressingHandler"
class="org.codehaus.xfire.addressing.AddressingInHandler" />
What is solution 2 problem?