spring-bootosgiapache-karafosgi-bundlemaven-bundle-plugin

OSGi Karaf Spring Boot 2.1.4-Release Error


I am trying to build an OSGi Karaf app using Spring Boot 2.1.4 with Java 8, OSGi version 5.0.0 and Apache Karaf 4.1.3.

I have created the following project in GitHub which builds and runs fine when I use Spring Boot 1.5.9.

But when I change the Spring boot version from 1.5.9-RELEASE to 2.1.4-RELEASE and trying to do mvn clean install then I get the following errors from the maven-bundle-plugin

[WARNING] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Export com.nemesis.osgi.springboot,  has 4,  private references [com.nemesis.osgi.springboot.controller, org.springframework.context.annotation, org.springframework.boot, org.springframework.boot.autoconfigure], 
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Exception: java.lang.ArrayIndexOutOfBoundsException: 19
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Invalid class file META-INF/versions/9/module-info.class (java.lang.ArrayIndexOutOfBoundsException: 19)
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Classes found in the wrong directory: {META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class=org.apache.logging.log4j.util.StackLocator, META-INF/versions/9/org/apache/logging/log4j/util/internal/DefaultObjectInputFilter.class=org.apache.logging.log4j.util.internal.DefaultObjectInputFilter, META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class=org.apache.logging.log4j.util.ProcessIdUtil}
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Exception: java.lang.ArrayIndexOutOfBoundsException: 19
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Invalid class file module-info.class (java.lang.ArrayIndexOutOfBoundsException: 19)
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Exception: java.lang.ArrayIndexOutOfBoundsException: 19
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Exception: java.lang.ArrayIndexOutOfBoundsException: 19
[ERROR] Bundle com.nemesis:osgi-spring-boot-demo-bundle:bundle:0.0.1-SNAPSHOT : Exception: java.lang.ArrayIndexOutOfBoundsException: 19

Any help is much appreciated.


Solution

  • I think the error is because the new spring boot bundles or dependencies are multi release jars that the maven bundle plugin version 3.3.0 can not yet handle. Updating the maven bundle plugin version to 4.1.0 fixed the issue for me.

    See this PR.