Hi again,

Yes I embed all the content of both jars inside the bundle (you can notice I did not put <scope>provided</scope> on dependancies). I tried to do other stuff with separate (bundlelized) jars. But it is impossible with this split package, because your application bundle will try to bind to derby and derbynet. But in OSGi, a package cannot be bound from two bundles.

What I did is a bit dirty (I don't like writting my own import instructions, I prefer let bnd do its magic) but I think it is the best solution so far. Btw, I wrote the same activator :)


On Thu, May 5, 2011 at 11:23 AM, Christian Schneider <chris@die-schneider.net> wrote:
Hi Loic,

Thanks for the fast reply. I have also seen that there are split packages and think this is a problem.
I hope the derby team can fix that in one of the next releases.

Do you package the derby jars inside your own jar? I would like to have a solution that works with the derby jars as bundles but in case that is not possible I can also put the derby jars inside my own jar.


Am 05.05.2011 11:15, schrieb Loic Petit:
Hi Christian,

I did succeed on deploying a network server bundle on OSGi.
To build it I did the following things,

In the maven I just include


And in the building process I put :

                            org.w3c.dom, org.xml.sax,
                        <Export-Package>org.apache.derby.jdbc, org.apache.derby.drda</Export-Package>
                        <Private-Package>org.apache.derby.*;-split-package:=merge-first, YOUR_PACKAGES</Private-Package>

The trick is two fold. Firstly, some imports are optional like the xalan serializing process etc... But the main problem is that some packages are split in the jar derby and derby net. No you have to do merge-first strategies.
By the way, it is a bit weird to have split packages in the derby distribution.

Hope this helps :)


On Thu, May 5, 2011 at 11:03 AM, Christian Schneider <chris@die-schneider.net> wrote:
Hi All,

I have problems running derby with network connector in an OSGi environment.

I created my own bundle for the starter and use an Activator to start derby (see below).
I have also attached to Manifest of my bundle. Probably there are more imports missing but this is as far as I got.

To install all this I use Karaf and a feature file (see below).

The derby jar seems to bea bundle already so I simply install it from maven. The derbynet jar is no bundle so I use the wrap syntax of Karaf so a Manifest is created for it on the fly.

So the problem is that when I install a bundle I get a non resolvable import
Error executing command: The bundle "derby-starter_4.1.0.SNAPSHOT [159]" could not be resolved. Reason: Missing Constraint: Import-Package: org.apache.derby.iapi.tools.i18n; version="0.0.0"

The package is in the bundle derby but it is not exported.

So I think either that export and perhaps some more is missing or I am doing something wrong.

Can anyone help me with this?

If you want to test this yourself I can provide a complete maven project and some instructions.


Feature file for Karaf

<feature name='tesb-derby-starter' version='4.1-SNAPSHOT'>

Starter class
package org.talend.esb.derby.starter;

import java.net.InetAddress;

import org.apache.derby.drda.NetworkServerControl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class NetworkActivator implements BundleActivator {
    NetworkServerControl server;

    public void start(BundleContext context) throws Exception {
        server = new NetworkServerControl(InetAddress.getByName("localhost"),1527);

    public void stop(BundleContext context) throws Exception {


Manifest of starter bundle
Manifest-Version: 1.0
Export-Package: org.talend.esb.derby.starter;uses:="org.apache.derby.d
Built-By: chris
Tool: Bnd-1.15.0
Bundle-Name: Service Activity Monitoring :: Derby Starter
Created-By: Apache Maven Bundle Plugin
Bundle-Vendor: Talend Inc.
Build-Jdk: 1.6.0_20
Bundle-Version: 4.1.0.SNAPSHOT
Bnd-LastModified: 1304585222883
Bundle-Activator: org.talend.esb.derby.starter.NetworkActivator
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-DocURL: www.talend.com
Bundle-SymbolicName: derby-starter
Import-Package: org.apache.derby.drda,org.apache.derby.iapi.tools.i18n

Christian Schneider

CXF and Camel Architect

Christian Schneider

CXF and Camel Architect