Hi

On Sun, Mar 13, 2011 at 8:11 PM, KARR, DAVID (ATTSI) <[email protected]> wrote:

> I'm building a set of unit tests for my CXF JAX-RS application.  I set
> up JAXRSServerFactoryBean for the tests.  Most of the tests work
> reasonably well, letting me create a WebClient to call my service.  The
> tests have a @RunWith for VerboseMockitoJUnitRunner, but I haven't set
> up a Spring context for them, I'm just setting some dependencies
> manually.
>
> One of the tests fails while rendering the response, with the following:
>
> org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
> WARNING: WebApplicationException has been caught : cause is
> java.lang.NullPointerException
>
> Unfortunately, that's all the information it gives me.  I don't get a
> stack trace.  How can I manually enable more diagnostics during the test
> so I can see where it's getting the NPE?
>
>
It is a bug (NPE), probably to do with some missing initialization, but
WebApplicationExceptionMapper itself does not print stacktraces because it
may  have been an exception thrown by the user as part of the application
flow.
It must be somewhere in the JAXBElementProvider.

Can you please try and register a custom JAXBElementProvider with the
JAXRSServerFactoryBean ? This provider will only extend writeTo/ReadFrom and
will have a try/catch block around super.writeFrom and readFrom ?
I'll check the JAXBElementProvider, I think it has few catches for different
types of exceptions including the Exception class - and in this case it
should indeed print a stacktrace...Letting users to configure the default
WebApplicationExceptionMapper for it to print the stacktraces is another
option...

Cheers, Sergey



> I had just added some code to define a @XmlJavaTypeAdapter for a
> HashMap, so it's likely it's in there somewhere, but I'd like to get the
> stack trace.
>



-- 
Sergey Beryozkin

Application Integration Division of Talend <http://www.talend.com>
http://sberyozkin.blogspot.com

Reply via email to