Use "json-schema-validator" as an OSGi bundle


This post describes how to integrate json-schema-validator 2.2.5 in an OSGi container.

json-schema-validator home page redirect to the binary download site to get OSGi ready library. But with this last one I was unable to make json-schema-validator working... I got an unsatisfied package jackson-databind.

So I decide to integrate by hand json-schema-validator and related dependencies. 14 jar to get and check (see into the MANIFEST.MF the "Export-Packages" directive..)

Here is the way :

  • use json-schema-validator in your Eclipse Java project by adding the pom dependency.
  • make a sample unit test working (see example package of the json-schema-validator project).
  • open your project "pom.xml" file using eclipse to know the current dependency tree (view called "Dependency Hierarchy").

After getting one-by-one each mandatory dependendency of the json validator, here is the final list I get :
  • btf-1.2.jar
  • jackson-annotations-2.4.1.jar
  • jackson-core-
  • msg-simple-1.1.jar
  • jackson-databind-
  • guava-16.0.1.jar
  • uri-template-0.9.jar
  • jackson-coreutils-1.8.jar
  • rhino-1.7R4.jar
  • libphonenumber-6.0.jar
  • mailapi-1.4.3.jar
  • jopt-simple-4.6.jar
  • joda-time-2.3.jar
  • json-schema-core-1.2.4.jar
  • json-schema-validator-2.2.5.jar

You can get each jar from a given maven repository; example joda-time-2.3.jar.

For each jar, I have to check the OSGi Export package directive. Here is the way to do that :

  • open the jar file using zip tool (ex. 7zip)
  • edit the file "META-INF/MANIFEST.MF"
  • check that the file contains an Export package directive like the following example for yoda time :
  • Export-Package: org.joda.time;version=2.3,org.joda.time.base;version=2
  • If this is not the case, I had to add it by hand. I had to do that for the following library : rhino, libphonenumbers, joptsimple. See under the related export package :
    • rhino-1.7R4.jar
    • get an updated version here
    • Export-Package: org.mozilla.javascript;version="1.7"
    • libphonenumber-6.0.jar
    • EDIT: it's now useless to do this update since this jar is embedded in the bundle's project (cf. under)
    • related issue : libphonenumber issue #205
    • joptsimple
      Export-Package: joptsimple;version="4.6"
    • EDIT: it's now useless to do this update since issue #65 has been fixed; So you could use a recent version : jopt-simple-4.8-SNAPSHOT.jar

After all these steps, when I want to validate a json content with a schema, I got an error while loading meta-schema "/draftv4/schema" (problem of class loading).
Until now, I have not figured out how to fix it.

        at com.github.fge.jsonschema.SchemaVersion.(
        at com.github.fge.jsonschema.SchemaVersion.(
        at com.github.fge.jsonschema.core.load.configuration.LoadingConfigurationBuilder.(
        at com.github.fge.jsonschema.core.load.configuration.LoadingConfiguration.byDefault(
Caused by: resource /draftv4/schema not found
        at com.github.fge.jackson.JsonLoader.fromResource(
        at com.github.fge.jsonschema.SchemaVersion.(
This file is present into "json-schema-core-1.2.4.jar" but not loaded as resource by OSGi container...

Following this error, I just open an issue json-schema-validator issue #111.

As workaround, with the help of Gábor Bakos and as first draft, I just push a "OSGi'fyed" version of the "json-schema-validator" here : boly38 json-schema-validator-bundle.

Of course any feedbacks are welcome

Aucun commentaire:

Enregistrer un commentaire

Mots clés du blog

10.1 4G acceptancetest adb androï Android androïd Android7 api appender appengine application applications archive array assistantematernelle astuce auth0 authentication authority automation Axis bash bearer blog boot bootloader bower build bundle c calendrier camille combal cdi certificate cf client cloudfoundry collaboratif command commandes connexion console css cyanogen decrypt démasquées démasquer développement dll dump easter eggs écologie écrit employeur EMUI EMUI5.0 encrypt enfant évènement export-package ExtJS fab fastboot fiche find firefox gadget galaxytab gelf gem git gmail gnupg gooelappengine google gparted gpg gpg2 gps graylog grenoble Grid gui harddrive heroku hover howto HTML http https IE ihm immobilier imprimante innovation insolite instance integration Java JavaScript jenkins jeu jobs json json-schema-validator key keystore labs linux livre log log4j logger logs lombok masquées masquer maven maven-gae-plugin Mémoire microsoft mobile mockito mondialisation monitor MUSE musique en ligne myopera nodejs npm NT NTEventLogger onglet openstack osgi paas package parameters parent php politique prosyst prototype proxies proxy quartz radio rappel recherche regex repository resize RIA ridge rock ROM route ruby rubygems s8500 samsung scheduler scm secret secure sel selenium Serializer server shared shell sign signature slf4j smartphone so société song spy ssh ssl struct swagger swig tâches téléphone téléréalité test thunderbird timeout token Tomcat tooltip tooltips truststore TWRP ubuntu unit test validator verify virgin virtualbox wave waze web WebApp wiki wikimedia wikipédia wikipen wiko windows yahoo youtube yum