Unable to use javax.json

I implemented a binding, which includes the javax.json package.

In the 2.4 SNAPSHOT environment everything works fine. However, if I copy the jar to a 2.3 Release environment I get the following exception when trying to initialitze the JSon reader from a http response

An error occurred while calling method 'ThingHandler.initialize()' on 'org.openhab.binding.entertaintv.internal.handler.EntertainTVHandler@180160c': javax.json.spi.JsonProvider: Provider org.glassfish.json.JsonProviderImpl not a subtype

javax.json.spi.JsonProvider: Provider org.glassfish.json.JsonProviderImpl not a subtype could be an indicator that the .jars are not found or something like that

I included both required jars in the lib folder,
added them to the classpatch in MANIFEST.MF

Manifest-Version: 1.0
Bundle-ActivationPolicy: lazy

… and also to build.properties

bin.includes = .,\

I unpackaged the jar and verified that lib/javax.json-api-1.1.3.jar and lib/javax.json-1.1.3.jar are included in the lib sub folder.

any idea?

I’d rather just use Gson for parsing since it is provided so you won’t have to package this additional dependency.

You could also try downgrading the version since the Homekit addon successfully uses the older version:


For more on Gson vs JSON-P and issues with the newer version see:

After a rebuild and OH restart initialisatiin is successful and works as eypexted.

For me Gson is useful if you new the binding to Java classes, which also requires class declaration etc. For simple stuff javax.json looks for me as more lightwight. I used v1.1.3 and include the 2 jars in the lib folder. The raaulting size of the binding jar ist about 170k (incl my lohic), which is ok.

Thanks for replying.

Great that it works!

Gson also has a JsonParser that you can use without having to define any objects at all. It’s used in a lot of bindings such as: Miele, Kodi, MiHome, Windcentrale, etc.