jQuery in Action, 2nd edition*
The moose likes EJB and other Java EE Technologies and the fly likes SessionBean method returning POJO == exception? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "SessionBean method returning POJO == exception?" Watch "SessionBean method returning POJO == exception?" New topic
Author

SessionBean method returning POJO == exception?

Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
Guys, I created a SessionBean that is returning a POJO. This POJO is not an entity bean, it's just a data container that I don't want to persist.

I created a client to obtain this bean via InitialContext, but when it is returning the POJO the following exception is encountered:



Both the server and client have the same POJO class. I understand that if this POJO were an entity bean, probably this problem will not happen. I do intend to turn the POJO into an entity bean, but still what if I just want to return a simple POJO that I don't want to persist?

NOTE: if I change the method to return a native java type like boolean or string, the invocation is working fine. So I'm sure it's caused by the way the POJO is being returned.

Any clue how I can get around this problem?
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Is your object serializable?


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
Thanks, implementing Serializable does the trick. Why is that so?
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Because Remote EJB uses RMI underneath, that's why your object needs to implement Serializable.
gaston lopez
Greenhorn

Joined: Nov 25, 2008
Posts: 9
Hi, I have the same (or similar) problem. I have a web application client that does a lookup to get an instance of a EJB. I get this perfect, but when I tried to call a method from this EJB wich return an object (It implements Serializable) I get the next error:

(Sorry by my english)

Exception
---------
javax.servlet.ServletException: javax.ejb.EJBException: nested exception is: java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe

Cause principal
---------------
javax.ejb.EJBException: nested exception is: java.rmi.MarshalException: CORBA MARSHAL 1398079745 Maybe; nested exception is: org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe


I have using Netbeans 6.5
Glassvish v2

And I have:
- A java library with the interface of Session Bean "Service" and the bussisnes objects that implements Serializable.
- An EJB Module, with the implementations of Session Bean "Service". It EJB Module includes the above java library. This implementations have the annotations @Remote.
- A web application (client). It includes the java library and it do a look up of Session Bean "Service" and call the methods of the "Service", if the method return a bussisnes object of the java library I get the above error.

Could you help me?. If anyone need more information please tell me, thank a lot.
Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
what kind of object are you trying to retrieve from this EJB?

Tell us more about the object you are trying to get from the first EJB that you have managed to retrieve.

My guess is that, this 2nd object you are trying to retrieve is still not fetched yet and you are trying to access it. Did you use JPA with lazy loading for this 2nd object?

Please provide more info if possible:
- classes involved
- your design (what is it you are trying to do)
- code of the invoking class
- exception stack

Give us the real deal, not just some vague description of your problem. With that we can only provide you with some vague answer too.
gaston lopez
Greenhorn

Joined: Nov 25, 2008
Posts: 9
I passed my first problema. Now have another. I'll try to explain with my pour English:

I have 3 proyects:

1-Java Library Proyects. It contain:
1.1 A busissnes class "Area" what implements Serializable with 3 attributes: id, description, areaFunction (type AreaFunction) and setters, getters and constructor.
1.2 A busissnes class "AreaFunction" what implements Serializable with 2 attributes: id and description and setters, getters and constructor.
1.3 An interface "ServiceArea" with a method "getAreaById(Long id)" that return an "Area". Thats all for this proyect.

2-EJB modules. It contains:
2.1 Include proyect 1.
2.2 An implementations of "ServiceArea" with @Remote and @Stateless ( mappedName="ServicieArea" ) annotation. This implementation get a method "getAreaById(Long id)" that return the "Area" Object
2.3 This proyect use Hibernate to get an area form database.

3- Web Application.
3.1 Include proyect 1.
3.2 It have an Action of Struts to do this:
InitialContext context = new InitialContext();
ServicieArea service = (ServicieArea) context.lookup("ServicieArea");
Area area = service.getAreaPorId(223L);


It didn't work because I did not include into web application JARs of hibernate, but now It works fine. My problema now is when I tried to get "areaFunction" attribute from "area".

My JSP recieve attribute "area" from action (thats ok). I tried to get from "area" the object "AreaFunction" and I get this error:

org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:50)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at ar.com.grupoesfera.laboratorio.ejb3.model.AreaFunction$$EnhancerByCGLIB$$63175243.getDescription(<generated>
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 org.apache.taglibs.standard.lang.jstl.ArraySuffix.evaluate(ArraySuffix.java:300)
at org.apache.taglibs.standard.lang.jstl.ComplexValue.evaluate(ComplexValue.java:129)
at org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:226)
at org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:185)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:123)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:151)
at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:97)
at org.apache.taglibs.standard.tag.el.core.ExpressionUtil.evalNotNull(ExpressionUtil.java:70)
at org.apache.taglibs.standard.tag.el.core.OutTag.evaluateExpressions(OutTag.java:121)
at org.apache.taglibs.standard.tag.el.core.OutTag.doStartTag(OutTag.java:79)
at org.apache.jsp.area_jsp._jspx_meth_c_out_2(area_jsp.java:222)
at org.apache.jsp.area_jsp._jspx_meth_html_html_0(area_jsp.java:124)
at org.apache.jsp.area_jsp._jspService(area_jsp.java:75)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1054)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:292)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:384)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:344)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:767)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:47)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
ApplicationDispatcher[/WebApp2] PWC1231: Servlet.service() para el servlet action desencaden� una excepci�n
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:50)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at ar.com.grupoesfera.laboratorio.ejb3.model.AreaFunction$$EnhancerByCGLIB$$63175243.getDescription(<generated>
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 org.apache.taglibs.standard.lang.jstl.ArraySuffix.evaluate(ArraySuffix.java:300)
at org.apache.taglibs.standard.lang.jstl.ComplexValue.evaluate(ComplexValue.java:129)
at org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:226)
at org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:185)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:123)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:151)
at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:97)
at org.apache.taglibs.standard.tag.el.core.ExpressionUtil.evalNotNull(ExpressionUtil.java:70)
at org.apache.taglibs.standard.tag.el.core.OutTag.evaluateExpressions(OutTag.java:121)
at org.apache.taglibs.standard.tag.el.core.OutTag.doStartTag(OutTag.java:79)
at org.apache.jsp.area_jsp._jspx_meth_c_out_2(area_jsp.java:222)
at org.apache.jsp.area_jsp._jspx_meth_html_html_0(area_jsp.java:124)
at org.apache.jsp.area_jsp._jspService(area_jsp.java:75)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1054)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:292)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:384)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:344)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:767)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:47)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
StandardWrapperValve[jsp]: PWC1406: Servlet.service() para el servlet jsp desencaden� una excepci�n
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:50)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at ar.com.grupoesfera.laboratorio.ejb3.model.AreaFunction$$EnhancerByCGLIB$$63175243.getDescription(<generated>
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 org.apache.taglibs.standard.lang.jstl.ArraySuffix.evaluate(ArraySuffix.java:300)
at org.apache.taglibs.standard.lang.jstl.ComplexValue.evaluate(ComplexValue.java:129)
at org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:226)
at org.apache.taglibs.standard.lang.jstl.ELEvaluator.evaluate(ELEvaluator.java:185)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:123)
at org.apache.taglibs.standard.lang.jstl.Evaluator.evaluate(Evaluator.java:151)
at org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager.evaluate(ExpressionEvaluatorManager.java:97)
at org.apache.taglibs.standard.tag.el.core.ExpressionUtil.evalNotNull(ExpressionUtil.java:70)
at org.apache.taglibs.standard.tag.el.core.OutTag.evaluateExpressions(OutTag.java:121)
at org.apache.taglibs.standard.tag.el.core.OutTag.doStartTag(OutTag.java:79)
at org.apache.jsp.area_jsp._jspx_meth_c_out_2(area_jsp.java:222)
at org.apache.jsp.area_jsp._jspx_meth_html_html_0(area_jsp.java:124)
at org.apache.jsp.area_jsp._jspService(area_jsp.java:75)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1054)
at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:292)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:384)
at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:344)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:446)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:542)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:474)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:366)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:767)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:47)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
[ November 26, 2008: Message edited by: gaston lopez ]
Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
Hey,

I'll try to be brief. your problem is caused by LAZY LOADING. Please do a google search on Lazy Loading on hibernate / JPA.

Pretty much, you need to either do:

OPTION A: EASY WAY OUT
---
1. in the session bean that returns "Area" (ServiceArea)
2. just before you return the Area object
3. call areaObject.getAreaFunction()

Step 3 will load the AreaFunction object. By the time the object is returned, the AreaFunction is also included (it is now initialised).


OPTION B: THE NORMAL WAY OUT
---
Have a read on LAZY LOADING on Hibernate and JPA. If you can turn off lazy loading between Area and AreaFunction, this will solve the problem too.
gaston lopez
Greenhorn

Joined: Nov 25, 2008
Posts: 9
Thanks Zenikko, but I know that. I'm looking for another option. My objetive is have "Services" distributites, like EJB for web application can consuming this ones. But If I have to set lazy=fase I'm losing.
Zenikko Sugiarto
Ranch Hand

Joined: Jan 09, 2005
Posts: 58
Gaston,

Yeah quite, but this is the implication of using OR mapping and distributed EJBs. OR mapping offers you the convenience, but if you don't partition your services correctly (meaning: to fit your functional and capacity need) you will have to embrace the performance overhead implication.

Example of the sort of partitioning you can do to introduce more flexibility could be like:

Data Model:
one product can belong to many categories. class available: Product, Category. The POJO implemented have a list of Category inside Product class.

Session bean partition:


Usage:


Same concept, just partitioning the service beans to do more atomic operation to allow you more control over what you want to fetch.

Of course, this is a very simplistic example, you can also overcome repetitious callback to remote session beans by implementing caching in the CLIENT end.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SessionBean method returning POJO == exception?