[JBoss Seam] - webservice and JPA LazyInitializationException
by mwkohout
Following the instructions in the webservices chapter of the documentation, I've got a small webservice that I've integrated into Seam...It reaches into the context, then pulls out one of my jpa home/dao objects.
The only problem is that some of the relationships are lazy and I speculate responsible for a LazyInitializationException I'm seeing when the java objects are being marshalled into xml.
here's part of the stack trace:
| 13:33:16,685 ERROR [[StudyService]] Servlet.service() for servlet StudyService threw exception
| org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: edu.umn.ictr.core.model.Study.IRBStudyIDs, no session or session was closed
| at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
| at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
| at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
| at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
| at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
| at edu.umn.ictr.core.model.Study.getIRBStudies(Study.java:133)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.get(Accessor.java:266)
| at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:92)
| at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:286)
| at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:619)
| at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:29)
| at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:132)
| at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:101)
| at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:286)
| at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:619)
| at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:93)
| at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:127)
| at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:244)
| at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:251)
| at com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:33)
| at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:461)
| at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292)
| at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221)
| at org.jboss.ws.core.jaxws.JAXBSerializer.serialize(JAXBSerializer.java:83)
| at org.jboss.ws.core.jaxrpc.binding.SerializerSupport.serialize(SerializerSupport.java:61)
| at org.jboss.ws.core.soap.ObjectContent.marshallObjectContents(ObjectContent.java:159)
| at org.jboss.ws.core.soap.ObjectContent.transitionTo(ObjectContent.java:72)
| at org.jboss.ws.core.soap.SOAPContentElement.transitionTo(SOAPContentElement.java:140)
| at org.jboss.ws.core.soap.SOAPContentElement.writeElement(SOAPContentElement.java:536)
| at org.jboss.ws.core.soap.SOAPElementImpl.writeElementContent(SOAPElementImpl.java:834)
| at org.jboss.ws.core.soap.SOAPElementImpl.writeElement(SOAPElementImpl.java:819)
| at org.jboss.ws.core.soap.SOAPElementImpl.writeElementContent(SOAPElementImpl.java:834)
| at org.jboss.ws.core.soap.SOAPElementImpl.writeElement(SOAPElementImpl.java:819)
| at org.jboss.ws.core.soap.SOAPElementWriter.writeElementInternal(SOAPElementWriter.java:149)
| at org.jboss.ws.core.soap.SOAPElementWriter.writeElement(SOAPElementWriter.java:130)
| at org.jboss.ws.core.soap.SOAPMessageImpl.writeTo(SOAPMessageImpl.java:291)
| at org.jboss.ws.core.server.ServiceEndpointManager.sendResponse(ServiceEndpointManager.java:517)
| at org.jboss.ws.core.server.ServiceEndpointManager.processRequest(ServiceEndpointManager.java:481)
| at org.jboss.ws.core.server.AbstractServiceEndpointServlet.doPost(AbstractServiceEndpointServlet.java:114)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
| at org.jboss.ws.core.server.AbstractServiceEndpointServlet.service(AbstractServiceEndpointServlet.java:75)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
| at java.lang.Thread.run(Thread.java:595)
|
Is there any way I can force the Seam WebService Endpoint(or some other part of the mechanism) to force all those relationships to be populated thus avoiding my problem, or is making a set of web service dtos my only choice?
thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104310#4104310
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104310
18 years, 8 months
[JBoss Tools (users)] - Re: How to debug an old J2EE Project created with an older J
by max.andersen@jboss.com
"millenium" wrote : Thanx for your help, your way works. Also Hot Deployment (e.g. changes in a servlet) and Debugging is working now.
|
Good ;)
anonymous wrote :
| But how can I redeploy my application? If I change something in a jsp, there is no hot deployement. In earlier versions I packaged my Application again and made a redeploy on the application.
|
This should happen automatically now when eclipse sees the archive have been updated.
anonymous wrote :
| In the new version there is no redeploy-function. I have to stop the server, package and debug again. Is there an easier way?
|
Open the JBoss Server View or Servers view - there should be a module called whatever the file you deployed; here you can redeploy/clean etc.
anonymous wrote :
| You also wrote there would be a new incremental packaging available. How can I use this?
|
I wonder what you are actually using now since the old archiving is not included anymore ;)
Look for the Archive view - here you can define the packaging you want; as jar or as exploded and always in sync.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104306#4104306
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104306
18 years, 8 months
[JBoss Seam] - Re: Exception handling of PersistenceException
by dapeng
Hi, Pete,
I've got the following case. A method (no conversation) will be called to delete a row in the database. The backing bean method returns without error, because the flush is not occured at this time. Later the SeamPhaseListener commits the first tx, which flushes the persistence context. During the flush a ConstraintViolationException is thrown because of a foreign key constraint exception. But my application code has no chance to catch this exception, because the backing bean method has finished already.
The only possibility is to write a complex error handling, which is able to do something after the tx commit. I have 2 problems here.
1. Currently SpringTransaction swallows the cause exception, so that I can't find the ConstraintViolationException in the exception stack. I will switch to another trnasaction manager and sees whether it is cleaner.
2. The exception handling mechanism doesn't allow me to hook in user defined exception handler, so that I can check the exception stack, so some logic. I think the redirect, end-conversation and http error are not enoughj under all circumstances.
Like to know your opinion.
Dapeng
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104301#4104301
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104301
18 years, 8 months