users@glassfish.java.net

Re: Glassfish + JPA + Maven +EJB

From: unludo <unludo_at_gmail.com>
Date: Sun, 1 Nov 2009 11:15:58 -0800 (PST)

Hi,
Your problem is most likely at database transaction level.
When you use a session bean, you use a default transaction provided by the
container.
Now if one of your function calls another function in your session bean
which needs another level of transaction (required, requiresNew, etc.), then
you have to do a new lookup on the bean to enable this. It recreates the
correct context for the other transaction.
Hope this helps.
Ludovic



glassfish-2 wrote:
>
> Hi,
> I'm trying to develop an application in JEE using maven and Glassfish, but
> I have a problem that I can't solve by myself.
> I'm doing an appclient make a request for a Stateless Session Bean, well
> I'm getting the answer at first request, but if I try to do a second
> request I got an Exception saying my EntityManager is closed, but I'm not
> closing it in my hard code. After if I try to do a third request I get a
> right answer, if I try fourth the exception appear again, and so on. What
> I mean I'm getting correct answer on odd request but on even request I'm
> getting that exception.
> This is the Exception I'm getting:
>
> 14/05/2009 07:56:55 com.sun.enterprise.appclient.MainWithModuleSupport
> <init>
> WARNING: ACC003: Application threw an exception.
> javax.ejb.EJBException: nested exception is: java.rmi.ServerException:
> RemoteException occurred in server thread; nested exception is:
> java.rmi.RemoteException: null; nested exception is:
> java.lang.IllegalStateException: Attempting to execute an
> operation on a closed EntityManager.
> java.rmi.ServerException: RemoteException occurred in server thread;
> nested exception is:
> java.rmi.RemoteException: null; nested exception is:
> java.lang.IllegalStateException: Attempting to execute an
> operation on a closed EntityManager.
> at
> com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:243)
> at
> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
> at
> com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
> at
> com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
> at
> br.ufg.inf.lbs.sdl.__LocationServiceRemote_Remote_DynamicStub.getLocation(br/ufg/inf/lbs/sdl/__LocationServiceRemote_Remote_DynamicStub.java)
> at
> br.ufg.inf.lbs.sdl._LocationServiceRemote_Wrapper.getLocation(br/ufg/inf/lbs/sdl/_LocationServiceRemote_Wrapper.java)
> at br.ufg.inf.lbs.sdl.App.main(App.java:28)
> 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:597)
> at
> com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
> at com.sun.enterprise.appclient.Main.main(Main.java:200)
> Caused by: java.rmi.RemoteException: null; nested exception is:
> java.lang.IllegalStateException: Attempting to execute an
> operation on a closed EntityManager.
> at
> com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:251)
> at
> com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1411)
> at
> com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
> at
> com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
> at
> com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:77)
> at $Proxy41.getLocation(Unknown Source)
> 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:597)
> at
> com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
> at
> com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
> at
> com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
> at
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
> at
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
> at
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
> at
> com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
> at
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
> at
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
> at
> com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
> at
> com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
> Caused by: java.lang.IllegalStateException: Attempting to execute an
> operation on a closed EntityManager.
> at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.verifyOpen(EntityManagerImpl.java:1210)
> at
> org.eclipse.persistence.internal.jpa.EJBQueryImpl.setMaxResults(EJBQueryImpl.java:833)
> at
> br.ufg.inf.lbs.sdl.LocationServiceBean.getLocation(LocationServiceBean.java:61)
> 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:597)
> at
> com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
> at
> com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
> at
> com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)
> at
> com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)
> at
> com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
> ... 17 more
> javax.ejb.EJBException: nested exception is: java.rmi.ServerException:
> RemoteException occurred in server thread; nested exception is:
> java.rmi.RemoteException: null; nested exception is:
> java.lang.IllegalStateException: Attempting to execute an
> operation on a closed EntityManager.
> at
> br.ufg.inf.lbs.sdl._LocationServiceRemote_Wrapper.getLocation(br/ufg/inf/lbs/sdl/_LocationServiceRemote_Wrapper.java)
> at br.ufg.inf.lbs.sdl.App.main(App.java:28)
> 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:597)
> at
> com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
> at com.sun.enterprise.appclient.Main.main(Main.java:200)
> Exception in thread "main" java.lang.RuntimeException:
> java.lang.reflect.InvocationTargetException
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:461)
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
> at com.sun.enterprise.appclient.Main.main(Main.java:200)
> Caused by: java.lang.reflect.InvocationTargetException
> 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:597)
> at
> com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
> at
> com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
> ... 2 more
> Caused by: javax.ejb.EJBException: nested exception is:
> java.rmi.ServerException: RemoteException occurred in server thread;
> nested exception is:
> java.rmi.RemoteException: null; nested exception is:
> java.lang.IllegalStateException: Attempting to execute an
> operation on a closed EntityManager.
> at
> br.ufg.inf.lbs.sdl._LocationServiceRemote_Wrapper.getLocation(br/ufg/inf/lbs/sdl/_LocationServiceRemote_Wrapper.java)
> at br.ufg.inf.lbs.sdl.App.main(App.java:28)
> ... 8 more
>
>
> I'm not sure what is the problem, I've already tried many things but I
> don't know what to do more.
> If someone has any experience with that kind of problem please help me I
> would be extremely glad.
>
> Thanks
> [Message sent by forum member 'maximusjc' (maximusjc)]
>
> http://forums.java.net/jive/thread.jspa?messageID=346242
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>

-- 
View this message in context: http://old.nabble.com/Glassfish-%2B-JPA-%2B-Maven-%2BEJB-tp23538615p26152291.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.