Controlling Transaction Management
drakemj Jan 17, 2013 3:38 PMBackground
I configured Jackrabbit (2.4.3) for a JBoss server (jboss-as-7.1.1.Final), by following the instructions here:
The relevant portions of my configuration are included at the end of this post.
Our application calls Jackrabbit under transaction management, within an EJB. From what I understand, the database connection configured for use with Jackrabbit cannot be under the control of an external transaction manager. I’ve read that “Jackrabbit implements distributed XA transaction support on a higher level, and expects to be in full control of the underlying database connection.” and “You can still do transactions with Jackrabbit, but you'll have to configure the transaction manager to work on top of Jackrabbit (using XASessions as the managed resources) instead of below Jackrabbit on the persistence layer.”
Question
My question is, how does one configure the transaction manager to satisfy these requirements? Unfortunately, I’m not sure whether this is an EJB setting, a datasource setting, part of the Jackrabbit configuration, or something else altogether.
A Related Error
Once Jackrabbit was configured, I noticed this (ironjacamar 1.0.9) error in my server log:
Caused by: java.sql.SQLException: You cannot set autocommit during a managed transaction! at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:888) at org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:715) at org.apache.jackrabbit.core.util.db.ConnectionHelper.getConnection(ConnectionHelper.java:439) at org.apache.jackrabbit.core.util.db.ConnectionHelper.reallyExec(ConnectionHelper.java:390) at org.apache.jackrabbit.core.util.db.ConnectionHelper$3.call(ConnectionHelper.java:378) at org.apache.jackrabbit.core.util.db.ConnectionHelper$3.call(ConnectionHelper.java:374) at org.apache.jackrabbit.core.util.db.ConnectionHelper$RetryManager.doTry(ConnectionHelper.java:567) at org.apache.jackrabbit.core.util.db.ConnectionHelper.exec(ConnectionHelper.java:374) at org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.verifyRootExists(DatabaseFileSystem.java:879)
This particular error codes from line 888 of http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.ironjacamar/ironjacamar-jdbc/1.0.9.Final/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java?av=fhttp://
I found that this error is the result of being in a managed transaction. The errors can be ignored (bypassed) by setting the ironjacamar.jdbc.ignoreautocommit system property to true. (I did this in standalone.xml.) Admittedly, this is a questionable fix. With this fixed, I get another string of errors. Rather than going down this other path of errors, I thought it was best to address the transaction manager configuration first.
My Configuration
1. jackrabbit-jca.rar\META-INF\MANIFEST.MF
Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: bart Build-Jdk: 1.6.0_34 Dependencies: javax.jcr export,org.slf4j
2. Standalone.xml (relevant excerpts only)
<system-properties> <!—other properties omitted -- > <property name="ironjacamar.jdbc.ignoreautocommit" value="true"/> </system-properties> <datasource jndi-name="java:/MyAppRepo" pool-name="MyAppRepo" enabled="true"> <connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url> <driver>oracle</driver> <security> <user-name>MyAppRepo</user-name> <password>MyAppRepo</password> </security> </datasource> <resource-adapter> <archive> jackrabbit-jca.rar </archive> <transaction-support>XATransaction</transaction-support> <connection-definitions> <connection-definition class-name="org.apache.jackrabbit.jca.JCAManagedConnectionFactory" jndi-name="java:/jca/MyApp" enabled="true" use-java-context="true" pool-name="jackrabbit-jca-1_6_1_rar-Pool" use-ccm="true"> <config-property name="HomeDir"> ${jboss.server.config.dir}/../../../repository </config-property> <config-property name="ConfigFile"> ${jboss.server.config.dir}/repository.xml </config-property> </connection-definition> </connection-definitions> </resource-adapter>
3. Repository.xml
See attachment
Thanks!
-
repository.xml 7.7 KB