Javax.measurement not found

I have downloaded the openHAB IDE following this guide: https://www.openhab.org/docs/developer/development/ide.html#installation

It all worked as described. However, now, I am trying to install org.openhab.action.xmpp and I receive the error message below about an unresolvable dependency to javax.measure. My understanding is, that this is a new dependency in V2.3 of openHAB. Is there anything missing in the parent pom org.openhab.bundles 1.13.0-SNAPSHOT? Am I missing something? Any hints would be greatly appreciated.

All the best, Florian.

C:\Users\Florian\openhab2-master\git\openhab1-addons\bundles\action\org.openhab.action.xmpp>mvn install
[INFO] Scanning for projects…
[INFO] Computing target platform for MavenProject: org.openhab.action:org.openhab.action.xmpp:1.13.0-SNAPSHOT @ C:\Users\Florian\openhab2-master\git\openhab1-addons\bundles\action\org.openhab.action.xmpp\pom.xml
[INFO] Fetching p2.index from https://openhab.jfrog.io/openhab/eclipse-smarthome-stable/ (172B)
[INFO] Adding repository https://openhab.jfrog.io/openhab/eclipse-smarthome-stable
[INFO] Adding repository https://dl.bintray.com/openhab/p2/openhab-core/2.0.0
[INFO] Adding repository https://dl.bintray.com/openhab/p2/openhab-deps-repo/1.0.12
[INFO] Resolving dependencies of MavenProject: org.openhab.action:org.openhab.action.xmpp:1.13.0-SNAPSHOT @ C:\Users\Florian\openhab2-master\git\openhab1-addons\bundles\action\org.openhab.action.xmpp\pom.xml
[INFO] {osgi.os=linux, osgi.ws=gtk, org.eclipse.update.install.features=true, osgi.arch=x86}
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: org.openhab.action.xmpp 1.13.0.qualifier
[ERROR] Missing requirement: org.eclipse.smarthome.core 0.10.0.201805241348 requires ‘package javax.measure 0.0.0’ but it could not be found
[ERROR] Missing requirement: org.eclipse.smarthome.core 0.10.0.201805310852 requires ‘package javax.measure 0.0.0’ but it could not be found
[ERROR] Cannot satisfy dependency: org.eclipse.smarthome.config.core 0.10.0.201805241348 depends on: package org.eclipse.smarthome.core.common 0.0.0
[ERROR] Cannot satisfy dependency: org.eclipse.smarthome.config.core 0.10.0.201805310852 depends on: package org.eclipse.smarthome.core.common 0.0.0
[ERROR] Cannot satisfy dependency: org.openhab.action.xmpp 1.13.0.qualifier depends on: package org.openhab.core.items 0.0.0
[ERROR] Cannot satisfy dependency: org.openhab.core.compat1x 2.0.0 depends on: package org.eclipse.smarthome.config.core 0.0.0
[ERROR]
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
[ERROR] Cannot resolve dependencies of MavenProject: org.openhab.action:org.openhab.action.xmpp:1.13.0-SNAPSHOT @ C:\Users\Florian\openhab2-master\git\openhab1-addons\bundles\action\org.openhab.action.xmpp\pom.xml: See log for details -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException

C:\Users\Florian\openhab2-master\git\openhab1-addons\bundles\action\org.openhab.action.xmpp>mvn -v
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-24T20:49:05+01:00)
Maven home: C:\Program Files\apache-maven-3.5.3\bin…
Java version: 1.8.0_172, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_172\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: “windows 10”, version: “10.0”, arch: “amd64”, family: “windows”

I think your issue is that you are building a single project without having first build the parent projects.

So do a quick build without tests of everything in git\openhab1-addons with:

mvn clean install -DskipTests=true

After that you can build the org.openhab.action.xmpp project without first building the parents.

1 Like

Seems, like you killed two birds with one stone. I tried to run maven in the openhab1-addons dirctory first, but it always failed. So, most likely, skipping the tests was the winner!

Super. :slight_smile:

Hopefully upgrading Smack libraries is easy now! I’ve done something similar for a library used by the Logitech Harmony binding where the Smack bugfixes made it a lot more stable:

There were significant API changes regarding the whole Stanza part. Maybe the XMPP action does not use these which makes upgrading less difficult.

The XMPP binding does not use stanzas. However, I stumbled across several other breaking API changes. Some of them were straight forward to recover from, others weren’t. These changes will have significant impact on the code of the plug-in, especially the chat console. I am thinking about creating a unit test project, whichwill insure, that the plugin will work as intended. i.e. I will have to mock an XMPP server. Are there any best pracitices how to implement unit tests and mocks for openHAB?

The tests are made in test bundles. For examples see the following openhab1-addons projects:

./bundles/binding/org.openhab.binding.enigma2.test
./bundles/binding/org.openhab.binding.stiebelheatpump.test
./bundles/binding/org.openhab.binding.s300th.test
./bundles/binding/org.openhab.binding.lightwaverf.test
./bundles/binding/org.openhab.binding.exec.test
./bundles/binding/org.openhab.binding.knx.test
./bundles/binding/org.openhab.binding.http.test
./bundles/binding/org.openhab.binding.samsungac.test
./bundles/binding/org.openhab.binding.em.test
./bundles/binding/org.openhab.binding.rfxcom.test
./bundles/binding/org.openhab.binding.dmx.test
./bundles/binding/org.openhab.binding.enocean.test
./bundles/binding/org.openhab.binding.maxcube.test
./bundles/binding/org.openhab.binding.nikobus.test
./bundles/binding/org.openhab.binding.systeminfo.test
./bundles/binding/org.openhab.binding.mqtt.test
./bundles/binding/org.openhab.binding.homematic.test
./bundles/binding/org.openhab.binding.netatmo.test
./bundles/binding/org.openhab.binding.pilight.test
./bundles/binding/org.openhab.binding.modbus.test
./bundles/persistence/org.openhab.persistence.db4o.test
./bundles/persistence/org.openhab.persistence.dynamodb.test
./bundles/persistence/org.openhab.persistence.exec.test
./bundles/io/org.openhab.io.multimedia.tts.googletts.test
./bundles/io/org.openhab.io.transport.cul.test
./bundles/io/org.openhab.io.gcal.test

Typically JUnit and Mockito are used in these bundles.

For openhab2-addons you can also refer to the Testing Eclipse SmartHome documentation. Though a lot of this is not applicable to the legacy openhab1-addons.

Well, then XMPP would be the first action package with unit tests. Looks doable, though, as it uses only a tiny bit of the underlying infrastructure. Maybe the day after tomorrow I will find some time to give it a try.