Jira Event Listener com.springframework... Errors Following Tutorial

Hello Developer Community!

I’m newer here and am following the Atlassian plugin tutorial. I was able to successfully create a plugin that makes postfunctions. I’ve started development on another portion of the plugin that creates an event listener via the tutorials but am getting dependency errors. This is the tutorial:
https://developer.atlassian.com/server/jira/platform/writing-jira-event-listeners-with-the-atlassian-event-library/

When the Jira server is up and running locally on port 2990 and I add my listener class, I get the following errors:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project pmatplugin: Compilation failure: Compilation failure: 
[ERROR] ~/exampleplugin/src/main/java/com/example/rocks/jira/workflow/listeners/ProjectCreatedListener.java:[12,52] package org.springframework.beans.factory.annotation does not exist
[ERROR] ~/exampleplugin/src/main/java/com/example/rocks/jira/workflow/listeners/ProjectCreatedListener.java:[13,38] package org.springframework.stereotype does not exist
[ERROR] ~/exampleplugin/src/main/java/com/example/rocks/jira/workflow/listeners/ProjectCreatedListener.java:[18,2] cannot find symbol
[ERROR]   symbol: class Component
[ERROR] ~/exampleplugin/src/main/java/com/example/rocks/jira/workflow/listeners/ProjectCreatedListener.java:[22,6] cannot find symbol
[ERROR]   symbol:   class Autowired
[ERROR]   location: class com.example.rocks.jira.workflow.listeners.ProjectCreatedListener
[ERROR] -> [Help 1]

My pom.xml:

<?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.example.rocks</groupId>
    <artifactId>exampleplugin</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <organization>
        <name>EXAMPLE INC</name>
        <url>http://www.example.com/</url>
    </organization>
    <name>exampleplugin</name>
    <description>This is an example 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>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>1.2.12</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-runtime</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</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>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.2-atlassian-1</version>
        </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>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>osworkflow</groupId>
            <artifactId>osworkflow</artifactId>
            <version>2.9.0-atlassian-1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>opensymphony</groupId>
            <artifactId>propertyset</artifactId>
            <version>1.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp</artifactId>
            <version>4.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp3</groupId>
            <artifactId>okhttp-urlconnection</artifactId>
            <version>4.0.1</version>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.springframework</groupId>-->
<!--            <artifactId>spring-beans</artifactId>-->
<!--            <version>5.1.5.RELEASE</version>-->
<!--        </dependency>-->
<!--        <dependency>-->
<!--            <groupId>org.springframework</groupId>-->
<!--            <artifactId>spring-context</artifactId>-->
<!--            <version>5.1.5.RELEASE</version>-->
<!--        </dependency>-->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>jira-maven-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>
                    -->
                    <enableQuickReload>true</enableQuickReload>
                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <!-- Add package to export here -->
                        <Export-Package>com.pmat.rocks.pmatplugin.api,</Export-Package>
                        <!-- Add package import here -->
                        <!-- *;resolution:="optional", *;version="0";resolution:=optional added for BundleException -->
                        <Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", com.atlassian.upm.*;resolution:="optional", *;version="0";resolution:=optional</Import-Package>
                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <jira.version>7.13.0</jira.version>
        <amps.version>8.0.2</amps.version>
        <plugin.testrunner.version>2.0.1</plugin.testrunner.version>
        <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
        <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <!-- TestKit version 6.x for JIRA 6.x -->
        <testkit.version>6.3.11</testkit.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

I tried to add the spring-beans and spring-context dependencies individually and then together (commented out above) but the plugin fails to load with the following errors on atlas-run each time. I also tried multiple different versions of the same dependencies.

'com.example.rocks.exampleplugin-tests' - ‘exampleplugin’  failed to load.
[INFO] [talledLocalContainer]                   Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.eclipse.org/gemini/blueprint/schema/blueprint]
[INFO] [talledLocalContainer]     Offending resource: URL [bundle://178.0:0/META-INF/spring/atlassian-plugins-component-imports.xml]
[INFO] [talledLocalContainer]     
[INFO] [talledLocalContainer]     
[INFO] [talledLocalContainer]                   It was loaded from ~/exampleplugin/target/jira/home/plugins/installed-plugins/exampleplugin-1.0.0-SNAPSHOT-tests.jar
[INFO] [talledLocalContainer]     
[INFO] [talledLocalContainer]           'com.example.rocks.exampleplugin' - 'exampleplugin'  failed to load.
[INFO] [talledLocalContainer]                   Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.atlassian.com/schema/atlassian-scanner]
[INFO] [talledLocalContainer]     Offending resource: URL [bundle://177.0:0/META-INF/spring/plugin-context.xml]
[INFO] [talledLocalContainer]     
[INFO] [talledLocalContainer]     
[INFO] [talledLocalContainer]                   It was loaded from ~/exampleplugin/target/jira/home/plugins/installed-plugins/exampleplugin-1.0.0-SNAPSHOT.jar

The plugin-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.atlassian.com/schema/atlassian-scanner
        http://www.atlassian.com/schema/atlassian-scanner/atlassian-scanner.xsd">
    <atlassian-scanner:scan-indexes/>
</beans>

Additional info:
Jira v7.13
Apache Tomcat v8.5.35
Java v1.8
IntelliJ IDE

Does anyone know what I can do to resolve these dependency errors? I found a few similar posts but none have been able to resolve my issue. I’ve also tried reimporting my project into IntelliJ.
Thank you for your help!
Em

Solved my issue! Had to add this to the AMPS portion of the pom.xml:
<extractDependencies>false</extractDependencies>

1 Like