I agree - I am doing the same here, but the first time I ran my app and
got a stack over flow error I was a little worried.
If bidirectional relationships need to be recreated on the persistent
side you can use a utility class to do that.
___________________________________________
Gavin Hogan
Programmer/Analyst
The State University of New York
State University Plaza
Albany, NY 12246
Phone 518-443-5481
fax 518-443-5809
e-mail [EMAIL PROTECTED]
-----Original Message-----
From: Bill Graham [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 17, 2007 2:25 PM
To: [email protected]
Subject: Re: [xfire-user] Hibernate+Spring+XFire could not
initialize proxy - the owning Session was closed
I use Hibernate to power a WS with Parent-Child relationships
and it works great. You do have to pay attention to how the loading is
done though, as with all Hibernate apps.
Using *.aegis.xml mappings (along side my *.hbm.xml files) with
a few 'ignore' settings helps keep circular Parent-Child references from
happening.
----- Original Message ----
From: Daniel King <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, May 17, 2007 6:28:45 AM
Subject: RE: [xfire-user] Hibernate+Spring+XFire could not
initialize proxy - the owning Session was closed
I use XFire 1.2.5 and Hibernate also. I have a few objects that
have parent/child relation. I'm using the Criteria API and *alias* to
load whatever objects I need. This way I don't receive a lazy
initialization exception.
Daniel King, R2D2, C3P0
Application Engineer
Web Team
Nemours
Office: (904) 288-5643
Fax: (904) 288-5758
*** Call me Daniel ***
NOTICE...This electronic transmission is intended only for the
person(s) named. It may contain information that is (i) proprietary to
the sender, and/or (ii) privileged, confidential and/or otherwise exempt
from disclosure under applicable State and Federal law, including, but
not limited to, privacy standards imposed pursuant to the federal Health
Insurance Portability and Accountability Act of 1996 (HIPAA). Receipt
by anyone other than the named recipient(s) is not a waiver of any
applicable privilege. If you received this confidential communication
in error, please notify the sender immediately by reply e-mail message
and permanently delete the original message from your system.
________________________________
From: Slawomir Krolik [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 17, 2007 3:42 AM
To: [email protected]
Subject: Re: [xfire-user] Hibernate+Spring+XFire could not
initialize proxy - the owning Session was closed
OpenSessionInView solved problem, I was searching for other
solution but didn't find it
Yes I use DTO Objects, but when I try to fill DTO object with
data from persisten classes I got lazy exception like in first email...
Maybe I'm trying to fill DTO in wrong place? I do this in class
that is exposed as Web Service implementation class
it looks like this:
<Persistent Objects>
<DAOS>
<CTRL>
<Transaction Proxy>
<Web Service Class> <- here I'm trying to fill DTO Objects
2007/5/17, Tomek Sztelak <[EMAIL PROTECTED] >:
IMHO returning Hibernate objects with webservice isn't a good
idea.
Such objects often have parent<->child relations which is hard
to send
using document style. Maybe you can introduce DTOs.
On 5/17/07, Bill Graham < [EMAIL PROTECTED]> wrote:
>
> This is probably caused by Hibernate lazy loading. The
Hibernate session was
> closed before the XFire servlet called methods on your beans
to marshall
> into XML. The fix is to use Spring's OpenSessionInViewFilter
around your
> XFire servlet.
>
>
> ----- Original Message ----
> From: Slawomir Krolik < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> >
> To: [email protected]
> Sent: Wednesday, May 16, 2007 5:30:57 PM
> Subject: [xfire-user] Hibernate+Spring+XFire could not
initialize proxy -
> the owning Session was closed
>
> 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(AbstractLazyIniti
alizer.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?
>
>
>
>
>
> ________________________________
> Yahoo! oneSearch: Finally, mobile search that gives answers,
not web links.
--
-----
When one of our products stops working, we'll blame another
vendor
within 24 hours.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
________________________________
Never miss an email again!
Yahoo! Toolbar
<http://us.rd.yahoo.com/evt=49938/*http://tools.search.yahoo.com/toolbar
/features/mail/> alerts you the instant new Mail arrives. Check it out.
<http://us.rd.yahoo.com/evt=49937/*http://tools.search.yahoo.com/toolbar
/features/mail/>