Jira java api client problem with dependencies

vovkakibe October 27, 2021

Hello.I make a plugin with jira-rest-java-client-core.I have some problems with dependencies.

Version jira:

8.13.10

My pom file:

<?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>ru.alfabank.atlassian</groupId>
<artifactId>jira-vendor-sync</artifactId>
<version>1.0.0</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>jira-vendor-sync</name>
<description>This is the ru.alfabank.atlassian:jira-vendor-sync plugin for Atlassian JIRA.</description>
<packaging>atlassian-plugin</packaging>
<repositories>
<repository>
<id>alfa-public</id>
<name>public Repository</name>
<url>https://binary.alfabank.ru/artifactory/public</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>alfa-central</id>
<name>Central Repository</name>
<url>https://binary.alfabank.ru/artifactory/mavenatlassian</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>atlassian-plugin-sdk-public</id>
<name>public Repository</name>
<url>https://binary.alfabank.ru/artifactory/public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>atlassian-plugin-sdk</id>
<name>Central plugin Repository</name>
<url>https://binary.alfabank.ru/artifactory/mavenatlassian</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>io.atlassian.util.concurrent</groupId>
<artifactId>atlassian-util-concurrent</artifactId>
</exclusion>
<exclusion>
<groupId>com.atlassian.httpclient</groupId>
<artifactId>atlassian-httpclient-library</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<version>4.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</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>${atlassian.spring.scanner.version}</version>
<scope>provided</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>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>5.1.2-2bd0a62e</version>
<!--
JIRA will already provide a number of dependencies that JRJC needs. We need to exclude
them from the JRJC dependency as we don't want to package them up inside the plugin.
-->
<exclusions>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
</exclusion>
<exclusion>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</exclusion>
<exclusion>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.atlassian.event</groupId>
<artifactId>atlassian-event</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</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>
</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 import here -->
<!--<Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", *;version="0";resolution:=optional</Import-Package>-->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
com.atlassian.inject;resolution:="optional",
com.sun.xml.fastinfoset.*;resolution:="optional",
groovy.*;resolution:="optional",
joptsimple;resolution:="optional",
net.sf.ehcache;resolution:="optional",
net.spy.memcached;resolution:="optional",
org.*;resolution:="optional",
sun.misc;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>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jira.version>8.13.10</jira.version>
<amps.version>8.1.2</amps.version>
<plugin.testrunner.version>2.0.2</plugin.testrunner.version>
<atlassian.spring.scanner.version>2.1.7</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>

 And i have error with compilation:

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:
make sure platform artifacts are not bundled into plugin
Found Banned Dependency: io.atlassian.util.concurrent:atlassian-util-concurrent:jar:4.0.1
Found Banned Dependency: com.google.code.findbugs:jsr305:jar:3.0.2
Found Banned Dependency: com.google.guava:guava:jar:26.0-jre
Found Banned Dependency: com.atlassian.httpclient:atlassian-httpclient-api:jar:2.0.0
Found Banned Dependency: org.apache.httpcomponents:httpcore:jar:4.4.10
Found Banned Dependency: org.apache.httpcomponents:httpmime:jar:4.5.5
Found Banned Dependency: org.apache.httpcomponents:httpclient:jar:4.5.5
Found Banned Dependency: org.apache.httpcomponents:httpclient-cache:jar:4.5.5
Use 'mvn dependency:tree' to locate the source of the banned dependencies.

3 answers

0 votes
I_L_I_A April 2, 2023

That means external httpcomponents are banned by jira for some reason, either because its already shipped with one and you need scope provided(which you say result in classNotFound error) OR its blocked on some other level. Anyways, you'd need to switch to another package to do http requests if thats the case.

Hope it helps.

0 votes
Nhac Tat Nguyen October 28, 2021

You can try to set the version of AMPS back to 8.0.0 and package the app again.

<amps.version>8.0.0</amps.version>
0 votes
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 27, 2021

Hello @vovkakibe 

Try adding <scope>provided</scope> for those dependencies which means that Maven will not package those dependencies, and the container will provide them.

Hope it helps

Tuncay

vovkakibe October 27, 2021

If i add this dependencies to scope provided i have another problem:

java.lang.NoClassDefFoundError: org/codehaus/jettison/json/JSONException

After i add new dependencies to my pom:

<!-- https://mvnrepository.com/artifact/org.codehaus.jettison/jettison -->
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.4.1</version>
</dependency>

And get this:

java.lang.NoSuchMethodError: com.atlassian.httpclient.api.ResponseTransformation$Builder.ok(Lcom/google/common/base/Function;)Lcom/atlassian/httpclient/api/ResponseTransformation$Builder;
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2021

Yes, but it is good to have fewer dependencies in the jar file, so adding all runtime dependencies (with provided scope) would be better IMO.

Suggest an answer

Log in or Sign up to answer