users@glassfish.java.net

Re: From NetBeans bundle version to server

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 26 Aug 2008 14:04:31 -0700

Mauro,

Your code is correct (it's a different story that you can inject an
EntityManagerFactory and rely on the UserTransaction instead).

Can it be that your persistence.xml specifies JTA as the transaction-type? If
yes, the TopLink code is correct, and you can't use EntityTransaction (the one
that entityManager.getTransaction() returns) in such configuration.

Either remove the transaction-type (to default to) or change it to be
RESOURCE_LOCAL, and it should solve your problem.

HTH,
-marina

Mauro Chiarugi - Dogma Systems wrote:
> Hi,
>
> I'm desperate!! :-)
> I've post this message to nbj2ee_at_netbeans.org mailing list, but after
> some suggestions, they suggest to post here.
>
> I've develop a web application using Visual Web, Nebeans and Glassfish
> (in bunlde with NetBeans 6.1).
>
> I'm trying to deploy the web application to the production server that
> use the same version of Glassfish (Sun Java System Application Server
> 9.1_02 (build b04-fcs)), but I obtain an error - you can see the log at
> the end of the email.
>
> I configured the production Glassfish in NetBeans so I deploy the Web
> App directly from NetBeans.
>
> Glassfish says that I "Cannot use an EntityTransaction while using JTA.".
>
> Why in the the netbeans bundle version of glassfish is all ok, but
> doesn't it work in a new Glassfish installation?
>
> I post my code so you can easily understand the error.
>
> <code>
>
> EntityManager entityManager =
> javax.persistence.Persistence.createEntityManagerFactory("MyRentStorePU").createEntityManager();
>
> try {
> entityManager.getTransaction().begin();
> entityManager.persist(cliente);
> entityManager.getTransaction().commit();
>
>
> } catch( RuntimeException e ) {
> entityManager.getTransaction().rollback();
> throw e;
> }
>
>
> </code>
>
> The exception happen at the catch block, when invoking
> entityManager.getTransaction().rollback();
> So I think the error is at
> entityManager.getTransaction().rollback();
>
> So here it is the Exception from Glassfish log:
> ############## BEGIN ######################
>
> [#|2008-08-26T09:15:51.391+0200|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-2;_RequestID=8029d9f4-17cc-4b61-8f75-36895b858585;|StandardWrapperValve[Faces
> Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw
> exception
> com.sun.rave.web.ui.appbase.ApplicationException:
> #{ConfirmYourData.buttonOk_action}: java.lang.IllegalStateException:
> Exception Description: Cannot use an EntityTransaction while using JTA.
> at
> com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:594)
> at
> com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:311)
> at
> com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
> at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
> at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
> at
> com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.render(PartialTraversalLifecycle.java:106)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
> at
> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
> at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
> 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.connector.grizzly.TaskBase.run(TaskBase.java:265)
> at
> com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
> Caused by: javax.faces.FacesException:
> #{ConfirmYourData.buttonOk_action}: java.lang.IllegalStateException:
> Exception Description: Cannot use an EntityTransaction while using JTA.
> at
> com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
> at
> com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
> at javax.faces.component.UICommand.broadcast(UICommand.java:383)
> at
> com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:160)
> at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
> at
> javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
> at
> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
> at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
> at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
> at
> com.sun.faces.extensions.avatar.lifecycle.PartialTraversalLifecycle.execute(PartialTraversalLifecycle.java:94)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
> ... 31 more
> Caused by: javax.faces.el.EvaluationException:
> java.lang.IllegalStateException:
> Exception Description: Cannot use an EntityTransaction while using JTA.
> at
> javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
> at
> com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
> ... 41 more
> Caused by: java.lang.IllegalStateException:
> Exception Description: Cannot use an EntityTransaction while using JTA.
> at
> oracle.toplink.essentials.internal.ejb.cmp3.transaction.JTATransactionWrapper.getTransaction(JTATransactionWrapper.java:66)
> at
> oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.getTransaction(EntityManagerImpl.java:340)
> at myrentstore.ConfirmYourData.buttonOk_action(ConfirmYourData.java:233)
> 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.el.parser.AstValue.invoke(AstValue.java:187)
> at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
> at
> javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
> ... 42 more
> |#]
>
> ############## END ######################
>
>
> Thank you in advance for your help.
>
> Regards,
> Mauro Chiarugi
>