tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From netname <albya...@gmail.com>
Subject TomEE 1.5 and Jackson
Date Thu, 04 Oct 2012 06:28:44 GMT
I am trying to move a JAX-RS application from 1.0 to 1.5 but I am getting all
sort of errors. The first error I got was: "No message body writer has been
found for response class". So I came to the forum and read that setting the
providers in system.properties and putting the Jackson jars in TomEE/lib is
not the appropiate way anymore. Below are the steps that I am following,
please let me know where is my error:

Setup Jackson in TomEE 1.5


1)  Copy jackson-mapper-asl-1.9.9.jar, jackson-core-asl-1.9.9.jar,
jackson-jaxrs-1.9.9.jar in MyWebApp/lib folder

2) Under the WEB-INF folder add the following files:

resources.xml
-------------
<resources>
    <Service id="jsonProvider"
             class-name="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
    <Service id="jaxbProvider"
             class-name="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider"
/>
</resources>


openejb-jar.xml
---------------
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-1.1">
    <pojo-deployment
class-name="com.palda.faclpt.util.JacksonContextResolver">
        <properties>
            cxf.jax-rs.providers = jsonProvider, jaxbProvider
        </properties>
    </pojo-deployment>
</openejb-jar>

Questions


*1) Which namespace for openejb-jar-1.1 should I use?*
    I found that newer versions do not support the pojo-deployment element

*2) Which is the use of the class specified in the pojo-deployment?*
  In TomEE I did not have to implement a Provider class. I did do it,
though, in order to customize the date format on the generated JSON. I am
not sure if this is the class that should be used for the pojo-deployment
element

The class that I am using as Provider is:

@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonContextResolver implements ContextResolver<ObjectMapper>
{
    private ObjectMapper objectMapper;

    public JacksonContextResolver() throws Exception {
        this.objectMapper = new
ObjectMapper().configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
    }
    public ObjectMapper getContext(Class<?> objectType) {
       
objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS,
false);
        return objectMapper;
    }
}


Thanks,

Alberto




--
View this message in context: http://openejb.979440.n4.nabble.com/TomEE-1-5-and-Jackson-tp4657777.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message