Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira Plugin PostFunction cannot be built or installed in Jira

ramzi May 8, 2021

I am using

Windows 10 Pro

Atlassian SDK version 8.0.16 with maven 3.5.4

Intellij idea standard edition 2020.3.2, i configured it to use maven from Atlassian

I created a jira plugin with a PostFunction module but when i try to build it with atlas-package or install it in Jira i get this error.

Output from Surefire dump:

# Created at 2021-05-08T03:34:52.604
java.lang.NoClassDefFoundError: com/company/jira/workflow/MyPostFunction
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(ReflectionUtils.java:60)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly(JUnit3TestChecker.java:66)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUnit3Test(JUnit3TestChecker.java:61)
at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUnit3TestChecker.java:56)
at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:53)
at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:102)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:309)
at org.apache.maven.surefire.junit4.JUnit4Provider.setTestsToRun(JUnit4Provider.java:189)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:132)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)
Caused by: java.lang.ClassNotFoundException: com.company.jira.workflow.MyPostFunction
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 18 more

 

the pom.xml of the plugin project is :

<?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.company.project</groupId>
<artifactId>WorkflowExtensions</artifactId>
<version>1.0.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>SDMWorkflowExtensions</name>
<description>This is the com.company.project:WorkflowExtensions 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>${atlassian.spring.scanner.version}</version>
<scope>compile</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>
<!-- 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.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.0.0</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.company.project.api,</Export-Package>
<!-- Add package import here -->
<Import-Package>org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkCount>0</forkCount>
</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 searched a lot in google but could not find a solution.

Please help,

thanks in advance.

2 answers

0 votes
ramzi May 10, 2021

I don't know the reason why but after recreating the plugin i could build it successfully with atlas-package. however it still fails to get installed in the jira instance and the atlassian-jira.log shows the following error:

when i try to install the plugin atlassian-jia.log prints this error :

com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.company.project.WorkflowExtensions
2021-05-10 13:21:30,415+0200 UpmAsynchronousTaskManager:thread-2 WARN admin 1098x962x3 19nhqz7 192.168.98.110,10.22.38.24 /rest/plugins/1.0/available/featured [c.a.plugin.impl.AbstractPlugin] Because of this exception
2021-05-10 13:21:30,415+0200 UpmAsynchronousTaskManager:thread-2 WARN admin 1098x962x3 19nhqz7 192.168.98.110,10.22.38.24 /rest/plugins/1.0/available/featured [c.a.plugin.impl.AbstractPlugin] Unable to enable plugin 'com.company.project.WorkflowExtensions'
2021-05-10 13:21:30,415+0200 UpmAsynchronousTaskManager:thread-2 ERROR admin 1098x962x3 19nhqz7 192.168.98.110,10.22.38.24 /rest/plugins/1.0/available/featured [c.a.p.osgi.factory.OsgiPlugin] Detected an error (BundleException) enabling the plugin 'com.company.project.WorkflowExtensions' : Unable to resolve com.company.project.WorkflowExtensions [297](R 297.0): missing requirement [com.company.project.WorkflowExtensions [297](R 297.0)] osgi.wiring.package; (osgi.wiring.package=com.github.javaparser) Unresolved requirements: [[com.company.project.WorkflowExtensions [297](R 297.0)] osgi.wiring.package; (osgi.wiring.package=com.github.javaparser)]. This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN
2021-05-10 13:21:30,410+0200 UpmAsynchronousTaskManager:thread-2 ERROR admin 1098x962x3 19nhqz7 192.168.98.110,10.22.38.24 /rest/plugins/1.0/available/featured [c.a.p.osgi.factory.OsgiPluginInstalledHelper] Cannot determine required plugins, cannot resolve bundle 'com.company.project.WorkflowExtensions'

 

any idea why this happens or how to solve it ?

0 votes
Gonchik Tsymzhitov
Community Champion
May 8, 2021

Hi @ramzi , 

Did you try it the build your app? 

atlas-mvn clean package

And if it's ok, please share your pom.xml

Because your error show exact error between classloader and your class.

java.lang.NoClassDefFoundError: com/company/jira/workflow/MyPostFunction

ramzi May 8, 2021

Hello @Gonchik Tsymzhitov 

thanks for your answer,

I added my pom.xml in my first post.

I could clean the plugin using atlas-clean but this did not solve the problem.

running atlas-mvn clean returns

[INFO] --------------------------[ atlassian-plugin ]--------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.501 s
[INFO] Finished at: 2021-05-09T03:31:03+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "${mavenPluginName}=$mavenPluginName". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/LifecyclePhaseNotFoundException

 

The attlassian-jira.log of the project i am trying to install the plugin in shows the following error:

2021-05-09 03:09:23,713 UpmAsynchronousTaskManager:thread-2 INFO admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [atlassian.plugin.loaders.ScanningPluginLoader] No plugins found to be installed
2021-05-09 03:09:23,872 UpmAsynchronousTaskManager:thread-2 ERROR admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [plugin.osgi.factory.OsgiPluginInstalledHelper] Cannot determine required plugins, cannot resolve bundle 'com.company.project.WorkflowExtensions'
2021-05-09 03:09:23,878 UpmAsynchronousTaskManager:thread-2 INFO admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [atlassian.plugin.manager.PluginEnabler] Resolving 1 plugins
2021-05-09 03:09:23,879 UpmAsynchronousTaskManager:thread-2 INFO admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [atlassian.plugin.manager.PluginEnabler] Enabling 1 plugins: [com.company.project.WorkflowExtensions]
2021-05-09 03:09:23,881 UpmAsynchronousTaskManager:thread-2 ERROR admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [plugin.osgi.factory.OsgiPlugin] Detected an error (BundleException) enabling the plugin 'com.company.project.WorkflowExtensions' : Unable to resolve com.company.project.WorkflowExtensions [230](R 230.0): missing requirement [com.company.project.WorkflowExtensions [230](R 230.0)] osgi.wiring.package; (osgi.wiring.package=com.github.javaparser) Unresolved requirements: [[com.company.project.WorkflowExtensions [230](R 230.0)] osgi.wiring.package; (osgi.wiring.package=com.github.javaparser)]. This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN
2021-05-09 03:09:23,881 UpmAsynchronousTaskManager:thread-2 WARN admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [atlassian.plugin.impl.AbstractPlugin] Unable to enable plugin 'com.company.project.WorkflowExtensions'
2021-05-09 03:09:23,881 UpmAsynchronousTaskManager:thread-2 WARN admin 189x97x1 8a7h0w 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [atlassian.plugin.impl.AbstractPlugin] Because of this exception
com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: de.com.company.project.WorkflowExtensions
at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:424) [atlassian-plugins-osgi-5.2.3-96cf760eb.jar:?]
at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:252) [atlassian-plugins-core-5.2.3-96cf760eb.jar:?]
at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:120) [atlassian-plugins-core-5.2.3-96cf760eb.jar:?]

Suggest an answer

Log in or Sign up to answer