You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by Anton Piatek1 <an...@uk.ibm.com> on 2013/04/02 16:10:46 UTC

wink unable to find writer for byte[]

My software has a rest call which returns a byte[], it is fairly simple 
as:
Response.ok(data).type("application/octet-stream").build();

This was working fine, until we upgraded from java 6 to java 7. Now I get 
an internal error. Getting some detailed logging information I see the 
below in the log. 
It suggests that wink does not have a writer that can work out what to do 
with a byte[]. Does anyone know if something changed between java 6 and 7 
which might mean I have to explicitly tell wink how to write a byte array? 
I would assume there is some way to register this manually, but I can't 
find it for wink...

org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter 
, 'Getting MessageBodyWriter for class type class [B, genericType class 
[B, annotations [@javax.ws.rs.GET(), 
@javax.ws.rs.Path(value={dataStoreName}/{msgId})], and media type 
application/octet-stream'
org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.getProvidersByMediaType 
, 'Getting providers by media type by calling 
getProvidersByMediaType(application/octet-stream, class [B)'
org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.getProvidersByMediaType 
, 'Get media type to providers cache for media type 
application/octet-stream resulted in []'
org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter 
, 'Found possible MessageBodyWriter ObjectFactories []'
org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter 
, 'No MessageBodyWriter returned true for isWriteable( class [B, class [B, 
[@javax.ws.rs.GET(), @javax.ws.rs.Path(value={dataStoreName}/{msgId})], 
application/octet-stream )'
org.apache.wink.server.internal.handlers.FlushResultHandler.handleResponse 
, 'Could not find a writer for [B and application/octet-stream. Try to 
find JAF DataSourceProvider'
com.sun.activation.registries.LogSupport.log , 'MailcapCommandMap: 
createDataContentHandler for application/octet-stream'
org.apache.wink.server.internal.handlers.FlushResultHandler.handleResponse 
, 'The system could not find a javax.ws.rs.ext.MessageBodyWriter or a 
DataSourceProvider class for the [B type and application/octet-stream 
mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the 
JAX-RS application for the type and media type specified.'
...

RawType: interface javax.ws.rs.ext.MessageBodyReader
Data Map:
...
MediaType key = */*
ObjectFactory Set value = {
}
...
MediaType key = application/octet-stream
ObjectFactory Set value = {
}
...


RawType: interface javax.ws.rs.ext.MessageBodyWriter
Data Map:
...
MediaType key = */*
ObjectFactory Set value = {
}
...
MediaType key = application/octet-stream
ObjectFactory Set value = {
}
...

RawType: interface javax.ws.rs.ext.ContextResolver
Data Map: {empty}'


Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Re: wink unable to find writer for byte[]

Posted by Anton Piatek1 <an...@uk.ibm.com>.
Luciano Resende <lu...@gmail.com> wrote on 03/04/2013 05:18:26:

> From: Luciano Resende <lu...@gmail.com>
> To: user@wink.apache.org, 
> Cc: wink-user@incubator.apache.org
> Date: 03/04/2013 05:18
> Subject: Re: wink unable to find writer for byte[]
> 
> On Tue, Apr 2, 2013 at 7:10 AM, Anton Piatek1 <an...@uk.ibm.com> 
wrote:
> My software has a rest call which returns a byte[], it is fairly simple 
as: 
> Response.ok(data).type("application/octet-stream").build(); 
> 
> This was working fine, until we upgraded from java 6 to java 7. Now 
> I get an internal error. Getting some detailed logging information I
> see the below in the log. 
> It suggests that wink does not have a writer that can work out what 
> to do with a byte[]. Does anyone know if something changed between 
> java 6 and 7 which might mean I have to explicitly tell wink how to 
> write a byte array? I would assume there is some way to register 
> this manually, but I can't find it for wink... 
> 
> 
org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter
> , 'Getting MessageBodyWriter for class type class [B, genericType 
> class [B, annotations [@javax.ws.rs.GET(), @javax.ws.rs.Path(value=
> {dataStoreName}/{msgId})], and media type application/octet-stream' 
> org.apache.wink.common.internal.registry.ProvidersRegistry
> $MediaTypeMap.getProvidersByMediaType , 'Getting providers by media 
> type by calling getProvidersByMediaType(application/octet-stream, class 
[B)' 
> org.apache.wink.common.internal.registry.ProvidersRegistry
> $MediaTypeMap.getProvidersByMediaType , 'Get media type to providers
> cache for media type application/octet-stream resulted in []' 
> 
org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter
> , 'Found possible MessageBodyWriter ObjectFactories []' 
> 
org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter
> , 'No MessageBodyWriter returned true for isWriteable( class [B, 
> class [B, [@javax.ws.rs.GET(), @javax.ws.rs.Path(value=
> {dataStoreName}/{msgId})], application/octet-stream )' 
....

> 
> What version of Wink are you using ? If you are using IBM JDK 7.0 
> you must upgrade to Wink 1.2.1 which has a fix for some specific 
> issues related to IBM JDK 7.
> 
> As for registering you MessageBodyWriter and MessageBodyWriter in 
> the application file, see a simple example in 
> 
> 
https://svn.apache.org/repos/asf/wink/sandbox/lresende/sample-jaxrs-webapp/
> 
> Where the MBW is registered in 
> 
> https://svn.apache.org/repos/asf/wink/sandbox/lresende/sample-jaxrs-
> webapp/src/main/webapp/WEB-INF/application

Yes I was on 1.2.0 and moving up to 1.2.1 has now fixed my issue.

Thanks very much for the help!
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 
741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Re: wink unable to find writer for byte[]

Posted by Luciano Resende <lu...@gmail.com>.
On Tue, Apr 2, 2013 at 7:10 AM, Anton Piatek1 <an...@uk.ibm.com>wrote:

> My software has a rest call which returns a byte[], it is fairly simple as:
> Response.ok(data).type("application/octet-stream").build();
>
> This was working fine, until we upgraded from java 6 to java 7. Now I get
> an internal error. Getting some detailed logging information I see the
> below in the log.
> It suggests that wink does not have a writer that can work out what to do
> with a byte[]. Does anyone know if something changed between java 6 and 7
> which might mean I have to explicitly tell wink how to write a byte array?
> I would assume there is some way to register this manually, but I can't
> find it for wink...
>
> org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter
> , 'Getting MessageBodyWriter for class type class [B, genericType class [B,
> annotations [@javax.ws.rs.GET(),
> @javax.ws.rs.Path(value={dataStoreName}/{msgId})], and media type
> application/octet-stream'
> org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.getProvidersByMediaType
> , 'Getting providers by media type by calling
> getProvidersByMediaType(application/octet-stream, class [B)'
> org.apache.wink.common.internal.registry.ProvidersRegistry$MediaTypeMap.getProvidersByMediaType
> , 'Get media type to providers cache for media type
> application/octet-stream resulted in []'
> org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter
> , 'Found possible MessageBodyWriter ObjectFactories []'
> org.apache.wink.common.internal.registry.ProvidersRegistry.getMessageBodyWriter
> , 'No MessageBodyWriter returned true for isWriteable( class [B, class [B,
> [@javax.ws.rs.GET(), @javax.ws.rs.Path(value={dataStoreName}/{msgId})],
> application/octet-stream )'
> org.apache.wink.server.internal.handlers.FlushResultHandler.handleResponse
> , 'Could not find a writer for [B and application/octet-stream. Try to find
> JAF DataSourceProvider'
> com.sun.activation.registries.LogSupport.log , 'MailcapCommandMap:
> createDataContentHandler for application/octet-stream'
> org.apache.wink.server.internal.handlers.FlushResultHandler.handleResponse
> , 'The system could not find a javax.ws.rs.ext.MessageBodyWriter or a
> DataSourceProvider class for the [B type and application/octet-stream
> mediaType.  Ensure that a javax.ws.rs.ext.MessageBodyWriter exists in the
> JAX-RS application for the type and media type specified.'
> ...
>
> RawType: interface javax.ws.rs.ext.MessageBodyReader
> Data Map:
> ...
> MediaType key = */*
> ObjectFactory Set value = {
> }
> ...
> MediaType key = application/octet-stream
> ObjectFactory Set value = {
> }
> ...
>
>
> RawType: interface javax.ws.rs.ext.MessageBodyWriter
> Data Map:
> ...
> MediaType key = */*
> ObjectFactory Set value = {
> }
> ...
> MediaType key = application/octet-stream
> ObjectFactory Set value = {
> }
> ...
>
> RawType: interface javax.ws.rs.ext.ContextResolver
> Data Map: {empty}'
>
>
What version of Wink are you using ? If you are using IBM JDK 7.0 you must
upgrade to Wink 1.2.1 which has a fix for some specific issues related to
IBM JDK 7.

As for registering you MessageBodyWriter and MessageBodyWriter in the
application file, see a simple example in

https://svn.apache.org/repos/asf/wink/sandbox/lresende/sample-jaxrs-webapp/

Where the MBW is registered in

https://svn.apache.org/repos/asf/wink/sandbox/lresende/sample-jaxrs-webapp/src/main/webapp/WEB-INF/application


-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/