1
votes

I am trying to use the Apache Commons JCI library in an OSGi Bundle being built by maven. I install the bundle on Apache Felix and everything looks fine until I try to start my Component which is when I get the error below. My pom.xml looks like:

<Embed-Dependency>jtidy;scope=compile|runtime;inline=false</Embed-Dependency>
<Embed-Directory>target/dependency</Embed-Directory>
<Embed-StripGroup>true</Embed-StripGroup>

<Export-Package>
    ${project.artifactId}.*;version=${project.version},
    org.apache.jsp.apps.*;version=${project.version}
</Export-Package>                        

<Import-Package>*;resolution:=optional</Import-Package>
<Private-Package></Private-Package>

<Include-Resource>
    {maven-resources},
    {maven-dependencies},
    src/main/scripts
</Include-Resource>

And i simply have a dependency on:

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-jci-core</artifactId>
        <version>1.0</version>
    </dependency>

I've tried explicitly adding the commons-jci-core to the Embed-Dependency and Import-Pacakage directives to no avail. Any ideas how I get embed this dependency so my bundle can see it?

Here is the error im receiving:

18.04.2012 22:08:01.328 *ERROR* [FelixPackageAdmin] com.activecq.tools [com.activecq.tools.services.impl.VaultSyncImpl] Error during instantiation of the implementation object (java.lang.NoClassDefFoundError: org/apache/commons/jci/monitor/FilesystemAlterationListener) java.lang.NoClassDefFoundError: org/apache/commons/jci/monitor/FilesystemAlterationListener
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:183)
    at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:118)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:997)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:333)
    at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:157)
    at org.apache.felix.scr.impl.config.ConfiguredComponentHolder.enableComponents(ConfiguredComponentHolder.java:262)
    at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:253)
    at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:147)
    at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:111)
    at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:285)
    at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:203)
    at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)
    at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
    at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3724)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1772)
    at org.apache.felix.framework.Felix$RefreshHelper.restart(Felix.java:4498)
    at org.apache.felix.framework.Felix.refreshPackages(Felix.java:3554)
    at org.apache.felix.framework.PackageAdminImpl.run(PackageAdminImpl.java:336)
    at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.jci.monitor.FilesystemAlterationListener not found by com.activecq.tools [170]
    at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:787)
    at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
    at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 25 more
1

1 Answers

2
votes

It turns out i need to embed:

<Embed-Dependency>
    commons-jci-fam;scope=compile|runtime;inline=false,
    commons-jci-core;scope=compile|runtime;inline=false
</Embed-Dependency>

FilesystemAlterationListener is in the fam project and the core project is needed for other dependencies.