Hi All,

I'm working on a JAX-RS implementation and functionally things are working
well (kudos to the team for a great framework) - cxf 2.2.2.

However, in a small part of the exception handling i'm not getting expected
behaviour - handling invalid URL paths.
               
I'm using a custom Exception Mapper to handle exceptions and my
understanding is that the following happens in this scenario:

The exception mapper class is passed control after the JAXRSInInterceptor
finds 'No root resource matching request path ..." and throws a
WebApplicationException.

Then the exception mapper can just return a response (some kind of error) as
normal. However i'm getting the following error when returning from the
exception mapper: 

<XML> Parsing Error: syntax error (or parsing error)
Location: <requested URL>
Line Number 1, Column 1:
"No message body writer found for response class: Error Response"

Now in other error cases (both checked and unchecked) this exception mapper
is returning normally. The Error Response object is XMLRootElement
annotated.

It seems that in the JAXRSOutInterceptor in certain cases its failing to
load the JAXB context/related resources. I noticed in other error cases I
get the following two lines in logs but the response comes back correctly:

[2009-06-23 09:12:18,493 DEBUG][haseInterceptorChain][http-8080-Processor24
fw9syo1f][0:0:0:0:0:0:0:1][] Invoking handleMessage on interceptor
org.apache.cxf.jaxrs.interceptor.jaxrsoutintercep...@5a37d54
[2009-06-23 09:12:18,494 DEBUG][.JAXRSOutInterceptor][http-8080-Processor24
fw9syo1f][0:0:0:0:0:0:0:1][] Response content type is: application/xml
[2009-06-23 09:12:18,496 DEBUG][.JAXRSOutInterceptor][http-8080-Processor24
fw9syo1f][0:0:0:0:0:0:0:1][] Response EntityProvider is:
org.apache.cxf.jaxrs.provider.JAXBElementProvider
[2009-06-23 09:12:18,498 DEBUG][AbstractJAXBProvider][http-8080-Processor24
fw9syo1f][0:0:0:0:0:0:0:1][] Error creating a JAXBContext using
ObjectFactory : "package.name" doesnt contain ObjectFactory.class or
jaxb.index
[2009-06-23 09:12:18,503 DEBUG][haseInterceptorChain][http-8080-Processor24
fw9syo1f][0:0:0:0:0:0:0:1][] Invoking handleMessage on interceptor
org.apache.cxf.interceptor.messagesenderinterceptor$messagesenderendingintercep...@5e43e3ac

but in the invalid url case i get:

[2009-06-23 09:11:31,336 DEBUG][haseInterceptorChain][http-8080-Processor25
fw9sxn5s][0:0:0:0:0:0:0:1][] Invoking handleMessage on interceptor
org.apache.cxf.jaxrs.interceptor.jaxrsoutintercep...@5a37d54
[2009-06-23 09:11:31,337 WARN ][.JAXRSOutInterceptor][http-8080-Processor25
fw9sxn5s][0:0:0:0:0:0:0:1][] .No message body writer found for response
class : ErrorResponse.
[2009-06-23 09:11:31,337 DEBUG][haseInterceptorChain][http-8080-Processor25
fw9sxn5s][0:0:0:0:0:0:0:1][] Invoking handleMessage on interceptor
org.apache.cxf.interceptor.messagesenderinterceptor$messagesenderendingintercep...@5e43e3ac

I haven't really tried to debug the cxf source but it seems like in the
JAXRSOutInterceptor around line 179 the writer is not getting correctly
created possibly beacuse the annotations on the Error Response class aren't
found? I'm not sure why in this one error case this would happen and not in
others.

Possibly related to: http://issues.apache.org/jira/browse/CXF-1858

As a side note: I temporarily tried to marshall the response to XML myself
in the exception mapper rather than letting the framework marshall it for me
(but this for some reason returns application/octet-stream instead of
application/xml).

Regards,
Kynan
-- 
View this message in context: 
http://www.nabble.com/JAX-RS%3A-Invalid-URL-handling-tp24157326p24157326.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to