Here's what comes to mind...
Do you want to use JPA or JTA cause you are mixing a soup.
Seems glassfish is using JTA.
Did you generate this toplink PU using netbeans?
Then the JTA em can (should?) be injected through di (you are using a JPA
em)
Try this code snippet :
<code>
@PersistenceContext
private EntityManager em;
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void remove(Object obj) {
Object mergedObj = em.merge(obj);
em.remove(mergedObj);
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void persist(Object obj) {
em.persist(obj);
}
</code>
for this to work, in persistence.xml it should say :
<persistence-unit name="jtatest" transaction-type="JTA"> (not JPA)
hope it helps,
Wim
-----Original Message-----
From: Mauro Chiarugi - Dogma Systems [mailto:mauro.chiarugi_at_dogmasystems.it]
Sent: dinsdag 26 augustus 2008 12:49
To: users_at_glassfish.dev.java.net
Subject: From NetBeans bundle version to server
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").cr
eateEntityManager();
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.sys
tem.container.web|_ThreadID=20;_ThreadName=httpSSLWorkerThread-8080-2;_Reque
stID=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.ja
va: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(P
artialTraversalLifecycle.java:106)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFi
lterChain.java:411)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:317)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:198)
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:230)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:198)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:288)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:271)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va: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(Defa
ultProcessorTask.java:568)
at
com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(Defaul
tProcessorTask.java:813)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTas
k(DefaultReadTask.java:341)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadT
ask.java:263)
at
com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadT
ask.java:214)
at
com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
at
com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerTh
read.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(ActionListenerImp
l.java:107)
at
com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionLis
tenerImpl.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(InvokeApplicationPhas
e.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(MethodBind
ingMethodExpressionAdapter.java:91)
at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImp
l.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.JTATransactionWrappe
r.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(MethodBind
ingMethodExpressionAdapter.java:77)
... 42 more
|#]
############## END ######################
Thank you in advance for your help.
Regards,
Mauro Chiarugi
--
Mauro Chiarugi
Dogma Systems Srl:
http://www.dogmasystems.it
MyRent, Car Rental Software:
http://www.myrent.it
http://www.myrent.es
http://www.myrent.eu
Email: mauro.chiarugi [at] dogmasystems.it
Tel : +39 071 90 90 188
Fax : +39 071 250 99 63
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: users-help_at_glassfish.dev.java.net