Hi Dave
I'll have a look asap, need to complete CXF-1982
Cheers, Sergey
----- Original Message -----
From: "dclane" <[email protected]>
To: <[email protected]>
Sent: Friday, January 16, 2009 11:16 PM
Subject: Problem with MessageBodyReader provider
Hi All,
I have a custom provider class for MultipartRequest objects which isn't
working. It is instantiated without incident when my application context is
loaded, but I hit a RuntimeException ("No message body reader found for
target class MultipartRequest, content type: multipart/mixed") whenever I
try to use the service.
I believe my configuration/annotations/everything are correct, and have even
tried stripping out all but the simplest code from my MultipartProvider in
order to make something work.
----- applicationContext.xml -----
<jaxrs:server id="service" address="/rs">
<jaxrs:serviceBeans>
<bean id="myService" class="com.company.MyServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean id="multipartProvider" class="com.company.MultipartProvider"/>
</jaxrs:providers>
</jaxrs:server>
----- MyServiceBean.java -----
@Path( "/service/{serviceId}" )
public class MyServiceBean {
@POST
@Path( "/doThings" )
public Response doThings( @PathParam( "serviceId" ) String serviceId,
MultipartRequest multipartRequest ) {
// do things here.
}
}
----- MultipartProvider.java -----
@Consumes( "multipart/mixed" )
@Provider
public class MultipartProvider implements
MessageBodyReader<MultipartRequest> {
public boolean isReadable( Class<?> type, Type genericType, Annotation[]
annotations, MediaType mt ) {
return MultipartRequest.class.isAssignableFrom( type );
}
public MultipartRequest readFrom( Class<MultipartRequest> clazz, Type
genericType, Annotation[] annotations, MediaType m, MultivaluedMap<String,
String> headers, InputStream is ) throws IOException {
MultipartRequest multipartRequest = new
DefaultMultipartHttpServletRequest(null,null,null);
return multipartRequest;
}
}
----------
The MyService.java code isn't important at the moment, because I can't get
past the method call due to the (missing?) provider problem.
The Content-Type is definitely getting set by the client (the server-side
error message shows the request's Content-Type). I've tried switching the
types recognized by my MultipartProvider's @Consumes annotation and setting
it to "*/*" (and tried removing the parameter altogether, which should make
it attempt to work with any type, right?), but the provider is never picked
up.
Am I annotating things incorrectly or improperly referencing the provider in
my applicationContext.xml? I've made MessageBodyWriter providers before and
don't see much a of difference...
Maybe a fresh set of eyes can help me out. ;)
Thank you,
- Dave
P.S. If it matters, I'm running Tomcat 5.5.
--
View this message in context:
http://www.nabble.com/Problem-with-MessageBodyReader-provider-tp21510459p21510459.html
Sent from the cxf-user mailing list archive at Nabble.com.