OSGI number imports restriction
Asked Answered
B

3

9

I'm building an OSGI base application, in one of my classes I do an important number of imports ( arround 30 ) and when i launch the app i get this exception :

java.lang.ArrayIndexOutOfBoundsException: 18
    at aQute.lib.osgi.Clazz.parseClassFile(Clazz.java:130)
    at aQute.lib.osgi.Clazz.<init>(Clazz.java:65)
    at aQute.lib.osgi.Processor.analyzeJar(Processor.java:159)
    at aQute.lib.osgi.Processor.analyzeBundleClasspath(Processor.java:77)
    at aQute.lib.osgi.Analyzer.analyze(Analyzer.java:194)
    at aQute.lib.osgi.Builder.analyze(Builder.java:95)
    at aQute.lib.osgi.Analyzer.calcManifest(Analyzer.java:293)
    at aQute.lib.osgi.Builder.build(Builder.java:45)
    at org.apache.felix.bundleplugin.BundlePlugin.buildOSGiBundle(BundlePlug...

when i comment the code and reduce the number of imports everything goes fine.

It seems like an OSGI restriction, how can I fixe this?

Thanks,

Bradytelic answered 19/2, 2015 at 13:14 Comment(0)
C
11

I've encountered same behavior when i use maven-bundle-plugin of version 2.3.7. But when i've upgraded version to 3.0.1 it disappears (i think any newer version also should fit).

So, try to upgrade version of used maven-bundle-plugin to latest one.

Hope it helps.

Constrain answered 19/4, 2016 at 13:10 Comment(1)
I wish I could upvote this answer more than once, but I can't. I also wish I could mark it as the correct answer on behalf of the original poster (@user1828433), but I can't.Sexual
D
2

A quick search showed the following issues:

https://issues.apache.org/jira/browse/FELIX-4556

https://issues.apache.org/jira/browse/FELIX-4005

I guess you're experiencing one of those for some reason.

According to Stuart McCulloch, as a workaround until the next plugin release is available you can upgrade the version of bnd used locally in your project:

  <plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.5.3</version>
    <dependencies>
      <dependency>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bndlib</artifactId>
        <version>2.4.0</version>
      </dependency>
    </dependencies>
  <plugin>
Dematerialize answered 19/2, 2015 at 15:17 Comment(0)
P
0

I had a similar problem and i fixed it by upgrading the version of the maven-bundle-plugin to 3.0.1. thank you nndru

Plainsong answered 14/3, 2019 at 22:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.