java.lang.ArrayIndexOutOfBoundsException with maven-bundle-plugin

I am not able to build my plugin due to the following error:

[INFO] --- maven-jira-plugin:6.3.15:generate-manifest (default-generate-manifest) @ wlStmdImport ---                                                                                                                                  [23/260]
[INFO] Generating a manifest for this plugin                                                                                                                                                                                                  
[INFO] using maven-bundle-plugin v2.5.3                                                                                                                                                                                                       
java.lang.ArrayIndexOutOfBoundsException: 19                                                                                                                                                                                                  
        at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:579)                                                                                                                                                                                
        at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:497)                                                                                                                                                                                
        at aQute.bnd.osgi.Clazz.parseClassFileWithCollector(Clazz.java:486)                                                                                                                                                                   
        at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:476)                                                                                                                                                                                
        at aQute.bnd.osgi.Analyzer.analyzeJar(Analyzer.java:2195)                                                                                                                                                                             
        at aQute.bnd.osgi.Analyzer.analyzeBundleClasspath(Analyzer.java:2101)                                                                                                                                                                 
        at aQute.bnd.osgi.Analyzer.analyze(Analyzer.java:139)                                                                                                                                                                                 
        at aQute.bnd.osgi.Builder.analyze(Builder.java:352)                                                                                                                                                                                   
        at aQute.bnd.osgi.Analyzer.calcManifest(Analyzer.java:618)                                                                                                                                                                            
        at org.apache.felix.bundleplugin.ManifestPlugin.getAnalyzer(ManifestPlugin.java:213)                                                                                                                                                  
        at org.apache.felix.bundleplugin.ManifestPlugin.getManifest(ManifestPlugin.java:114)                                                                                                                                                  
        at org.apache.felix.bundleplugin.ManifestPlugin.execute(ManifestPlugin.java:69)                                                                                                                                                       
        at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:294)                                                                                                                                                          
        at org.apache.felix.bundleplugin.BundlePlugin.execute(BundlePlugin.java:285)                                                                                                                                                          
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)                                                                                                                                  
        at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojoImpl(MojoExecutor.java:172)                                                                                                                                                  
        at org.twdata.maven.mojoexecutor.MojoExecutor$ExecutionEnvironmentM3.executeMojo(MojoExecutor.java:476)                                                                                                                               
        at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:75)                                                                                                                                                       
        at com.atlassian.maven.plugins.amps.MavenGoals.generateBundleManifest(MavenGoals.java:1593)                                                                                                                                           
        at com.atlassian.maven.plugins.amps.osgi.GenerateManifestMojo.execute(GenerateManifestMojo.java:65)                                                                                                                                   
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.twdata.maven.trap.Dispatcher.invokeMavenMainMethod(Dispatcher.java:95)
        at org.twdata.maven.trap.Dispatcher.main(Dispatcher.java:30)
        at org.twdata.maven.trap.App.main(App.java:18)
[ERROR] Manifest de.westlotto.jira.plugins.stmd:wlStmdImport:atlassian-plugin:1.0.0-SNAPSHOT : Exception: 19
[ERROR] Manifest de.westlotto.jira.plugins.stmd:wlStmdImport:atlassian-plugin:1.0.0-SNAPSHOT : Invalid class file module-info.class (java.lang.ArrayIndexOutOfBoundsException: 19)
[ERROR] Manifest de.westlotto.jira.plugins.stmd:wlStmdImport:atlassian-plugin:1.0.0-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/9/javax/xml/bind/ModuleUtil.class=javax.xml.bind.ModuleUtil}
[ERROR] Error(s) found in manifest configuration

I am using the Plugin SDK version 6.3.10 and my pom looks like this:

<?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.example.test</groupId>
	<artifactId>DataImport</artifactId>
	<version>1.0.0-SNAPSHOT</version>

	<organization>
		<name>CompanyName</name>
		<url>http://www.company.company</url>
	</organization>

	<name>PluginName</name>
	<description>PluginDescription</description>
	<packaging>atlassian-plugin</packaging>

	<pluginRepositories>
		<pluginRepository>
			<id>central</id>
			<name>Central Repository</name>
			<url>http://repo.maven.apache.org/maven2</url>
			<layout>default</layout>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<releases>
				<updatePolicy>never</updatePolicy>
			</releases>
		</pluginRepository>
	</pluginRepositories>

	<dependencies>
		<dependency>
			<groupId>com.atlassian.jira</groupId>
			<artifactId>jira-api</artifactId>
			<version>${jira.version}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</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>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring-context.version}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>javax.inject</groupId>
			<artifactId>javax.inject</artifactId>
			<version>${javax-inject.version}</version>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>org.glassfish.jersey.core</groupId>
			<artifactId>jersey-client</artifactId>
			<version>${jersey.version}</version>
		</dependency>

		<dependency>
			<groupId>org.glassfish.jersey.media</groupId>
			<artifactId>jersey-media-json-jackson</artifactId>
			<version>${jersey.version}</version>
		</dependency>

		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
			<version>${jaxb.version}</version>
		</dependency>

		<dependency>
			<groupId>com.sun.xml.bind</groupId>
			<artifactId>jaxb-impl</artifactId>
			<version>${jaxb.version}</version>
		</dependency>

		<dependency>
			<groupId>org.glassfish.jaxb</groupId>
			<artifactId>jaxb-runtime</artifactId>
			<version>${jaxb.version}</version>
		</dependency>

		<dependency>
			<groupId>javax.activation</groupId>
			<artifactId>activation</artifactId>
			<version>${javax.activation.version}</version>
		</dependency>

		<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>${jax-ws-rs.version}</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
			<version>${gson.version}</version>
		</dependency>

		<dependency>
			<groupId>com.atlassian.sal</groupId>
			<artifactId>sal-api</artifactId>
			<version>${sal-api.version}</version>
			<scope>provided</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>com.atlassian.maven.plugins</groupId>
				<artifactId>maven-jira-plugin</artifactId>
				<version>${amps.version}</version>
				<extensions>true</extensions>
				<configuration>
					<allowGoogleTracking>false</allowGoogleTracking>
					<productVersion>${jira.version}</productVersion>
					<productDataVersion>${jira.version}</productDataVersion>
					<enableQuickReload>true</enableQuickReload>
					<enableFastdev>false</enableFastdev>
					<instructions>
						<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
						<Export-Package></Export-Package>
						<Import-Package>*</Import-Package>
						<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>
					<allowGoogleTracking>false</allowGoogleTracking>
					<scannedDependencies>
						<dependency>
							<groupId>com.atlassian.plugin</groupId>
							<artifactId>atlassian-spring-scanner-external-jar</artifactId>
						</dependency>
					</scannedDependencies>
					<verbose>true</verbose>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<properties>
		<jira.version>7.10.0</jira.version>
		<amps.version>6.3.15</amps.version>
		<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
		<atlassian.spring.scanner.version>2.1.3</atlassian.spring.scanner.version>
		<maven-bundle-plugin.version>3.5.1</maven-bundle-plugin.version>
		<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
		<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>
		<jersey.version>2.25.1</jersey.version>
		<jaxb.version>2.3.0</jaxb.version>
		<javax.activation.version>1.1.1</javax.activation.version>
		<jax-ws-rs.version>1.1.1</jax-ws-rs.version>
		<gson.version>2.2.2-atlassian-1</gson.version>
		<sal-api.version>2.0.0</sal-api.version>
		<spring-context.version>5.0.8.RELEASE</spring-context.version>
		<javax-inject.version>1</javax-inject.version>
		<junit.version>4.10</junit.version>
	</properties>

</project>

I found several issues with this error online but they all pointed out to update the maven-bundle-plugin to a later version. But how do I do this in this scenario? What do I have to do in order to get the build process working?

I’m still stuck here. Does no one know why this is not working?

It looks like either your app or one of your dependency JARs (de.westlotto.jira.plugins.stmd:wlStmdImport) has been built with Java 9 or newer, while version of bnd tool does not support that yet. I’d look into getting an older version of the corresponding binary or recompiling your code for Java 8, without module-info.

Just a guess, hope it helps.
Igor

1 Like

Thank you, this was exactly my problem. I just didn’t see it. The version of the jaxb lib in my pom.xml was 2.3.0, which is used for Java 9. I changed this to the latest java 8 version 2.2.11 and everything worked as intended. :slight_smile:

1 Like

Great! Happy it helped. :slight_smile:

I have the same exception

During debugging I found possible problem class with following deps:

feign.error.FeignExceptionConstructor
feign.error.ResponseBody;
lombok.Getter;

But I still cannot resolve this problem.

I had the same issue, and for me it was lombok. Try use an older version of lombok for me 1.16.16 worked, I guess that jar doesn’t contain a module-info.class.

It seems that even though lombok is only used during compile time, it messes up the manifest generation, another solution might be to somehow exclude lombok from the generate-manifest part