You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Kari Pahula <ka...@avoltus.com> on 2015/09/30 09:02:57 UTC

Using a dependency in my bundle and NoClassDefFoundError

Hi.

I've run into trouble trying to use a dependency with my bundle,
namely opencsv. I added the dependency to my pom.xml and built my
bundle with mvn package and copied the jar file to karaf's deploy.

My bundle wouldn't start due to unresolved requirements. First it
wanted to have com.opencsv.enums, which I resolved with bundle:install
wrap:mvn:com.opencsv/opencsv. Next it wanted to have
org.apache.commons.lang3, which was resolved with bundle:install
wrap:mvn:org.apache.commons/commons-lang3.

After this, my bundle would start but fail, since I get a
NoClassDefFoundError at runtime from opencsv, where it tries to use
apache commons' StringUtils.

How could I get to opencsv successfully use commons? Anything else I
should tell about my scenario?

Re: Using a dependency in my bundle and NoClassDefFoundError

Posted by Paul Spencer <pa...@apache.org>.
Kari,
Please use the command bundle:headers to verify the which packages are imported and exported.

As to org.apache.commons.lang3, you may not need to wrap the jar when installing.  Try the to install without the wrap:
  bundle:install mvn:org.apache.commons/commons-lang3.

bundle:headers for Commons Lang 3 outputs the following:
karaf@root()> headers 124

Commons Lang (124)
------------------
Specification-Title = Commons Lang
Archiver-Version = Plexus Archiver
Tool = Bnd-1.15.0
Specification-Version = 3.1
Specification-Vendor = The Apache Software Foundation
Implementation-Version = 3.1
Build-Jdk = 1.5.0_22
Implementation-Vendor-Id = org.apache
Created-By = Apache Maven Bundle Plugin
Implementation-Title = Commons Lang
Manifest-Version = 1.0
Implementation-Build = UNKNOWN_BRANCH@r??????; 2011-11-09 22:58:07-0800
Bnd-LastModified = 1320908300777
X-Compile-Target-JDK = 1.5
Include-Resource = templates/release-notes.vm=src/main/resources/templates/release-notes.vm,META-INF/LICENSE.txt=LICENSE.txt,META-INF/NOTICE.txt=NOTICE.txt
Built-By = hen
X-Compile-Source-JDK = 1.5
Implementation-Vendor = The Apache Software Foundation

Bundle-Vendor = The Apache Software Foundation
Bundle-Name = Commons Lang
Bundle-DocURL = http://commons.apache.org/lang/
Bundle-Description = Commons Lang, a package of Java utility classes for the  classes that are in java.lang's hierarchy, or are considered to be so  standard as to justify existence in java.lang.
Bundle-SymbolicName = org.apache.commons.lang3
Bundle-Version = 3.1.0
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2

Private-Package = 
	templates
Export-Package = 
	org.apache.commons.lang3.event;version=3.1,
	org.apache.commons.lang3.mutable;version=3.1,
	org.apache.commons.lang3.tuple;version=3.1,
	org.apache.commons.lang3.time;version=3.1,
	org.apache.commons.lang3.concurrent;version=3.1,
	org.apache.commons.lang3.text.translate;version=3.1,
	org.apache.commons.lang3.text;version=3.1,
	org.apache.commons.lang3.math;version=3.1,
	org.apache.commons.lang3;version=3.1,
	org.apache.commons.lang3.exception;version=3.1,
	org.apache.commons.lang3.reflect;version=3.1,
	org.apache.commons.lang3.builder;version=3.1


karaf@root()> 

> On Sep 30, 2015, at 3:02 AM, Kari Pahula <ka...@avoltus.com> wrote:
> 
> Hi.
> 
> I've run into trouble trying to use a dependency with my bundle,
> namely opencsv. I added the dependency to my pom.xml and built my
> bundle with mvn package and copied the jar file to karaf's deploy.
> 
> My bundle wouldn't start due to unresolved requirements. First it
> wanted to have com.opencsv.enums, which I resolved with bundle:install
> wrap:mvn:com.opencsv/opencsv. Next it wanted to have
> org.apache.commons.lang3, which was resolved with bundle:install
> wrap:mvn:org.apache.commons/commons-lang3.
> 
> After this, my bundle would start but fail, since I get a
> NoClassDefFoundError at runtime from opencsv, where it tries to use
> apache commons' StringUtils.
> 
> How could I get to opencsv successfully use commons? Anything else I
> should tell about my scenario?