I have a couple of questions.
My application consists of some servlets and EJB session bean.
The goal is to save the data objects with hibernate.
I uses Jboss 4.0.2 and hibernate3
After loading the servlet, there are the exceptions:
-----------------
16:16:51,213 INFO [STDOUT] java.sql.SQLException: You cannot set autocommit during a managed transaction!
16:16:51,213 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.BaseWrapperMa
nagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:462)
16:16:51,213 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.WrappedConnec
tion.setAutoCommit(WrappedConnection.java:432)
------------------------
I think the reason is servlet and EJB is configured in non-managed and managed environments.
I read the book Hibernate in Action. Since Hibernate needs to be portable across these environments (page 49-50). Using JTATransactionFactory may fix this problem. I set up hibernate-service.xml, but running in jboss,
No Attribute found with name: TransactionStrategy.
-------------------------------------------
16:31:33,551 INFO [ServiceConfigurator] Problem configuring service jboss.har:s
ervice=Hibernate
org.jboss.deployment.DeploymentException: No Attribute found with name: TransactionStrategy
at org.jboss.system.ServiceConfigurator.configure(ServiceConfigurator.ja
va:263)
at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigura
tor.java:164)
at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java
:118)
at org.jboss.system.ServiceController.install(ServiceController.java:202
)
-------------------------------------------
Where is wrong? Or if this is a right way to fix “You cannot set autocommit during a managed transaction!” issue?
Thank you for your help!
chwang
This is hibernate-service file:
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">java:/PDSSTUDIO_DS</attribute>
<attribute name="Dialect">org.hibernate.dialect.SQLServerDialect</attribute>
<attribute name="SessionFactoryName">java:/pdsstudio/SessionFactory</attribute>
<attribute name="TransactionStrategy">
org.hibernate.transaction.JTATransactionFactory</attribute>
</mbean>
</server>
|