1
votes

Preface

I'm using Karaf to deploy some Camel routes. I'm currently using the deploy folder for that. My issue is that Karaf takes a very long time to start up the first time with the contents in my deploy folder, which I will list shortly. Without these contents, the startup is pretty fast. On subsequent starts, the error doesn't appear. I start Karaf via karaf.sh with debugging enabled.

Versions

  • JDK: AdoptOpenJdk/OpenJDK8
  • Karaf Version: 4.2.6
  • Camel Version: 3.0.0-M1
  • Target of my beans: Java 1.8

Provisioning

I'm using these files for provisioning.

org.apache.karaf.features.cfg:

featuresRepositories = \
    mvn:org.apache.karaf.features/standard/4.2.6/xml/features, \
    mvn:org.apache.karaf.features/framework/4.2.6/xml/features, \
    mvn:org.apache.karaf.features/enterprise/4.2.6/xml/features, \
    mvn:org.apache.karaf.features/spring/4.2.6/xml/features, \
    mvn:org.apache.camel.karaf/apache-camel/3.0.0-M1/xml/features, \
    mvn:org.apache.activemq/activemq-karaf/5.15.9/xml/features

featuresBoot = \
    (wrap)/2.6.1, \
    instance/4.2.6, \
    package/4.2.6, \
    log/4.2.6, \
    ssh/4.2.6, \
    framework/4.2.6, \
    system/4.2.6, \
    eventadmin/4.2.6, \
    feature/4.2.6, \
    shell/4.2.6, \
    management/4.2.6, \
    service/4.2.6, \
    jaas/4.2.6, \
    deployer/4.2.6, \
    diagnostic/4.2.6, \
    bundle/4.2.6, \
    config/4.2.6, \
    kar/4.2.6, \
    http-whiteboard/4.2.6, \
    http/4.2.6, \
    war/4.2.6 , \
    camel/3.0.0-M1, \
    camel-core/3.0.0-M1, \
    camel-groovy/3.0.0-M1, \
    camel-jackson/3.0.0-M1, \
    camel-jms/3.0.0-M1, \
    camel-jsonpath/3.0.0-M1, \
    camel-jetty9/3.0.0-M1, \
    camel-rest-swagger/3.0.0-M1, \
    camel-swagger-java/3.0.0-M1, \
    camel-http4/3.0.0-M1, \
    camel-mongodb3/3.0.0-M1, \
    camel-netty4/3.0.0-M1, \
    activemq-broker/5.15.9

org.apache.karaf.features.xml:

<blacklistedRepositories>
        <repository>mvn:org.apache.karaf.features/framework/4.3.0-SNAPSHOT/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/standard/4.3.0-SNAPSHOT/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/standard/4.2.1-SNAPSHOT/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/standard/4.2.1/xml/features</repository>
        <repository>mvn:org.ops4j.pax.web/pax-web-features/7.2.3/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/enterprise/4.3.0-SNAPSHOT/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/enterprise-legacy/4.3.0-SNAPSHOT/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/spring/4.3.0-SNAPSHOT/xml/features</repository>
        <repository>mvn:org.apache.karaf.features/spring-legacy/4.3.0-SNAPSHOT/xml/features</repository>
</blacklistedRepositories>

My deploy folder currently has these contents:

  • A JAR file with camel beans (23KB)
  • A KAR file with its dependencies (2.7MB)
  • A blueprint file in which I use the above camel beans (15KB)

I also get this error when I try to start Karaf, this actually appears a second time directly following the first:

java.lang.ArrayIndexOutOfBoundsException: 19
     at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:576)
     at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:494)
     at aQute.bnd.osgi.Clazz.parseClassFileWithCollector(Clazz.java:483)
     at aQute.bnd.osgi.Clazz.parseClassFile(Clazz.java:473)
     at aQute.bnd.osgi.Analyzer.analyzeJar(Analyzer.java:2177)
     at aQute.bnd.osgi.Analyzer.analyzeBundleClasspath(Analyzer.java:2083)
     at aQute.bnd.osgi.Analyzer.analyze(Analyzer.java:138)
     at aQute.bnd.osgi.Analyzer.calcManifest(Analyzer.java:616)
     at org.ops4j.pax.swissbox.bnd.BndUtils.createBundle(BndUtils.java:161)
     at org.ops4j.pax.url.wrap.internal.Connection.getInputStream(Connection.java:83)
     at java.net.URL.openStream(URL.java:1057)
     at org.apache.karaf.features.internal.download.impl.SimpleDownloadTask.download(SimpleDownloadTask.java:77)
     at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:60)
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
     at java.lang.Thread.run(Thread.java:748)

What I did so far

  • Reinstall Karaf
  • I upgraded to this version of Karaf
  • I tried installing OpenJDK9, 11
  • I analyzed my transitive dependencies and found that some of them target Java 1.9

The error stays. Karaf and my Camel routes work correctly after Karaf is started, I just don't like seeing this error. Would it make sense for my camel application to target 1.9? Upgrading would be a huge process, maybe you can see something from the things I've provided before I go about requesting to target 1.9.

1

1 Answers

2
votes

Most likely there is an attempt to install one (or more) jar file which is Java 9+ module and not an OSGi bundle. In this case Karaf tries to wrap it to dynamically make a bundle out of it. The wrapping logic uses bnd to analyze the jar file. It probably depends on older version of bnd which fails because it can not parse a Java 9+ class (most likely the newly introduced module-info.class).

To find which bundles are wrapped you can run bundle:list -t 0 -u | grep "wrap:" command in Karaf.

Some ways to solve the problem are:

  • don't wrap Java 9+ module. Use an older version of the library
  • wrap the module(s) manually before deploying using the newest bnd
  • contact the OPS4J Pax URL team and ask if there is newer version that can wrap Java 9+ modules (perhaps by depending on newer bnd version)

UPDATE:

Looks like the Apache Karaf Community is fixing this in https://issues.apache.org/jira/browse/KARAF-6988 . So you should be able to get around it by upgrading to a version of Karaf mentioned in the JIRA.