Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After some trial and error I have come up with the following approach:</p> <ol> <li>Create a JDBC Connection pool in glassfish that is used to access the Jackrabbit Repository tables.</li> <li>Set the resource type to javax.sql.DataSource and enable 'Non Transactional Connections'</li> <li>Create a JDBC resource that can be used to access to the Jackrabbit JDBC Connection Pool. Use the JNDI name defined in this resource in the Jackrabbit repository.xml to configure the persistence manager etc.</li> <li>Create a Connector connection pools using the Jackrabbit-jca resource adapter</li> <li>Set Transaction Support to XATransaction</li> <li>Add the property 'bindSessionToTransaction' and set it to true</li> <li>Create a Connector Resource that can be used to inject the Repository into a EJB</li> </ol> <p>I have tested this with a stateless EJB and it works without error.</p> <p>I also created a second JDBC Connection pool of type javax.sql.DataSource and a JDBC resource that points to a separate database that maintains the applications other tables and created a persistence.xml that uses the datasource.</p> <p>I then modified both the repo and the tables in the applications database (using JPA) and confirmed that if the transaction is rolled back both the changes on the repo and application tables are rolled back correctly.</p> <p>I believe this is the correct approach as it allows Jackrabbit to be in full control of it's database connection but still participate in the container managed transaction as an XA Resource.</p> <p>I did test the second datasource both as a XADataSource and a non-XA DataSource and both approaches worked. I assume it does not need to be a XADataSource as the are no other non-XA DataSources in the transaction and it participates in the global transaction via LLR (Logging Last Resource).</p> <p><strong>Update 1:</strong></p> <p>It turns out you can also get this to work by bypassing the repo datasource and configuring the JDBC URL directly in the repository xml. One benefit of this is when clustering the repo you do not need to create a datasource in each Glassfish instance, instead you can just copy the repository.xml and change the cluster node id.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload