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
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