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"?>
<resources>
<Service id="jsonProvider" class-name="org.apache.cxf.jaxrs.provider.json.JSONProvider">
dropRootElement=true
supportUnwrapped = true
dropCollectionWrapperElement=true
</Service>
</resources>
In the /src/main/webapp/WEB-INF/openejb-jar.xml
descriptor, you only have to refer to the earlier defined configuration:
<openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
<pojo-deployment class-name="jaxrs-application">
<properties>
cxf.jaxrs.providers = jsonProvider
</properties>
</pojo-deployment>
</openejb-jar>
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: airhacks.io!