Create and use custom transaction management in JIRA

As mentioned in this ticket -
The workaround for using transactions with ActiveObjects in Jira (and what Atlassian is doing) would be to manually start a transaction:

import com.atlassian.jira.transaction.Transaction;
import com.atlassian.jira.transaction.Txn;
    Transaction txn = Txn.begin();
    try {
    } finally {

begin is declared as

 * Represents the ability to peform a database transaction in JIRA.
 * @since v4.4.1
public interface TransactionSupport {
     * This begins a new transaction if one is not already running for this thread.
     * <p>
     * It will be a NoOp if a transaction is already running and in this case a call to {@link
     * Transaction#commit()} will also be a NoOp.  The outer caller is then reponsible
     * for the ultimate commit or rollback.
     * <p>
     * It will also be a NoOp if a transaction support in JIRA is turned off.
     * @return a {@link Transaction} context object that you can called commit or rollback on
     * @throws TransactionRuntimeException if the transaction can not be established at all
    Transaction begin() throws TransactionRuntimeException;

So to interact with Transaction interface, I need it reference the appropriate maven dependency. Where can I get the dependency? I am developing the plugin for JIRA 7.3.0.

To access Atlassian’s Maven artifacts, you need to either use the Atlassian Plugin SDK, which bundles a properly configured Maven, or at least use the Atlassian Maven Proxy

Could you tell me the exact dependency which brings in com.atlassian.jira.transaction
As I am facing this error when I compile
[ERROR] test/src/main/java/com/test/jira/app/service/[10,38] package com.atlassian.jira.transaction does not exist

I got my answer by just putting in random stuff into pom.xml, if anyone comes to this page, this is the dependency which contains implementation classes for JIRA.

1 Like