users@glassfish.java.net

Re: From NetBeans bundle version to server

From: Danilo Levantesi <danilo.levantesi_at_gmail.com>
Date: Tue, 26 Aug 2008 15:34:33 +0200

I had a similar problem when I switched from Netbeans 5.5.1 to 6.1 and created
a new persistence unit in a project.
This is my persistence.xml, hope it can help you (replace "project-PU"
and "jdbc/datasource" with more useful names).

<persistence-unit name="project-PU" transaction-type="JTA">
    
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    <jta-data-source>jdbc/datasource</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="toplink.ddl-generation" value="create-tables"/>
    </properties>
  </persistence-unit>

> 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").c
>reateEntityManager();
>
> 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.sy
>stem.container.web|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-2;_Requ
>estID=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.j
>ava:594) at
> com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImp
>l.java:311) at
> com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.jav
>a: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(ApplicationF
>ilterChain.java:411) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>nFilterChain.java:317) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>hain.java:198) at
> com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
>nFilterChain.java:230) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
>hain.java:198) at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.j
>ava:288) at
> org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContex
>tValve.java:271) at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.j
>ava:202) at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:63
>2) at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:57
>7) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94) at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:20
>6) at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:63
>2) at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:57
>7) 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.jav
>a:150) at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:63
>2) at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:57
>7) 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(Def
>aultProcessorTask.java:568) at
> com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(Defau
>ltProcessorTask.java:813) at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTa
>sk(DefaultReadTask.java:341) at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultRead
>Task.java:263) at
> com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultRead
>Task.java:214) at
> com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
> at
> com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerT
>hread.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(ActionListenerIm
>pl.java:107) at
> com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionLi
>stenerImpl.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(InvokeApplicationPha
>se.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(MethodBin
>dingMethodExpressionAdapter.java:91) at
> com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerIm
>pl.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.JTATransactionWrapp
>er.getTransaction(JTATransactionWrapper.java:66) at
> oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.getTransactio
>n(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:3
>9) at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp
>l.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(MethodBin
>dingMethodExpressionAdapter.java:77) ... 42 more
>
> |#]
>
> ############## END ######################
>
>
> Thank you in advance for your help.
>
> Regards,
> Mauro Chiarugi