Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSGI number imports restriction

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,

like image 351
user1828433 Avatar asked Feb 19 '15 13:02

user1828433


2 Answers

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.

like image 98
nndru Avatar answered Oct 12 '22 18:10

nndru


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>
like image 35
Puce Avatar answered Oct 12 '22 17:10

Puce