Posts tagged with jax-rs

    Marshalling Interfaces in JAX-RS

    In Java, interfaces are used all over the place. Occasionally, these will need to be marshalled into XML/JSON. However, JAX-RS creates its own JAXBContext on its own. So, you may see exceptions like this…

    Foo is an interface, and JAXB can't handle interfaces.
        this problem is related to the following location:
            at Foo
            at public Foo[] Response.getFoo()
            at Response
     
        at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.getMarshaller(AbstractJAXBProvider.java:160) [resteasy-jaxb-provider-3.0.6.Final.jar:]
        at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.writeTo(AbstractJAXBProvider.java:122) [resteasy-jaxb-provider-3.0.6.Final.jar:]
        at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:129) [resteasy-jaxrs-3.0.6.Final.jar:]
        at org.jboss.resteasy.core.interception.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:62) [resteasy-jaxrs-3.0.6.Final.jar:]
            ...

    Ugly, huh? Here’s how to fix it…

    Using Weld (CDI), JSF, and JAX-RS in Tomcat

    We’ve recently been in the transition from using Spring in a Tomcat environment to Java EE7 in Wildfly? (still finalizing the container of choice).

    Since we’re in transition, we’d like to run the application in both Tomcat and Wildfly, without having to make changes to the bundled application. It should just work on deploy. Here’s how to do it…