Monthly Archives: December 2014

Rule Them All meets PhantomJS to test JAX-RS javascript client generation


HTMLUnit is great to test web applications but sadly it doesn’t support recent js libraries (AngularJs/JQuery to not say their names).

PhantomJs is a great alternative but sometimes setup can be boring or too complicated for what you need.

Continue reading

PDF Helper Maven Plugin


A quick blog post to say I released today the first version (0.1) of pdf-helper-maven-plugin. It hit central pretty recently.

It is a small plugin allowing to concatenate PDFs using Maven.

Continue reading

OpenEJB ApplicationComposer and random port


ApplicationComposer is a great way to test a small JAXRS service but how to handle concurrent builds? how to avoid port conflicts since all builds will use the same (default) port?

An easy solution is to “affect” one port by build…but don’t ask me to maintain the range allocation ;).

OpenEJB now provides a nice solution.

Continue reading

Apache Johnzon: more configuration and TomEE integration


Apache Johnzon is an implementation of JSON-P specification but it also includes
a JSON java mapper and a JAX-RS provider.

First version was not very easy to configure (actually it was but it needed to extend
default implementation) but since 0.2-incubating it is designed to work out of the box.

It was done adding a new class: org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider
and a bunch of setters (+ lazy initialization of the mapper).

Here a sample to integrate it with TomEE resources.xml (but using Spring or any other configuration
model should work as well while setters are supported):

<Service id="johnzon" class-name="org.apache.johnzon.jaxrs.ConfigurableJohnzonProvider">
    ignores = com.foo.MyType,com.foo.MyOtherType
    accessMode = method
    supportHiddenAccess = true
    doCloseOnStreams = false
    version = 2
    skipNull = true
    skipEmptyArray = true
</Service>

Then to use it in TomEE just like it as usual in openejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
  <pojo-deployment class-name="jaxrs-application">
    <properties>
      cxf.jaxrs.providers = johnzon

      # this one is not mandatory but recommanded
      cxf.jaxrs.skip-provider-scanning = true
    </properties>
  </pojo-deployment>
</openejb-jar>

Side note: didn’t dig into it but using tomee service references ($refName)
you can even configure in resources.xml the Johnzon Mapper directly and just
set it (mapper attribute) in JohnzonProvider…but this is less intuitive then.

This way if default configuration (Pojo) doesn’t fit your need cause you use private constructors, field mapping etc… you can customize it pretty easily now.

Last but nice: default Johnzon provider is the one used out of the box in TomEE 2 for json serialization!