Hi
On Tue, Apr 27, 2010 at 3:34 PM, Juri Glaß <[email protected]> wrote:
> Hi All
>
> I have a method actions in my REST interface. This method should accept a
> XML with some user actions (clicked, ..). The XML consists of multiple
> entries and these entries should be available at the server side in a
> collection.
>
> The method looks something like this:
>
> @POST
> @Path("/{userid}/actions")
> @Consumes("application/xml")
> Response setFeedback(@PathParam("userid") Long userId, Actions actions);
>
> I created the Actions class which holds a collection of Action elements.
>
> @XmlRootElement(name = "Actions")
> public class Actions {
>
> private Collection<Action> actions;
>
> // Getter/Setter omitted
> }
>
> @XmlRootElement(name = "Action")
> public class Action {
>
> Long itemId;
>
> // Getter/Setter omitted
> }
>
> I can post to the action method, but only the Actions class is not null,
> the collection is null.
>
> I have two problems:
> 1. How can I get better error messages from CXF to trace down what went
> wrong? I only get 500 Internal Server Error and the log file says:
>
> java.lang.RuntimeException: org.apache.cxf.interceptor.Fault:
> XXXXX.Actions.getActions()Ljava/util/Collection;
> at
> org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:99)
>
> 2. If the parsing go wrong, throws CXF always an Internal Server Error? If
> so, how can I catch this?
>
>
What looks like to be happening is that a setFeedback method throws NPE and
by default it is propagated to the underlying container (per the spec). So
one option is to register say a JAXRS ExceptionMapper for
RuntimeException...
cheers, Sergey
>
>
> I use CXF 2.2.3, Spring, Maven and Glassfish v3.
>
> Best
> Juri
>
>
>
>