Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JIRA plugin with JDK-1.8

pkozlov June 23, 2015

I was developping an atlassian plugin (JIRA) and tried to use java 8. By the way, JIRA is successfully running on JRE-1.8 without any troubles. More than that, I can use any new java class or method which appeared in java 8 (like java.time.LocalDate, for instance).

First thing I did - changed the version for maven-compiler-plugin:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

Everything is still working perfect. Plugin compiles, I can install and use it without any troubles.


When I add at least one syntactic feature which appeared in java 8 (lambda, method reference or anything else) anywhere, for example, this simple code:

List<String> list = Arrays.asList("1", "22", "333");
list.stream().map(String::length);

Code compiles without any issues. But when I try to install it to running JIRA instance, I see the following error in logs:

com.atlassian.plugin.PluginParseException: Unable to scan for host components in plugin classes
        at com.atlassian.plugin.osgi.factory.transform.stage.HostComponentSpringStage.execute(HostComponentSpringStage.java:62)
        at com.atlassian.plugin.osgi.factory.transform.DefaultPluginTransformer.transform(DefaultPluginTransformer.java:146)
        at com.atlassian.plugin.osgi.factory.OsgiPluginFactory.createOsgiPluginJar(OsgiPluginFactory.java:324)
        at com.atlassian.plugin.osgi.factory.OsgiPluginFactory.create(OsgiPluginFactory.java:229)
        at com.atlassian.jira.plugin.MasterPluginFactory.create(MasterPluginFactory.java:81)        
        at com.atlassian.plugin.loaders.ScanningPluginLoader.deployPluginFromUnit(ScanningPluginLoader.java:155)
        at com.atlassian.plugin.loaders.ScanningPluginLoader.loadFoundPlugins(ScanningPluginLoader.java:117)
        at com.atlassian.plugin.loaders.PermissionCheckingPluginLoader.loadFoundPlugins(PermissionCheckingPluginLoader.java:30)
        at com.atlassian.plugin.manager.DefaultPluginManager.scanForNewPlugins(DefaultPluginManager.java:850)
        at com.atlassian.plugin.manager.DefaultPluginManager.installPlugins(DefaultPluginManager.java:799)
        at com.atlassian.jira.plugin.JiraPluginManager.installPlugins(JiraPluginManager.java:163)
        at sun.reflect.GeneratedMethodAccessor970.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegis
trar.java:134)
        at com.sun.proxy.$Proxy73.installPlugins(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor970.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
        at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
        at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at com.sun.proxy.$Proxy1444.installPlugins(Unknown Source)
        at com.atlassian.upm.core.install.PluginArtifactInstallerImpl$1.doInTransaction(PluginArtifactInstallerImpl.java:55)
        at com.atlassian.upm.core.install.PluginArtifactInstallerImpl$1.doInTransaction(PluginArtifactInstallerImpl.java:50)
        at com.atlassian.sal.core.transaction.HostContextTransactionTemplate$1.doInTransaction(HostContextTransactionTemplate.java:25)
        at com.atlassian.jira.DefaultHostContextAccessor.doInTransaction(DefaultHostContextAccessor.java:34)
        at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegis
trar.java:134)
        at com.sun.proxy.$Proxy417.doInTransaction(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:154)
        at com.sun.proxy.$Proxy417.doInTransaction(Unknown Source)
        at com.atlassian.sal.core.transaction.HostContextTransactionTemplate.execute(HostContextTransactionTemplate.java:21)
        at sun.reflect.GeneratedMethodAccessor155.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
        at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
        at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
        at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
        at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
        at com.sun.proxy.$Proxy1505.execute(Unknown Source)
        at com.atlassian.upm.core.install.PluginArtifactInstallerImpl.installPlugins(PluginArtifactInstallerImpl.java:49)
        at com.atlassian.upm.core.install.AbstractPluginInstallHandler.installSingleArtifact(AbstractPluginInstallHandler.java:94)
        at com.atlassian.upm.core.install.JarPluginInstallHandler.installPluginInternal(JarPluginInstallHandler.java:47)
        at com.atlassian.upm.core.install.AbstractPluginInstallHandler.installPlugin(AbstractPluginInstallHandler.java:48)
        at com.atlassian.upm.core.install.DefaultPluginInstallationService.execute(DefaultPluginInstallationService.java:111)
        at com.atlassian.upm.core.install.DefaultPluginInstallationService.install(DefaultPluginInstallationService.java:87)
        at com.atlassian.upm.install.UpmPluginInstallationService.install(UpmPluginInstallationService.java:94)
        at com.atlassian.upm.core.rest.resources.install.InstallTask.installFromFile(InstallTask.java:123)
        at com.atlassian.upm.core.rest.resources.install.InstallFromFileTask.executeTask(InstallFromFileTask.java:38)
        at com.atlassian.upm.core.rest.resources.install.InstallTask.call(InstallTask.java:60)
        at com.atlassian.upm.core.rest.resources.install.InstallTask.call(InstallTask.java:34)
        at com.atlassian.upm.core.rest.async.AsynchronousTaskManager$1.call(AsynchronousTaskManager.java:78)
        at com.atlassian.upm.core.rest.async.AsynchronousTaskManager$1.call(AsynchronousTaskManager.java:73)
        at com.atlassian.sal.core.executor.ThreadLocalDelegateCallable.call(ThreadLocalDelegateCallable.java:42)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Error parsing class file
        at com.atlassian.plugin.osgi.util.ClassBinaryScanner.scanClassBinary(ClassBinaryScanner.java:66)
        at com.atlassian.plugin.osgi.factory.transform.stage.HostComponentSpringStage.findUsedHostComponents(HostComponentSpringStage.java:194)
        at com.atlassian.plugin.osgi.factory.transform.stage.HostComponentSpringStage.execute(HostComponentSpringStage.java:58)
        ... 88 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 18
        at aQute.lib.osgi.Clazz.parseClassFile(Clazz.java:448)
        at aQute.lib.osgi.Clazz.parseClassFile(Clazz.java:369)
        at aQute.lib.osgi.Clazz.parseClassFileWithCollector(Clazz.java:359)
        at com.atlassian.plugin.osgi.util.ClassBinaryScanner.scanClassBinary(ClassBinaryScanner.java:38)
        ... 90 more

Is it possible to make it working with java 8?

7 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
pkozlov December 17, 2015

By the way, it is resolved in JIRA-7. I had checked. Works fine with lambdas, method references and everything else.

2 votes
Herberts Markūns November 4, 2015

As Bernard Jaquet suggested in the comment, lambda expressions might be the cause for this, at least it was for me. After removing them from my code (that is, replacing with old-school java code), I was able to successfully upload the new version compiled on java 8. 

1 vote
Ulrich Hobelmann [catworkx]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2019

Same problem with Jira 7.13, now what's up with that?

Runtime is Java 8, plugin was compiled with Java 8.

Ulrich Hobelmann [catworkx]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2019

UPM seems to choke on a 3rd party library containing a module-info.class file in the jar (although it says it's compatible with Java 8?).

Hm, and my plugin's MANIFEST says it requires JavaSE 9.0, which I don't even have installed on my system. WTF?

Oh nice, the version of biz.aqute.bndlib is still 2.4.1, from 2015.

Ulrich Hobelmann [catworkx]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2019

Compiling with AMPS 6.2 at least fails early, because AMPS includes an old bndlib version that cannot parse the module-info.class.

With AMPS 8.0.0 everything builds fine, but installation on Jira 7.13 fails (because Jira still uses that ancient version, even after upgrading UPM). I got the plugin working by

  • configuring the maven-jar-plugin to exclude the 3rd party library's module-info.class, so there's nothing to choke on
  • explicitly setting a Require-Capability in the OSGi instructions that says it needs JavaSE version=1.8 instead of 9.0. (Since the filter uses quotation marks, you need to wrap it in CDATA.)
Frédéric Esnault May 28, 2019

Hi @Ulrich Hobelmann [catworkx] 

Could you please show us how you configured this ? I'm not finding any doc on this.

Also, are you using jira-maven-plugin or maven-jira-plugin (with AMPS 8 it should be jira-maven-plugin).

Thanks, I'm having a third party dependency that seems to make the plugin install fail.

Ulrich Hobelmann [catworkx]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 28, 2019

Yes, I used amps 8, as you say.

For the jar plugin:

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<excludes>
<exclude>**/module-info.class</exclude>
</excludes>
</configuration>
</plugin>

For the jira-maven-plugin, the following:

<instructions>
<Import-Package>
...
</Import-Package>
<Require-Capability>
<![CDATA[osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"]]>
</Require-Capability>
<CONF_COMM />
</instructions>

in addition to whatever imports you need there.

Hope this helps...

Frédéric Esnault May 28, 2019

Thanks a lot for the answer @Ulrich Hobelmann [catworkx] 

I'll test this this morning and come back to say if it helped.

But anyway, I'm very grateful you came to share your solution. Thanks !

Frédéric Esnault May 28, 2019

@Ulrich Hobelmann [catworkx] 

Unfortunately it did not help, here is the error :

2019-05-29 08:53:36,799 UpmAsynchronousTaskManager:thread-3 ERROR admin 580x4716x1 14qajfm 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [c.a.plugin.loaders.ScanningPluginLoader] Unable to deploy plugin 
2019-05-29 08:53:36,799 UpmAsynchronousTaskManager:thread-3 ERROR admin 580x4716x1 14qajfm 0:0:0:0:0:0:0:1 /rest/plugins/1.0/ [c.a.plugin.loaders.ScanningPluginLoader] Because of the following exception:
java.lang.NullPointerException
at com.atlassian.plugin.osgi.factory.transform.stage.HostComponentSpringStage.addHostComponentsUsedInSuperClasses(HostComponentSpringStage.java:235)
at com.atlassian.plugin.osgi.factory.transform.stage.HostComponentSpringStage.findUsedHostComponents(HostComponentSpringStage.java:220)

I don't know if it's the same cause (dependency with jdk8) but the same plugin with the same dependency at a previous version works fine, but from one version up, it fails.

Ulrich Hobelmann [catworkx]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 29, 2019

Sorry, that doesn't look familiar. I'm not sure what a HostComponentSpringStage is. Are there exceptions before that? Maybe the NPE is because some classes were not found (if your OSGi doesn't include everything you need)? Otherwise, no idea.

Frédéric Esnault May 29, 2019

Nope no other exception.

Before I had a different exception with AMPS 6, which directed to a BND problem with JDK 8 (lambdas), but with AMPS 8, I just have this NPE.

Maybe if I could find the source code of this HostComponentSpringStage I could try to debug this.

But the imports are the same in both working and failing versions, only the external dependency version changes.

I opened an AMPS support ticket for this, if you want to follow :

https://ecosystem.atlassian.net/browse/AMPS-1500

Frédéric Esnault May 29, 2019

@Ulrich Hobelmann [catworkx]  Thanks a looooot !

Finally got it working.

So what I did is :

  • added the atlassian-plugins dependency to my plugin (as provided) so I could access the HostComponentSpringStage class;
  • download sources of the atlassian-plugins-osgi and attached the source to the class when breakpoint is reached
  • analyzed the nullpointer exception to check what class was causing problem : turned out it was a class called: module-info.class (!)
  • crawled up the call stack to see what jar was being analyzed at this moment : it was log4j.
  • used mvn dependency:tree on my project to see who was bringing log4j with him, and of course it was my dependency (the one for which it was working with one version but not with the latest).
  • modified my pom to exclude log4j from this dependency
  • added log4j dependency to my pom so that there is no class not found error
  • then of course it failed the same, but :
    • added the module-info.class exclusion as you said
    • did not have to add the osgi requirement
  • And voilà, success !

So a huge thanks to you for your (quick) answers, and for pointing me in the right direction !

Frédéric Esnault May 29, 2019

Added a comment on the AMPS issue to let them know where it is in their code.

Ulrich Hobelmann [catworkx]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 30, 2019

Good. So looks like the same problem with a different dependency and in your case in a different component (I didn't use Spring scanner in the plugin, maybe that's why?). Hope Atlassian upgrades all their components asap to be able to process jars from newer Java versions.

0 votes
Bernard Jaquet October 12, 2015

As far I can tell only lambda expressions are impacted, other things like streams are working just fine on JIRA 6.4.11.

0 votes
Vijay Khacharia
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 11, 2015

Has anyone found the solution? I am on jira 6.4.11, almost latest version and still have the same issue.

0 votes
pkozlov September 20, 2015

No, I didn't.

0 votes
firelord September 20, 2015

Have you solved this problem?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events