Configuring The JSON Default Provider (jettison) in TomEE

TomEE comes with Jettison and cxf as standard JAXB and JAX-RS providers. Jettison is "chatty" and might require some tweaking.

To tweak Jettison in a WAR deployment, you will have to provide two configuration files:

The first src/main/webapp/WEB-INF/resources.xml configures the JSON provider:

<?xml version="1.0"?>
    <Service id="jsonProvider" class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
        supportUnwrapped = true

In the /src/main/webapp/WEB-INF/openejb-jar.xml descriptor, you only have to refer to the earlier defined configuration:

<openejb-jar xmlns="" 
    <pojo-deployment  class-name="jaxrs-application">
            cxf.jaxrs.providers = jsonProvider

TomEE greatly simplifies the configuration--checkout the CXF standalone example as reference / comparison.

See you at Java EE Workshops at Munich Airport, Terminal 2 or on demand and in a location very near you:!


Just tested on 1.7.1, using dropCollectionWrapperElement=true would give you invalid JSON format. It seems like you need serializeAsArray=true as well.

Posted by Non-Non on November 12, 2014 at 05:58 AM CET #


I've been have this problem for quite a while. I couldn't find on the internet another way to solve it. Your well detailed post was the only place that could save my problem. Many thanks! =****

Posted by Pedro on March 19, 2015 at 05:29 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments