Java 8 features are not supported in wired tests

osgi-test-runner

#1

Hello!

I created an empty Jira plugin project using atlas-create-jira-plugin command from the Atlassian Plugin SDK. I run then atlas-integration-test and everything works fine. Then I add just 2 lines to MyComponentWiredTest class:

import java.util.function.Supplier;
...
Supplier s = this::toString;

Then I run atlas-integration-test again and this time get BUILD FAILURE. Cause:

com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.atlassian-plugins-osgi-testrunner-bundle
	at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418)
	at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:287)
	at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130)
	at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107)
	at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1248)
	at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1218)
	at com.atlassian.jira.plugin.JiraPluginManager.addPlugins(JiraPluginManager.java:153)
	at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:597)
	at com.atlassian.jira.plugin.JiraPluginManager.earlyStartup(JiraPluginManager.java:119)
	at com.atlassian.jira.ComponentManager$PluginSystem.earlyStartup(ComponentManager.java:641)
	at com.atlassian.jira.ComponentManager.quickStart(ComponentManager.java:196)
	at com.atlassian.jira.ComponentManager.start(ComponentManager.java:165)
	at com.atlassian.jira.upgrade.PluginSystemLauncher.start(PluginSystemLauncher.java:47)
	at com.atlassian.jira.startup.DefaultJiraLauncher.lambda$postDbLaunch$2(DefaultJiraLauncher.java:154)
	at com.atlassian.jira.startup.DefaultJiraLauncher$$Lambda$70/1956872054.run(Unknown Source)
	at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrEnqueue(DatabaseConfigurationManagerImpl.java:304)
	at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrWhenDatabaseActivated(DatabaseConfigurationManagerImpl.java:199)
	at com.atlassian.jira.startup.DefaultJiraLauncher.postDbLaunch(DefaultJiraLauncher.java:146)
	at com.atlassian.jira.startup.DefaultJiraLauncher.lambda$start$0(DefaultJiraLauncher.java:105)
	at com.atlassian.jira.startup.DefaultJiraLauncher$$Lambda$15/1147552338.run(Unknown Source)
	at com.atlassian.jira.util.devspeed.JiraDevSpeedTimer.run(JiraDevSpeedTimer.java:31)
	at com.atlassian.jira.startup.DefaultJiraLauncher.start(DefaultJiraLauncher.java:103)
	at com.atlassian.jira.startup.LauncherContextListener.initSlowStuff(LauncherContextListener.java:160)
	at com.atlassian.jira.startup.LauncherContextListener.initSlowStuffInBackground(LauncherContextListener.java:145)
	at com.atlassian.jira.startup.LauncherContextListener.contextInitialized(LauncherContextListener.java:105)
	... 8 filtered
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	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: org.osgi.framework.BundleException: Activator start error in bundle com.atlassian.plugins.atlassian-plugins-osgi-testrunner-bundle [125].
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2196)
	at org.apache.felix.framework.Felix.startBundle(Felix.java:2064)
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955)
	at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942)
	at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 15912
	at org.objectweb.asm.ClassReader.readClass(Unknown Source)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at org.objectweb.asm.ClassReader.accept(Unknown Source)
	at com.atlassian.plugins.osgi.test.asm.BundleTestScanner.processUrl(BundleTestScanner.java:46)
	at com.atlassian.plugins.osgi.test.asm.BundleTestScanner.scan(BundleTestScanner.java:32)
	at com.atlassian.plugins.osgi.test.BundleTestClassesActivator.addBundle(BundleTestClassesActivator.java:94)
	at com.atlassian.plugins.osgi.test.BundleTestClassesActivator.start(BundleTestClassesActivator.java:68)
	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
	at org.apache.felix.framework.Felix.activateBundle(Felix.java:2146)

I’d like to attract attention of the Atlassian test runner team. It is a bug in their component. Although I specified Java 8 level for sources and target and have JDK 8 installed I cannot use Java 8 in wired tests. Please fix it.

My environment:
Windows 8.1
Atlassian Plugin SDK 6.3.7
jdk1.8.0_51
APMS 6.3.14
Jira 7.6.1
atlassian-plugins-osgi-testrunner 1.2.3
maven.compiler.source 1.8
maven.compiler.target 1.8


#2

hi @efulmo have you found a solution for this? I am getting the same Error but have not added one line of code. I am compiling again JIRA 8.0.0-m004 and with JIRA 7 i never got this message.


#3

Hello @clouless. It appeared that development version of Jira that is started from the plugin folder contains too old version of JUnit. To fix that I had to add the following to the AMPS configuration

                    <!-- Required to make testrunner work -->
                    <bundledArtifacts>
                        <libArtifact>
                            <groupId>org.apache.servicemix.bundles</groupId>
                            <artifactId>org.apache.servicemix.bundles.junit</artifactId>
                            <version>4.12_1</version>
                        </libArtifact>
                    </bundledArtifacts>

#4

Hi @efulmo I too found a solution. There are many incompatible versions. As you said Junit is newer and also if using ActiveObjects also a newer version has to be used.

I cannot quite remember what exactly fixed it but it was some kind of mixup of dependencies.

For JIRA 7.x and 8.x I ended up with these TEST dependencies:

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-integration</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>2.0.0-beta.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito2</artifactId>
            <version>2.0.0-beta.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.openpojo</groupId>
            <artifactId>openpojo</artifactId>
            <version>0.8.6</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.23.0</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>