Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hubert Felber
How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))
April 7, 2011 9:14 AM
Answer

Hubert Felber

Rank: Regular Member

Posts: 157

Join Date: November 23, 2009

Recent Posts

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
Hitoshi Ozawa
RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))
April 9, 2011 4:58 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

liferay-portal-6.0.5/jboss-5.1.0/server/default/deploy/liferay-ds.xml

<property name="defaultAutoCommit" value="false"/>
Hubert Felber
RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))
April 11, 2011 8:51 AM
Answer

Hubert Felber

Rank: Regular Member

Posts: 157

Join Date: November 23, 2009

Recent Posts

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
1    <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
1        <bean id="liferayDataSource" class="org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy">
2        <property name="defaultAutoCommit" value="false"/>
3        <property name="targetDataSource">
4            <bean class="com.liferay.portal.dao.jdbc.util.DataSourceFactoryBean">
5                <property name="propertyPrefix" value="jdbc.default."/>
6            </bean>
7        </property>
8    </bean>
and added the following to portal-ext.properties
1    transaction.manager.impl=org.springframework.transaction.jta.JtaTransactionManager
2    transaction.manager.property.allowCustomIsolationLevels=true
3    transaction.manager.property.globalRollbackOnParticipationFailure=true

But still it does not work: In the context of LdapImporter I get
 1
 217:23:07,114 ERROR [STDERR] java.sql.SQLException: You cannot set autocommit during a managed transaction!
 317:23:07,120 ERROR [STDERR]     at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:598)
 417:23:07,124 ERROR [STDERR]     at org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:458)
 517:23:07,131 ERROR [STDERR]     at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.getTargetConnection(LazyConnectionDataSourceProxy.java:417)
 617:23:07,137 ERROR [STDERR]     at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
 7 ....
 817:23:07,437 ERROR [STDERR]     at com.liferay.portal.security.ldap.PortalLDAPImporterImpl.importFromLDAP(PortalLDAPImporterImpl.java:109)
 9...
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
RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))
May 2, 2011 4:57 AM
Answer

Hubert Felber

Rank: Regular Member

Posts: 157

Join Date: November 23, 2009

Recent Posts

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
RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))
July 5, 2012 3:02 PM
Answer

Steven Zhao

Rank: New Member

Posts: 3

Join Date: February 23, 2012

Recent Posts

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.
Hitoshi Ozawa
RE: How to set AutoCommit to false ? (Liferay 6.05 / JBoss 5.1 / Derby))
July 5, 2012 5:20 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

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