Getting Error during plugin deployment, (osgi.wiring.package=com.atlassian.inject) Unresolved requirements

Hi,
I’m building plugin for jira server. it is throwing below error during plugin deployment.


[INFO] [talledLocalContainer] ___ FAILED PLUGIN REPORT _____________________
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] 1 plugin failed to load during Jira startup.
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] ‘com.cgi.asop.asopWorkflowFieldsDelegator’ - ‘ASOP WorkFlow Fields Delegator’ failed to load.
[INFO] [talledLocalContainer] Cannot start plugin: com.cgi.asop.asopWorkflowFieldsDelegator
[INFO] [talledLocalContainer] Unable to resolve com.cgi.asop.WorkflowFieldsDelegator [196](R 196.0): missing requirement [com.cgi.asop.WorkflowFieldsDelegator [196](R 196.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.inject) Unresolved requirements: [[com.cgi.asop.WorkflowFieldsDelegator [196](R 196.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.inject)]
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] It was loaded from C:\Proaction\plugins\ASOP-Workflow-Fields-Delegator\target\jira\home\plugins\installed-plugins\asopWorkflowFieldsDelegator-1.1.3.jar
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] ********************************************************************************************************************************************************************************************************

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.xxx.asop</groupId>
	<artifactId>asopWorkflowFieldsDelegator</artifactId>
	<version>1.1.3</version>
	<organization>
		<name>xxx</name>
		<url>www.xxx.com/</url>
	</organization>
	<name>asopWorkflowFieldsDelegator</name>
	<description>This is the com.xxx.asop:asopWorkflowFieldsDelegator 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>
		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>jira-core</artifactId>
			<version>${jira.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.atlassian.plugin</groupId>
			<artifactId>atlassian-spring-scanner-annotation</artifactId>
			<version>${atlassian.spring.scanner.version}</version>
			<scope>compile</scope>
			<!-- <scope>provided</scope> -->
		</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>
		<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>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.1.1</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>com.atlassian.sal</groupId>
			<artifactId>sal-api</artifactId>
			<version>3.0.7</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.velocity</groupId>
			<artifactId>velocity</artifactId>
			<version>1.7</version>
		</dependency>
		<dependency>
			<groupId>log4j</groupId>
			<artifactId>log4j</artifactId>
			<version>1.2.17</version>
		</dependency>
		<dependency>
			<groupId>com.atlassian.crowd</groupId>
			<artifactId>embedded-crowd-api</artifactId>
			<version>2.8.0-OD-6-JIRA-05</version>
		</dependency>
		<dependency>
			<groupId>com.atlassian.plugins</groupId>
			<artifactId>atlassian-plugins-webfragment-api</artifactId>
			<version>4.1.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.atlassian.plugins</groupId>
			<artifactId>atlassian-plugins-core</artifactId>
			<version>2.6.0</version>
		</dependency>
		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>jira-projects-api</artifactId>
			<version>4.1.13</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>velocity-tools</groupId>
			<artifactId>velocity-tools-generic</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>com.sun.jersey</groupId>
			<artifactId>jersey-client</artifactId>
			<version>1.8</version>
		</dependency>
		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20090211</version>
		</dependency>
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>r05</version>
		</dependency>
		<dependency>
			<groupId>org.apache.lucene</groupId>
			<artifactId>lucene-core</artifactId>
			<version>8.1.1</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.cargo</groupId>
			<artifactId>cargo-maven3-plugin</artifactId>
			<version>1.9.2</version>
		</dependency>
		<dependency>
			<groupId>net.java.dev.activeobjects</groupId>
			<artifactId>activeobjects</artifactId>
			<version>3.0.0</version>
		</dependency>
		<dependency>
			<groupId>com.atlassian.activeobjects</groupId>
			<artifactId>activeobjects-plugin</artifactId>
			<version>3.0.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.google.collections</groupId>
			<artifactId>google-collections</artifactId>
			<version>1.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.atlassian.templaterenderer</groupId>
			<artifactId>atlassian-template-renderer-api</artifactId>
			<version>4.0.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.ofbiz</groupId>
			<artifactId>ofbcore-jira-entity</artifactId>
			<version>2.1.8</version>
		</dependency>
        <dependency>
               <groupId>org.projectlombok</groupId>
               <artifactId>lombok</artifactId>
               <version>1.18.10</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>
					<enableQuickReload>true</enableQuickReload>
					<allowGoogleTracking>false</allowGoogleTracking>
					<instructions>
						<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
						<Export-Package>com.xxx.asop,</Export-Package>

						<Import-Package>
							org.springframework.osgi.*;resolution:="optional",
							org.eclipse.gemini.blueprint.*;resolution:="optional", *</Import-Package>

							<Import-Package>*</Import-Package>
     						<Spring-Context>*</Spring-Context>
						<!-- <Require-Bundle> com.onresolve.jira.groovy.groovyrunner </Require-Bundle> -->
					</instructions>
					<applications>
						<application>
							<applicationKey>jira-software</applicationKey>
							<version>${jira.version}</version>
						</application>
					</applications>
					<startupTimeout>1500000</startupTimeout>
					<shutdownTimeout>900000</shutdownTimeout>
<!-- 					<productDataPath>${basedir}/src/test/resources/generated-test-resources.zip</productDataPath>
 -->					<!-- <jvmArgs>-Xms1g -Xmx2g -XX:MaxPermSize=1g -XX:-UseGCOverheadLimit 
						-server</jvmArgs> -->
				</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>
			<plugin>
				<groupId>com.atlassian.maven.plugins</groupId>
				<artifactId>amps-maven-plugin</artifactId>
				<version>8.0.2</version>
				<configuration>
					<startupTimeout>1200000</startupTimeout>
					<shutdownTimeout>900000</shutdownTimeout>
					<enableFastdev>true</enableFastdev>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.1</version>
				<configuration>
					<executable>${JAVA_HOME}/bin/javac</executable>
					<compilerVersion>1.8</compilerVersion>
					<fork>true</fork>
				</configuration>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>com.atlassian.plugin</groupId>
										<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
										<versionRange>[1.2.13,)</versionRange>
										<goals>
											<goal>atlassian-spring-scanner</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore />
									</action>
								</pluginExecution>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>com.atlassian.maven.plugins</groupId>
										<artifactId>jira-maven-plugin</artifactId>
										<versionRange>[8.0.1,)</versionRange>
										<goals>
											<goal>compress-resources</goal>
											<goal>filter-plugin-descriptor</goal>
											<goal>filter-test-plugin-descriptor</goal>
											<goal>generate-rest-docs</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore />
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
	<pluginRepositories>
		<pluginRepository>
			<id>atlassian-public</id>
			<url>https://m2proxy.atlassian.com/repository/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>
	<properties>
		<jira.version>8.11.1</jira.version>
		<amps.version>8.0.2</amps.version>
		<atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
		<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
		<quick.reload.version>3.0.0</quick.reload.version>
		<testkit.version>6.3.11</testkit.version>
		<maven.test.skip>true</maven.test.skip>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<!-- <argLine>JVM_SUPPORT_RECOMMENDED_ARGS="-Datlassian.plugins.enable.wait=300"</argLine> -->
		<argLine>-Datlassian.plugins.enable.wait=300</argLine>
	</properties>
</project>

Hi,

This error means there was some package “com.atlassian.inject” which your app tries to import (via Import-Package) at runtime, but which Jira is not providing:

Your pom looks quite incorrect to me, and maybe it is the root cause of the problems. The default scope in maven is “compile” so you will compiling in the jira-projects-api (and indeed most of your dependencies) into your plugin when they are already provided by jira.

I suggest you change the scope of most of your dependencies to provided if they should be provided by Jira, rather than compiled into your plugin.

I suggest you review all of the dependencies in your pom, I see quite a few that I don’t think should be required in a plugin, e.g direct dependency on velocity, (SAL api provides TemplateRenderer), direct dependency on lucene, cargo and active objects. Maybe it is valid for your plugin use-case, but if you are just trying to use the plugin system, you shouldn’t need these dependencies.

The normal debugging process for this exception would be to through the OSGI browser: https://developer.atlassian.com/server/framework/atlassian-sdk/using-the-osgi-browser/ and determine if anything is actually exporting the package that you require.

It’s also worth noting your Import-Package section in your pom.xml looks incorrect - it looks like you have the section repeated twice - I would remove the second as it looks incorrect.