Using jjs to confirm issue with DatatypeConverter in WebSphere Liberty

I kept running into a funky ‘java.lang.NullPointerException’ with the WebSphere Liberty included DataValidator. To debug the issue, I used the jjs – nashorn engine

If you need, to figure out where the class is located

try {
Class c = Class.forName("javax.xml.bind.DatatypeConverter");
System.out.println("Location " + c.getProtectionDomain().getCodeSource().getLocation());
} catch (ClassNotFoundException e1) {
TODO Auto-generated catch block

You’ll get output like this:

Location /opt/ibm/wlp/dev/api/spec/

Then you can look at the default JDK – Java SDK – 1.8

jjs> javax.xml.bind.DatatypeConverter.printHexBinary("get".getBytes())

Then you can look at the specific jar with jdk Java SDK – 1.8 + Liberty Jaxb

/opt/ibm/ibm-java-sdk-8.0-4.5/jre/bin/jjs --dump-on-error -classpath "/opt/ibm/wlp/dev/api/spec/" 
jjs> javax.xml.bind.DatatypeConverter.printHexBinary("get".getBytes())

From this, I determined that I needed to update in “”

Generating Swagger as part of a Maven Build

Most of my projects use Maven to build and coordinate dependencies and run unit and build integration tests. I’ve found it a real pain that I could not generate my swagger docs as part of the build.

I have found a really easy way. In Jenkins, I have a downstream job that runs specific maven goals. The WebSphere Liberty maven goals are documented WebSphere Liberty Maven Documentation. Please note my downstream job is an experimental downstream project; I am a bit concerned about edge cases where the process dies.

The commands of the downstream job are:

mvn dependency:copy-dependencies liberty:install-apps liberty:test-start-server

The commands execute three key elements:

  1. Dummy Server.xml – attached at the bottom
  2. Execution for Goal for pre-integration-test
  3. Execution must follow the copy-dependencies so the war file is copied on in

You can check your server is up and running:

tail -f target/liberty/wlp/usr/servers/defaultServer/logs/messages.log

Download the Swagger (YAML)

curl http://localhost:9080/swagger/api/swagger.yaml -o myswagger.yaml

The full code is below