maven-bundle-plugin fails with "Invalid class file module-info.class"
Asked Answered
H

3

15

After adding a dependency that contains a JPMS module, the maven-bundle-plugin (version 3.3.0) fails with:

[INFO] --- maven-bundle-plugin:3.3.0:bundle (default-bundle) @ my-bundle ---
[ERROR] Bundle myGroup:my-bundle:bundle:1.0 : 
        Exception: java.lang.ArrayIndexOutOfBoundsException: 19
[ERROR] Bundle myGroup:my-bundle:bundle:1.0 : 
        Invalid class file module-info.class (java.lang.ArrayIndexOutOfBoundsException: 19)

It seems that the plugin tries (and fails) to analyze the module-info.class, which should be irrelevant in an OSGi context.

Hammering answered 25/5, 2018 at 14:0 Comment(0)
H
30

Upgrading the bundle plugin to version 3.5.0 resolved the issue:

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <version>3.5.0</version>
</plugin>

I also had to upgrade maven to 3.5, since the latest version of the plugin threw a NPE on maven 3.3:

Failed to execute goal org.apache.felix:maven-bundle-plugin:3.5.0:bundle (default-bundle) on project my-bundle: Execution default-bundle of goal org.apache.felix:maven-bundle-plugin:3.5.0:bundle failed. NullPointerException

See also FELIX-5698

UPDATE: Please check for the latest version of the bundle plugin at maven central. The latest version of maven can be found at their download page.

Hammering answered 25/5, 2018 at 14:0 Comment(1)
Thanks.This is great.I am still on Maven 3.3.9 and the maven bundle plugin version 3.5.0 worked on Java 1.8.0_131 when I faced a similar issueDelay
U
2

If you're using IntelliJ, this issue may appear despite your maven configuration being up to date because of this issue: https://youtrack.jetbrains.com/issue/IDEA-194358

The workaround is to turn off the Osmorc plugin

Urchin answered 21/6, 2018 at 14:7 Comment(0)
I
2

I've been having the same issue. After a lot of playing, I found out that it was the uber-jar that was the root cause. YMMV.

Itagaki answered 15/2, 2020 at 19:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.