Fórum

How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

Hubert Felber, modificado 13 Anos atrás.

How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

Regular Member Postagens: 157 Data de Entrada: 23/11/09 Postagens Recentes
Hi,

I use Liferay 6.05 / JBoss 5.1 / Derby DB

I need to do my own transaction handling (commit/rollback) and therefore must set AutoCommit to false.
I notice that the application seams to run with AutoCommit set to TRUE. Every DB statement is committed as soon as executed.

I am using liferay-ds.xml pointing to "lportal" as documented and let JBoss manage the data source. Another "derby-ds.xml" points to my applicationDB (also Derby) where I want to handle the transactions myself.
I cannot set AutoCommit to false on connections, because I use EJB's and CMP.

Could anyone please give me a hint how to achieve this? Till now I did not find helpful info.

Thank you
Hubert
thumbnail
Hitoshi Ozawa, modificado 13 Anos atrás.

RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
liferay-portal-6.0.5/jboss-5.1.0/server/default/deploy/liferay-ds.xml

<property name="defaultAutoCommit" value="false"/>
Hubert Felber, modificado 13 Anos atrás.

RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

Regular Member Postagens: 157 Data de Entrada: 23/11/09 Postagens Recentes
Hitoshi,
Hitoshi Ozawa:
liferay-portal-6.0.5/jboss-5.1.0/server/default/deploy/liferay-ds.xml
<property name="defaultAutoCommit" value="false"/>
Thank you, but unfortunately this did not help.
I added to liferay-ds.xml
	<connection-property name="autoCommit">false</connection-property>
but this changed nothing (I think this is default anyway). Still connections are autocommit==true
Then I added the following to ext-spring.xml
		<bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
		<property name="defaultAutoCommit" value="false" />
		<property name="targetDataSource">
			<bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean">
				<property name="propertyPrefix" value="jdbc.default." />
			</bean>
		</property>
	</bean>
and added the following to portal-ext.properties
    transaction.manager.impl=org.springframework.transaction.jta.JtaTransactionManager
    transaction.manager.property.allowCustomIsolationLevels=true
    transaction.manager.property.globalRollbackOnParticipationFailure=true

But still it does not work: In the context of LdapImporter I get

17:23:07,114 ERROR [STDERR] java.sql.SQLException: You cannot set autocommit during a managed transaction!
17:23:07,120 ERROR [STDERR]     at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:598)
17:23:07,124 ERROR [STDERR]     at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:458)
17:23:07,131 ERROR [STDERR]     at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.getTargetConnection(LazyConnectionDataSourceProxy.java:417)
17:23:07,137 ERROR [STDERR]     at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
 ....
17:23:07,437 ERROR [STDERR]     at com.liferay.portal.security.ldap.PortalLDAPImporterImpl.importFromLDAP(PortalLDAPImporterImpl.java:109)
...
The connection at this point still has autocommit set to true. And of course the db connections from my app are also autocommit true, so that I cannot manually do commits or rollbacks. They have no effect because everything is committed immediately.

I am at the same point as alexey here http://www.liferay.com/de/community/forums/-/message_boards/message/8182365#_19_message_5078738

and have no clue how to fix it.

So if you have any further idea, please let me know.

Thank you very much
Hubert
Hubert Felber, modificado 12 Anos atrás.

RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

Regular Member Postagens: 157 Data de Entrada: 23/11/09 Postagens Recentes
Hi,

The problem was not the autocommit, it was the missing "legacy-invokers-service.xml" in the deploy directory.
So the beans did not participate in existing transactions but started new Transactions, giving the impression to be in autocommit mode.
Steven Zhao, modificado 11 Anos atrás.

RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

New Member Postagens: 3 Data de Entrada: 23/02/12 Postagens Recentes
What should I put in "legacy-invokers-service.xml" and where should I put this file?

Thanks

Hubert Felber:
Hi,

The problem was not the autocommit, it was the missing "legacy-invokers-service.xml" in the deploy directory.
So the beans did not participate in existing transactions but started new Transactions, giving the impression to be in autocommit mode.
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
legacy-invokers-service.xml is a JBoss setting. Following JBoss page may help you.

http://docs.jboss.org/jbossas/docs/Installation_And_Getting_Started_Guide/5/html/The_JBoss_Server___A_Quick_Tour.html