As I said, I think that this is a configuration issue and not a code issue. To narrow this down, I created a new binding called TestBinging (sp! argh!!) using the ./create_openhab_binding_skeleton.sh script, then imported it.
Next I added one line to the initialize function and 2 imports
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
…
@Override
public void initialize() {
config = getConfigAs(TestBingingConfiguration.class);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
updateStatus(ThingStatus.ONLINE);
}
Then I added org.apache.httpcomponents.httpclient_4.5.2.v20170210-0925.jar to the buildpath as an external archive. Now the project builds OK.
Now, and this is where I think I’m going wrong, I added a runtime dependency on hhttpclient to the POM which now looks like this:
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>pom</artifactId>
<groupId>org.openhab.binding</groupId>
<version>2.3.0-SNAPSHOT</version>
</parent>
<artifactId>org.openhab.binding.testbinging</artifactId>
<packaging>eclipse-plugin</packaging>
<name>TestBinging Binding</name>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponent</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
Next I update the run configuration to add my new binding. I’m testing with PaperUI and when I add a TestBinding thing I get this error:
2018-05-19 12:59:09.570 [ERROR] [.i.c.AbstractInvocationHandler:101 ] - An error occurred while calling method ‘ThingHandler.initialize()’ on ‘org.openhab.binding.testbinging.internal.TestBingingHandler@3bf6a8bb’: org/apache/http/impl/client/BasicCredentialsProviderjava.lang.NoClassDefFoundError: org/apache/http/impl/client/BasicCredentialsProvider
so it looks like the runtime does not know where to get the httpclient jars.
Thansk,
Steve