I have been experimenting with binding development and I’m getting this error:
Caused by: java.lang.ClassNotFoundException:
org.apache.http.client.ClientProtocolException cannot be found by org.openhab.binding.
I know why I’m getting a ClientProtocolException (testing an error path) but I don’t know why java can’t find the class.
I’m new to java and only somewhat familiar with Eclipse. I think it’s just a configuration issue but I’m not able to find it.
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:
Well it tool me a week (seems longer) but I’ve figured out one way to do it. I doubt its the best way but until I get a better answer, it will have to do.
It seems that even though openHAB is a Maven project, it doesn’t use Maven to build so I wasted a lot of time trying to add dependencies to the pom.
In the end I found another binding had created a directory under the main binding folder. I created a folder, copied the jars needed into that directory, added that directory to the build.properties file in the “bin.includes:” list, add the jars to the MANIFEST.MF file under “Bundle-Classpath:” entry and finally add the jars to the build path,.
Not exactly intuitive. I’m not going to mark this as solved because I am holding out hope that someone will tell me the openHAB way to do this.