I'm experimenting with writing an openHab2 binding which is written in java. I'm a C++ guy and java is new to me. The offending code looks like this:
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
...
@Override
public void initialize() {
...
CredentialsProvider credsProvider = new BasicCredentialsProvider();
...
}
I added org.apache.httpcomponents.htpclient_4.5.2.v20170210-0925.jar to the buildpath as an external jar and the program builds without any problems. This project uses Maven, which I'm not familiar with either, as the build system so I added:
<dependencies>
<dependency>
<groupId>org.apache.httpcomponent</groupId>
<artifactId>httpclient</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
to the pom.xml.
When I run the system I get this error:
2018-05-20 09:51:38.574 [ERROR] [.i.c.AbstractInvocationHandler:101 ] - An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.testbinging.internal.TestBingingHandler@728656fc': org/apache/http/impl/client/BasicCredentialsProviderjava.lang.NoClassDefFoundError: org/apache/http/impl/client/BasicCredentialsProvider at org.openhab.binding.testbinging.internal.TestBingingHandler.initialize(TestBingingHandler.java:63)
2018-05-20 09:51:38.576 [ERROR] [.c.thing.internal.ThingManager:700 ] - Exception occurred while initializing handler of thing 'testbinging:sample:0ac3dcf3': org/apache/http/impl/client/BasicCredentialsProviderjava.lang.NoClassDefFoundError: org/apache/http/impl/client/BasicCredentialsProvider
It look to my untrained eye like the runtime classpath is not set correctly.
I'm using eclipse-oxygen version Oxygen.3a Release(4.7.3a), Build id: 20181405.1200 and $ mvn -version Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.8.0_171, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Thanks, Steve Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.9.0-5-amd64", arch: "amd64", family: "unix"