cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: JAX-RS: Invalid URL handling
Date Tue, 23 Jun 2009 09:28:12 GMT
Hi Kynan,

Can you please try to set an application/xml type on your custom Response please ?
Hopefully it will make a difference.

> [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

What happens is that a provider first attempts to initialize a package wide context and then
resorts back to trying to load a 
class-specific context. The message is a bit misleading. I think I can also try to optimize
given that it's already been checked 
whether a given package contains ObjectFactory or not.

> 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).

If no content-type has already been set then (per the spec) it defaults to application/octet-stream.
So please set application/xml 
in your custom exception mapper and hopefully it will start working

thanks, Sergey


----- Original Message ----- 
From: "Kynan Fraser" <kynan.fraser@customware.net>
To: <users@cxf.apache.org>
Sent: Tuesday, June 23, 2009 12:22 AM
Subject: JAX-RS: Invalid URL handling


>
> 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.JAXRSOutInterceptor@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$MessageSenderEndingInterceptor@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.JAXRSOutInterceptor@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$MessageSenderEndingInterceptor@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.
>
> 


Mime
View raw message