You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@wink.apache.org by Murali <up...@us.ibm.com> on 2010/11/23 01:53:49 UTC
Error 500: java.lang.IllegalArgumentException: MediaType header is
null
Hi All,
I am getting the following error, when I send the request from client.
When I run the server in debug mode, I see that exception raises in
getbody(Schema.class , null ) method of InPart class.
Error 500: java.lang.IllegalArgumentException: MediaType header is null
I think I have to set the MediaType, but I dont know where. Can someone
please provide with some inputs?
My brief code is here, where Schema is user defined class.
List<InPart> parts = inMP.getParts();
Iterator<InPart> ipIterator = parts.iterator();
InPart ip = ipIterator.next();
Schema sc = ip.getBody(Schema.class, null);
Error Stack Trace,
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor logException
IllegalArgumentException occurred during the handlers chain invocation
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor handleRequest Unhandled
exception
[11/22/10 19:52:07:969 EST] 0000001f servlet E
com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught
exception created in one of the service methods of the servlet JAX-RS
Servlet in application ASF_NewEAR. Exception created :
java.lang.IllegalArgumentException: MediaType header is null
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:47)
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:34)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:150)
at org.apache.wink.common.model.multipart.InPart.getBody(InPart.java:121)
at org.apache.wink.common.model.multipart.InPart.getBody(InPart.java:133)
at
com.ibm.bams.asf.jaxrs.FrameworkHandlerDelegate.registerSchema(FrameworkHandlerDelegate.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at
org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:51)
at
org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:33)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:61)
.............................................
.......................................
Thanks in advance,
Murali
--
View this message in context: http://apache-wink-users.3471013.n2.nabble.com/Error-500-java-lang-IllegalArgumentException-MediaType-header-is-null-tp5765059p5765059.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.
Re: Error 500: java.lang.IllegalArgumentException: MediaType header is null
Posted by Murali Uppala <up...@us.ibm.com>.
Hi Jesse,
Thanks for the help.
I made sure that Content-Type header is set on the parts in the request and
that worked!
But once I pass that issue, I get the following error, in method call
ip.getBody(Schema.class, Schema.class);
[11/23/10 12:08:20:500 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor logException
WebApplicationException (415 - Unsupported Media Type) occurred during the
handlers chain invocation
Request from Client,
Content-Type: multipart/form-data;boundary=AaB03x
--AaB03x
Content-Disposition: form-data;
Content-Type: application/json
{"schema":{"validation":"off","schemaPermission":"AllowFullPermission","file":"schema.xsd","schemaId":"SFX_Schema_MS_01","isActive":"false","schemaName":"Maintenance
Scheduling"}}
--AaB03x
----------------------------------------------------------------------------------------------------------------------------------------
If I send the XML data instead of JSON data, it works good. I am not sure
why?
Following request from client works good,
Content-Type: multipart/form-data;boundary=AaB03x
--AaB03x
Content-Disposition: form-data;
Content-Type: application/xml
<schema>
<validation>off</validation>
<schemaId>SFX_Schema_MS_01</schemaId>
<schemaName>Maintenance Scheduling</schemaName>
<isActive>false</isActive>
<file>hello.xsd</file>
<schemaPermission>AllowFullPermission</schemaPermission>
</schema>
--AaB03x
Thank you,
Murali Uppala
From: Jesse A Ramos/Austin/IBM@IBMUS
To: wink-user@incubator.apache.org
Date: 11/23/2010 10:22 AM
Subject: Re: Error 500: java.lang.IllegalArgumentException: MediaType
header is null
Hi,
This is a bug in the 1.0 release. We look for the Content-Type header on
the part being demarshalled but don't check for null in the case that the
header doesn't exist. This is fixed in the 1.1 release and higher.
However, what the fix does is default to content type of text/plain if the
header is not set. If this is not correct for the entity, you'll need to
make sure the Content-Type header is set on the parts in the request.
Having said that, I think there is a non-related bug in your input
parameters to getBody that will cause a problem after you get passed this
issue. The second parameter should also be Schema.class instead of null.
This Type parameter will be used to find a MessageBodyReader that can
demarshall the part into the appropriate entity.
-- Jesse
From: Murali Uppala/Watson/Contr/IBM@IBMUS
To: wink-user@incubator.apache.org
Date: 11/22/2010 06:55 PM
Subject: Error 500: java.lang.IllegalArgumentException: MediaType
header is null
Hi All,
I am getting the following error, when I send the request from client.
When I run the server in debug mode, I see that exception raises in
getbody(Schema.class , null ) method of InPart class.
Error 500: java.lang.IllegalArgumentException: MediaType header is null
I think I have to set the MediaType, but I dont know where. Can someone
please provide with some inputs?
My brief code is here, where Schema is user defined class.
List<InPart> parts = inMP.getParts();
Iterator<InPart> ipIterator = parts.iterator();
InPart ip = ipIterator.next();
Schema sc = ip.getBody(Schema.class, null);
Error Stack Trace,
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor logException
IllegalArgumentException occurred during the handlers chain invocation
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor handleRequest Unhandled
exception
[11/22/10 19:52:07:969 EST] 0000001f servlet E
com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught
exception created in one of the service methods of the servlet JAX-RS
Servlet in application ASF_NewEAR. Exception created :
java.lang.IllegalArgumentException: MediaType header is null
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString
(MediaTypeHeaderDelegate.java:47)
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString
(MediaTypeHeaderDelegate.java:34)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:150)
at org.apache.wink.common.model.multipart.InPart.getBody
(InPart.java:121)
at org.apache.wink.common.model.multipart.InPart.getBody
(InPart.java:133)
at
com.ibm.bams.asf.jaxrs.FrameworkHandlerDelegate.registerSchema
(FrameworkHandlerDelegate.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:48)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at
org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest
(InvokeMethodHandler.java:51)
at
org.apache.wink.server.handlers.AbstractHandler.handleRequest
(AbstractHandler.java:33)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle
(RequestHandlersChain.java:26)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle
(RequestHandlersChain.java:22)
at
org.apache.wink.server.handlers.AbstractHandlersChain.doChain
(AbstractHandlersChain.java:61)
.............................................
.......................................
Thanks in advance,
Murali
--
View this message in context:
http://apache-wink-users.3471013.n2.nabble.com/Error-500-java-lang-IllegalArgumentException-MediaType-header-is-null-tp5765059p5765059.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.
Re: Error 500: java.lang.IllegalArgumentException: MediaType header is null
Posted by Jesse A Ramos <jr...@us.ibm.com>.
Accidentally sent my reply directly to Murali. Pasting my response here
on the mailing list:
You'd get this message if your application doesn't provide a
MessageBodyReader that can convert json data into a Schema Object. Wink
previously provided providers for the org.json classes (ex: JSONObject).
With release 1.1.2, we've added a Jackson provider
(wink-providers/wink-jackson-provider) that may be able to do the
conversion. Jackson implements it's own JAX-RS MessageBodyReader which we
wrap using some default configuration settings in 1.1.2. If you'd like to
try Jackson directly, you can put Jackson libraries in your classpath and
return the provider in your Application sub-class.
-- Jesse
From: Murali Uppala/Watson/Contr/IBM
To: wink-user@incubator.apache.org
Cc: Jesse A Ramos/Austin/IBM@IBMUS
Date: 11/23/2010 11:15 AM
Subject: Re: Error 500: java.lang.IllegalArgumentException:
MediaType header is null
Hi Jesse,
Thanks for the help.
I made sure that Content-Type header is set on the parts in the request
and that worked!
But once I pass that issue, I get the following error, in method call
ip.getBody(Schema.class, Schema.class);
[11/23/10 12:08:20:500 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor logException
WebApplicationException (415 - Unsupported Media Type) occurred during the
handlers chain invocation
Request from Client,
Content-Type: multipart/form-data;boundary=AaB03x
--AaB03x
Content-Disposition: form-data;
Content-Type: application/json
{"schema":{"validation":"off","schemaPermission":"AllowFullPermission","file":"schema.xsd","schemaId":"SFX_Schema_MS_01","isActive":"false","schemaName":"Maintenance
Scheduling"}}
--AaB03x
----------------------------------------------------------------------------------------------------------------------------------------
If I send the XML data instead of JSON data, it works good. I am not sure
why?
Following request from client works good,
Content-Type: multipart/form-data;boundary=AaB03x
--AaB03x
Content-Disposition: form-data;
Content-Type: application/xml
<schema>
<validation>off</validation>
<schemaId>SFX_Schema_MS_01</schemaId>
<schemaName>Maintenance Scheduling</schemaName>
<isActive>false</isActive>
<file>hello.xsd</file>
<schemaPermission>AllowFullPermission</schemaPermission>
</schema>
--AaB03x
Thank you,
Murali Uppala
From: Jesse A Ramos/Austin/IBM@IBMUS
To: wink-user@incubator.apache.org
Date: 11/23/2010 10:22 AM
Subject: Re: Error 500: java.lang.IllegalArgumentException:
MediaType header is null
Hi,
This is a bug in the 1.0 release. We look for the Content-Type header on
the part being demarshalled but don't check for null in the case that the
header doesn't exist. This is fixed in the 1.1 release and higher.
However, what the fix does is default to content type of text/plain if the
header is not set. If this is not correct for the entity, you'll need to
make sure the Content-Type header is set on the parts in the request.
Having said that, I think there is a non-related bug in your input
parameters to getBody that will cause a problem after you get passed this
issue. The second parameter should also be Schema.class instead of null.
This Type parameter will be used to find a MessageBodyReader that can
demarshall the part into the appropriate entity.
-- Jesse
From: Murali Uppala/Watson/Contr/IBM@IBMUS
To: wink-user@incubator.apache.org
Date: 11/22/2010 06:55 PM
Subject: Error 500: java.lang.IllegalArgumentException: MediaType
header is null
Hi All,
I am getting the following error, when I send the request from client.
When I run the server in debug mode, I see that exception raises in
getbody(Schema.class , null ) method of InPart class.
Error 500: java.lang.IllegalArgumentException: MediaType header is null
I think I have to set the MediaType, but I dont know where. Can someone
please provide with some inputs?
My brief code is here, where Schema is user defined class.
List<InPart> parts = inMP.getParts();
Iterator<InPart> ipIterator = parts.iterator();
InPart ip = ipIterator.next();
Schema sc = ip.getBody(Schema.class, null);
Error Stack Trace,
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor logException
IllegalArgumentException occurred during the handlers chain invocation
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor handleRequest Unhandled
exception
[11/22/10 19:52:07:969 EST] 0000001f servlet E
com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught
exception created in one of the service methods of the servlet JAX-RS
Servlet in application ASF_NewEAR. Exception created :
java.lang.IllegalArgumentException: MediaType header is null
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:47)
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:34)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:150)
at
org.apache.wink.common.model.multipart.InPart.getBody(InPart.java:121)
at
org.apache.wink.common.model.multipart.InPart.getBody(InPart.java:133)
at
com.ibm.bams.asf.jaxrs.FrameworkHandlerDelegate.registerSchema(FrameworkHandlerDelegate.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at
org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:51)
at
org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:33)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:61)
.............................................
.......................................
Thanks in advance,
Murali
--
View this message in context:
http://apache-wink-users.3471013.n2.nabble.com/Error-500-java-lang-IllegalArgumentException-MediaType-header-is-null-tp5765059p5765059.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.
Re: Error 500: java.lang.IllegalArgumentException: MediaType header is null
Posted by Jesse A Ramos <jr...@us.ibm.com>.
Hi,
This is a bug in the 1.0 release. We look for the Content-Type header on
the part being demarshalled but don't check for null in the case that the
header doesn't exist. This is fixed in the 1.1 release and higher.
However, what the fix does is default to content type of text/plain if the
header is not set. If this is not correct for the entity, you'll need to
make sure the Content-Type header is set on the parts in the request.
Having said that, I think there is a non-related bug in your input
parameters to getBody that will cause a problem after you get passed this
issue. The second parameter should also be Schema.class instead of null.
This Type parameter will be used to find a MessageBodyReader that can
demarshall the part into the appropriate entity.
-- Jesse
From: Murali Uppala/Watson/Contr/IBM@IBMUS
To: wink-user@incubator.apache.org
Date: 11/22/2010 06:55 PM
Subject: Error 500: java.lang.IllegalArgumentException: MediaType
header is null
Hi All,
I am getting the following error, when I send the request from client.
When I run the server in debug mode, I see that exception raises in
getbody(Schema.class , null ) method of InPart class.
Error 500: java.lang.IllegalArgumentException: MediaType header is null
I think I have to set the MediaType, but I dont know where. Can someone
please provide with some inputs?
My brief code is here, where Schema is user defined class.
List<InPart> parts = inMP.getParts();
Iterator<InPart> ipIterator = parts.iterator();
InPart ip = ipIterator.next();
Schema sc = ip.getBody(Schema.class, null);
Error Stack Trace,
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor logException
IllegalArgumentException occurred during the handlers chain invocation
[11/22/10 19:52:07:969 EST] 0000001f RequestProces I
org.apache.wink.server.internal.RequestProcessor handleRequest Unhandled
exception
[11/22/10 19:52:07:969 EST] 0000001f servlet E
com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E: Uncaught
exception created in one of the service methods of the servlet JAX-RS
Servlet in application ASF_NewEAR. Exception created :
java.lang.IllegalArgumentException: MediaType header is null
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:47)
at
org.apache.wink.common.internal.providers.header.MediaTypeHeaderDelegate.fromString(MediaTypeHeaderDelegate.java:34)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:150)
at
org.apache.wink.common.model.multipart.InPart.getBody(InPart.java:121)
at
org.apache.wink.common.model.multipart.InPart.getBody(InPart.java:133)
at
com.ibm.bams.asf.jaxrs.FrameworkHandlerDelegate.registerSchema(FrameworkHandlerDelegate.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at
org.apache.wink.server.internal.handlers.InvokeMethodHandler.handleRequest(InvokeMethodHandler.java:51)
at
org.apache.wink.server.handlers.AbstractHandler.handleRequest(AbstractHandler.java:33)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:26)
at
org.apache.wink.server.handlers.RequestHandlersChain.handle(RequestHandlersChain.java:22)
at
org.apache.wink.server.handlers.AbstractHandlersChain.doChain(AbstractHandlersChain.java:61)
.............................................
.......................................
Thanks in advance,
Murali
--
View this message in context:
http://apache-wink-users.3471013.n2.nabble.com/Error-500-java-lang-IllegalArgumentException-MediaType-header-is-null-tp5765059p5765059.html
Sent from the Apache Wink Users mailing list archive at Nabble.com.