Third-party jar not being packaged by maven and not being found on Jira

Aaron Humphrey August 27, 2015

I'm trying to write an event-handler plugin for JIRA which has a dependency on the RabbitMQ client (so it can send notifications via RabbitMQ about issue changes).

Originally we were doing this through Groovy scripts, so we just dumped rabbitmq-client.jar (and, I believe, some apache dependencies) into atlassian-jira/WEB-INF/lib.  For development, I manually added rabbitmq-client.jar to my Eclipse classpath, but added amqp-client (which includes the com.rabbitmq.client package) as an "included" dependency.  But when I deployed my plugin, the classloader complained about being unable to load com.rabbitmq.client.ConnectionFactory, so obviously it wasn't finding it.  (Our plugin is Version 2.)

After some research, I thought I'd try changing amqp-client to a "compile" dependency instead.  And it worked, for a while, at least–it bundled the com.rabbitmq .class files into my plugin's JAR file, and things worked.  There were bugs, I made a few code changes, and then ran atlas-package again to rebuild my plugin file, uploaded it in JIRA...and it stopped working.  It was giving me the same classloader errors about com.rabbitmq.client.ConnectionFactory.

When I looked in the JAR file, it was no longer packaging com.rabbitmq in there.  And the output of atlas-package says "amqp-client-3.3.1.jar already exists in destination."  Why would it think that?  Where is this "destination"?  I'm building this on a completely different machine than my (test) JIRA server, so it obviously doesn't have a clue, so why doesn't it listen when I say I need to compile it in?

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
  <plugin-info>
    <description>${project.description}</description>
    <version>${project.version}</version>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
  </plugin-info>
  <!-- add our i18n resource -->
  <resource type="i18n" name="i18n" location="issue-link-watcher"/>
  
  <!-- publish our component -->
  <component key="eventListener" class="com.pleasantsolutions.jira.plugins.listeners.IssueEventDispatcher">
    <description>Class that processes the incoming JIRA issue events.</description>
  </component>

  <!-- import from the product container -->
  <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/>
  <component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>
  
  <servlet-filter name="Issue Link Servlet Filter" i18n-name-key="issue-link-servlet-filter.name" key="issue-link-servlet-filter" class="com.pleasantsolutions.jira.plugins.servlet.filter.IssueLinkServletFilter" location="before-dispatch" weight="100">
    <description key="issue-link-servlet-filter.description">The Issue Link Servlet Filter Plugin</description>
    <url-pattern>/*</url-pattern>
  </servlet-filter>
</atlassian-plugin>
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.pleasantsolutions.jira.plugins</groupId>
    <artifactId>issue-link-watcher</artifactId>
    <version>1.0-pre0007</version>
    <organization>
        <name>Pleasant Solutions</name>
        <url>http://www.pleasantsolutions.com/</url>
    </organization>
    <name>issue-link-watcher</name>
    <description>This is the com.pleasantsolutions.jira.plugins:issue-link-watcher plugin for Atlassian JIRA.</description>
    <packaging>atlassian-plugin</packaging>
    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
        <!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
        <!--
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <version>${jira.version}</version>
            <scope>provided</scope>
        </dependency>
        -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>${plugin.testrunner.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
            <scope>provided</scope>
        </dependency>
        <!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
        <!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
        <!--
        <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-testkit-client</artifactId>
            <version>${testkit.version}</version>
            <scope>test</scope>
        </dependency>
        -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.1.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.rabbitmq</groupId>
            <artifactId>amqp-client</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>2.5.6.SEC03</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>
                    <!-- Uncomment to install TestKit backdoor in JIRA. -->
                    <!--
                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.jira.tests</groupId>
                            <artifactId>jira-testkit-plugin</artifactId>
                            <version>${testkit.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                    -->
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <jira.version>6.3.6</jira.version>
        <amps.version>5.0.4</amps.version>
        <plugin.testrunner.version>1.2.0</plugin.testrunner.version>
        <!-- TestKit version 5.x for JIRA 5.x, 6.x for JIRA 6.x -->
        <testkit.version>5.2.26</testkit.version>
    </properties>
</project>

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Aaron Humphrey August 27, 2015

Just noticed that there's a "target/dependency-maven-plugin-markers" folder, which contained a file named "com.rabbitmq-amqp-client-jar-3.3.1.marker".  I removed the file, and my next atlas-package call actually bundled the com.rabbitmq packages into my jar file...and put the .marker file back in place.  So does this mean that I have to explicitly remove this marker file, or atlas-clean, before every package build?  (I imagine on the actual build server this will be less of an issue, because it should recreate its build folders from scratch every time, but I'm still in debug mode.)

TAGS
AUG Leaders

Atlassian Community Events