0

I am deploying httpclient-4.3.4.jar in deploy folder of karaf. In terminal when I use command find-class HttpClients, nothing is getting listed. When use keyword find-class HttpClient, I get only follwing classes loaded for httpclient bundle. Since some of the classes are missing I am getting java.lang.NoClassDefFoundError: org/apache/http/impl/client/HttpClients in one of my dependent bundles.

I need to know whey some classes are not available. If it is our own bundle, we can specify imports and exports to control the classes which we need to expose. But for external jars, why this is happening?

httpclient (202) org/apache/http/HttpClientConnection.class org/apache/http/client/HttpClient.class org/apache/http/client/params/HttpClientParams.class org/apache/http/client/utils/HttpClientUtils.class org/apache/http/impl/AbstractHttpClientConnection.class org/apache/http/impl/DefaultHttpClientConnection.class org/apache/http/impl/SocketHttpClientConnection.class org/apache/http/impl/client/AbstractHttpClient.class org/apache/http/impl/client/AutoRetryHttpClient.class org/apache/http/impl/client/ContentEncodingHttpClient.class org/apache/http/impl/client/DecompressingHttpClient.class org/apache/http/impl/client/DefaultHttpClient.class org/apache/http/impl/client/SystemDefaultHttpClient.class

om39a
  • 1,406
  • 4
  • 20
  • 39

1 Answers1

2

First, is it a valid OSGi bundle, without the required manifest entries and the right Package-Exports/Imports this won't work. If you just drop it in the deploy folder it might get autowrapped, but this isn't always working. It's better to either take an existing Bundle or do install with:

osgi:install wrap:mvn:groupID/artifactID/version

All of this is also documented in the Karaf User Manual.

The installed bundle can be started with

start ID

where ID is the ID of the bundle just installed.

EDIT:

You definitely need to wrap the bundle in question, since it isn't a OSGi bundle yet. So in your case do:

install wrap:mvn:org.apache.httpcomponents/httpclient/4.3.4

after the bundle is installed:

start ID

If you do a bundle:header after that you'll get a nice header definition. The find class does show the HttpClient class in this bundle:

karaf@root()> find-class HttpClients

wrap_mvn_org.apache.httpcomponents_httpclient_4.3.4 (78)
org/apache/http/impl/client/HttpClients.class
Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22
  • This works fine in my local machine. But when I deploy same jar to server, I get this issue. I tried copying the same karaf folder that I use in my local to the server and I can able to replicate above issue. – om39a Jul 23 '14 at 15:53
  • how did you try to do it? Dropping it at the deploy folder, or installing via shell? What is the log-file saying? – Achim Nierbeck Jul 24 '14 at 07:02
  • I tried dropping the files into deploy folder and also my maven build will post the jars files directly into deploy folder. In either ways, there is no warning or error logs. Every thing seems fine. Even the bundle are started and in active mode. [fyi, local is a mac machine and server is a unix machine] – om39a Jul 24 '14 at 14:52
  • well, to be on the safe side install it via the shell command – Achim Nierbeck Jul 24 '14 at 15:30
  • osgi:install wrap:mvn:groupID/artifactID/version -> This is the shell command you mean here? – om39a Jul 24 '14 at 20:27
  • yep, and after that do a start BundleID, the ID you got back from the install command – Achim Nierbeck Jul 25 '14 at 11:55
  • I did it. But still I am facing same issue. – om39a Jul 27 '14 at 14:39
  • I tried with httpclient-osgi jar in same way you mentioned without a wrap and it worked. – om39a Jul 27 '14 at 23:54