0

I have a large Java application that's mostly networking and file processing with lots of DB access. There's no UI. We expose a few web services (embedded Netty) and call some external rest web services. The project is built with Ant. It's about 10 different jars plus maybe 30-40 libraries.

My current task is to move the project to the OSGi framework. I am startling slowly.

Following the examples in "OSGi In Action" chapter 6, I have used the BND ant task to put the entire project into one huge jar file. This worked. I am able to run the program using java -jar. Here's my current .bnd file:

-output: bundle/MerchantServicesBundle.jar
-include: manifest/merchantservices.manifest
Bundle-Name: MerchantServices
Bundle-SymbolicName: com.shopping.services.merchant
Bundle-Version: 4.1
Main-Class: com.shopping.merchant.services.netty.MerchantServices
Class-Path: /home/ppantera/repositories/MerchantJava/modules/MerchantServices/conf/

Private-Package: *

I am using Apache Felix 4.0.3. From the Gogo shell I can install the bundle but when I start it I get this:

org.osgi.framework.BundleException: Unresolved constraint in bundle com.shopping.services.merchant [8]: Unable to resolve 8.0: missing requirement [8.0] osgi.wiring.package; (osgi.wiring.package=android.dalvik)

Why does Felix think this is an Android project?

There doesn't seem to be much about this on the 'net. Would you recommend using an older version of Felix so I'm sheltered from the newer OSGi features that could cause me confusion?

I tried adding this to my .bnd file:

Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version>=1.7))"

That didn't help. What am I doing wrong? Any other pointers?

René Höhle
  • 26,716
  • 22
  • 73
  • 82
ppantera
  • 11
  • 1

2 Answers2

2

It looks like somehow bnd detected a requirement to an Android package, and added that to the MANIFEST.MF, it could be in your code, but could also be in one of your 3rd party libraries.

Check your manifest to be sure, I guess you'll find something like

Import-Package:android.dalvik. 

If that's the case you can test the bundle by manually removing that header and see if that helps. When you've got that clear, you can resolve it for example by making that import optional in bnd.

Frank Lee
  • 2,728
  • 19
  • 30
  • +1. Felix thinks this is an Android project because your bundle manifest says it's an Android project! Another suggestion would be to avoid `Private-Package: *` since that literally sucks *everything* bnd can see on the classpath into the bundle. At least limit it to within a namespace such as `com.foo.myapplication.*`. – Neil Bartlett Feb 15 '13 at 01:12
  • Also: no, don't use an older version of Felix, they will all report the same problem. The issue is not with Felix, it's with the way the bundle has been built. – Neil Bartlett Feb 15 '13 at 01:14
0

One of easy solution is:

Go to FuseESB console:

Type the command:

osgi:install mvn:commons-io/commons-io/2.1

Replace 'common's-io' with your your dependency's group id and artifact id (Maven) e.g my dependency was:

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.1</version>
    <scope>provided</scope>
</dependency>

Cheers