You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Wang Wayne <su...@gmail.com> on 2008/12/15 06:35:52 UTC

org.apache.cxf.interceptor.Fault: No Content-Type

Hello All,



I have met a question when I request my local web service from Browser. The
error from Tomcat server as following:

Interceptor has thrown exception, unwinding now

org.apache.cxf.interceptor.Fault: No Content-Type specified for HTTP GET



But still the same web service when I request from Junit test, It's work.
The request code as following:

URL url = *new* URL("http://localhost:8000/sso/webservice/policyservice/test
");

        InputStream in = url.openStream();

        log.info(*getStringFromInputStream*(in));



This is server code:

         @GET

    @Path("/test/")

    *public* Response test(InputStream is) {

        *return* Response.*status*(Response.Status.*OK*).entity(
"<result>success</result>").build();

}

Would someone could help me, please. I really appreciate!



Best wishes for you!

Wayne Wang

RE: org.apache.cxf.interceptor.Fault: No Content-Type

Posted by Sergey Beryozkin <sb...@progress.com>.
That said - most likely cause is that you have a method with a parameter
not annotated with any of JAXRS parameter annotations - hence you see
this exception. If it's the case then may be that code which used to
throw it should've stayed :-), to prevent attempts to read from an empty
input stream or something...

Cheers, Sergey

-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozk@progress.com] 
Sent: 23 January 2009 23:50
To: users@cxf.apache.org
Subject: RE: org.apache.cxf.interceptor.Fault: No Content-Type

Hi - it's definitely fixed in 2.1.4/2.2 snapshots. Sorry about it, just
hang on please a little bit longer and 2.1.4 will be released.
Here's one workaround :

Register an implementation of CXF JAXRS RequestFilter (as a provider)
and add, say, a wildcard type like this :

message.put(Message.CONTENT_TYPE, "*/*");

Hope it helps, Sergey 




-----Original Message-----
From: Todd Orr [mailto:torr0101@gmail.com] 
Sent: 23 January 2009 20:12
To: users@cxf.apache.org
Subject: Re: org.apache.cxf.interceptor.Fault: No Content-Type

I'm experiencing the same bug while trying to view a resource in my
browser. Firefox does not send Content-Type with a GET request, so
this fails every time. Seems like a real bug.

On Mon, Dec 15, 2008 at 4:52 AM, Sergey Beryozkin
<se...@progress.com> wrote:
> Hi
>
> I think it's actually a  legacy bug. I think the reason it works in a
unit
> test is because some default content type is set when Java
> (HTTP)UrlConnection is involved but not when a browser is used.
>
> That said, I'm not sure one can call it a bug. Please set Content-Type
to
> any acceptable content type, */* even, to keep you going, but in
reality you
> can't have a GET request with a request body available at the same
time.
> Most likely the InputStream value in your method is null.
>
> Either way, what I will do is I'll update the code to log a warning
message
> and set the type to */*.
>
> Cheers, Sergey
>
>
>> Hi Wayne,
>>
>> I think you'd better try with the last version 2.1.3
>>
>> because there's a issue on 2.1.2 and it was fixed on that version
>>
>> http://issues.apache.org/jira/browse/CXF-1699
>>
>>
>>
>> On Mon, Dec 15, 2008 at 1:35 PM, Wang Wayne <su...@gmail.com>
wrote:
>>
>>> Hello All,
>>>
>>>
>>>
>>> I have met a question when I request my local web service from
Browser.
>>> The
>>> error from Tomcat server as following:
>>>
>>> Interceptor has thrown exception, unwinding now
>>>
>>> org.apache.cxf.interceptor.Fault: No Content-Type specified for HTTP
GET
>>>
>>>
>>>
>>> But still the same web service when I request from Junit test, It's
work.
>>> The request code as following:
>>>
>>> URL url = *new* URL("
>>> http://localhost:8000/sso/webservice/policyservice/test
>>> ");
>>>
>>>       InputStream in = url.openStream();
>>>
>>>       log.info(*getStringFromInputStream*(in));
>>>
>>>
>>>
>>> This is server code:
>>>
>>>        @GET
>>>
>>>   @Path("/test/")
>>>
>>>   *public* Response test(InputStream is) {
>>>
>>>       *return* Response.*status*(Response.Status.*OK*).entity(
>>> "<result>success</result>").build();
>>>
>>> }
>>>
>>> Would someone could help me, please. I really appreciate!
>>>
>>>
>>>
>>> Best wishes for you!
>>>
>>> Wayne Wang
>>>
>>
>>
>>
>> --
>> Regards!
>>
>> Chouxinxin Huang
>>
>
>

RE: org.apache.cxf.interceptor.Fault: No Content-Type

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi - it's definitely fixed in 2.1.4/2.2 snapshots. Sorry about it, just
hang on please a little bit longer and 2.1.4 will be released.
Here's one workaround :

Register an implementation of CXF JAXRS RequestFilter (as a provider)
and add, say, a wildcard type like this :

message.put(Message.CONTENT_TYPE, "*/*");

Hope it helps, Sergey 




-----Original Message-----
From: Todd Orr [mailto:torr0101@gmail.com] 
Sent: 23 January 2009 20:12
To: users@cxf.apache.org
Subject: Re: org.apache.cxf.interceptor.Fault: No Content-Type

I'm experiencing the same bug while trying to view a resource in my
browser. Firefox does not send Content-Type with a GET request, so
this fails every time. Seems like a real bug.

On Mon, Dec 15, 2008 at 4:52 AM, Sergey Beryozkin
<se...@progress.com> wrote:
> Hi
>
> I think it's actually a  legacy bug. I think the reason it works in a
unit
> test is because some default content type is set when Java
> (HTTP)UrlConnection is involved but not when a browser is used.
>
> That said, I'm not sure one can call it a bug. Please set Content-Type
to
> any acceptable content type, */* even, to keep you going, but in
reality you
> can't have a GET request with a request body available at the same
time.
> Most likely the InputStream value in your method is null.
>
> Either way, what I will do is I'll update the code to log a warning
message
> and set the type to */*.
>
> Cheers, Sergey
>
>
>> Hi Wayne,
>>
>> I think you'd better try with the last version 2.1.3
>>
>> because there's a issue on 2.1.2 and it was fixed on that version
>>
>> http://issues.apache.org/jira/browse/CXF-1699
>>
>>
>>
>> On Mon, Dec 15, 2008 at 1:35 PM, Wang Wayne <su...@gmail.com>
wrote:
>>
>>> Hello All,
>>>
>>>
>>>
>>> I have met a question when I request my local web service from
Browser.
>>> The
>>> error from Tomcat server as following:
>>>
>>> Interceptor has thrown exception, unwinding now
>>>
>>> org.apache.cxf.interceptor.Fault: No Content-Type specified for HTTP
GET
>>>
>>>
>>>
>>> But still the same web service when I request from Junit test, It's
work.
>>> The request code as following:
>>>
>>> URL url = *new* URL("
>>> http://localhost:8000/sso/webservice/policyservice/test
>>> ");
>>>
>>>       InputStream in = url.openStream();
>>>
>>>       log.info(*getStringFromInputStream*(in));
>>>
>>>
>>>
>>> This is server code:
>>>
>>>        @GET
>>>
>>>   @Path("/test/")
>>>
>>>   *public* Response test(InputStream is) {
>>>
>>>       *return* Response.*status*(Response.Status.*OK*).entity(
>>> "<result>success</result>").build();
>>>
>>> }
>>>
>>> Would someone could help me, please. I really appreciate!
>>>
>>>
>>>
>>> Best wishes for you!
>>>
>>> Wayne Wang
>>>
>>
>>
>>
>> --
>> Regards!
>>
>> Chouxinxin Huang
>>
>
>

Re: org.apache.cxf.interceptor.Fault: No Content-Type

Posted by Todd Orr <to...@gmail.com>.
I'm experiencing the same bug while trying to view a resource in my
browser. Firefox does not send Content-Type with a GET request, so
this fails every time. Seems like a real bug.

On Mon, Dec 15, 2008 at 4:52 AM, Sergey Beryozkin
<se...@progress.com> wrote:
> Hi
>
> I think it's actually a  legacy bug. I think the reason it works in a unit
> test is because some default content type is set when Java
> (HTTP)UrlConnection is involved but not when a browser is used.
>
> That said, I'm not sure one can call it a bug. Please set Content-Type to
> any acceptable content type, */* even, to keep you going, but in reality you
> can't have a GET request with a request body available at the same time.
> Most likely the InputStream value in your method is null.
>
> Either way, what I will do is I'll update the code to log a warning message
> and set the type to */*.
>
> Cheers, Sergey
>
>
>> Hi Wayne,
>>
>> I think you'd better try with the last version 2.1.3
>>
>> because there's a issue on 2.1.2 and it was fixed on that version
>>
>> http://issues.apache.org/jira/browse/CXF-1699
>>
>>
>>
>> On Mon, Dec 15, 2008 at 1:35 PM, Wang Wayne <su...@gmail.com> wrote:
>>
>>> Hello All,
>>>
>>>
>>>
>>> I have met a question when I request my local web service from Browser.
>>> The
>>> error from Tomcat server as following:
>>>
>>> Interceptor has thrown exception, unwinding now
>>>
>>> org.apache.cxf.interceptor.Fault: No Content-Type specified for HTTP GET
>>>
>>>
>>>
>>> But still the same web service when I request from Junit test, It's work.
>>> The request code as following:
>>>
>>> URL url = *new* URL("
>>> http://localhost:8000/sso/webservice/policyservice/test
>>> ");
>>>
>>>       InputStream in = url.openStream();
>>>
>>>       log.info(*getStringFromInputStream*(in));
>>>
>>>
>>>
>>> This is server code:
>>>
>>>        @GET
>>>
>>>   @Path("/test/")
>>>
>>>   *public* Response test(InputStream is) {
>>>
>>>       *return* Response.*status*(Response.Status.*OK*).entity(
>>> "<result>success</result>").build();
>>>
>>> }
>>>
>>> Would someone could help me, please. I really appreciate!
>>>
>>>
>>>
>>> Best wishes for you!
>>>
>>> Wayne Wang
>>>
>>
>>
>>
>> --
>> Regards!
>>
>> Chouxinxin Huang
>>
>
>

Re: org.apache.cxf.interceptor.Fault: No Content-Type

Posted by Sergey Beryozkin <se...@progress.com>.
Hi

I think it's actually a  legacy bug. 
I think the reason it works in a unit test is because some default content type is set when Java (HTTP)UrlConnection 
is involved but not when a browser is used.

That said, I'm not sure one can call it a bug. 
Please set Content-Type to any acceptable content type, */* even, to keep you going, but in reality you can't have 
a GET request with a request body available at the same time. Most likely the InputStream value in your method is null.

Either way, what I will do is I'll update the code to log a warning message and set the type to */*.
 
Cheers, Sergey


> Hi Wayne,
> 
> I think you'd better try with the last version 2.1.3
> 
> because there's a issue on 2.1.2 and it was fixed on that version
> 
> http://issues.apache.org/jira/browse/CXF-1699
> 
> 
> 
> On Mon, Dec 15, 2008 at 1:35 PM, Wang Wayne <su...@gmail.com> wrote:
> 
>> Hello All,
>>
>>
>>
>> I have met a question when I request my local web service from Browser. The
>> error from Tomcat server as following:
>>
>> Interceptor has thrown exception, unwinding now
>>
>> org.apache.cxf.interceptor.Fault: No Content-Type specified for HTTP GET
>>
>>
>>
>> But still the same web service when I request from Junit test, It's work.
>> The request code as following:
>>
>> URL url = *new* URL("
>> http://localhost:8000/sso/webservice/policyservice/test
>> ");
>>
>>        InputStream in = url.openStream();
>>
>>        log.info(*getStringFromInputStream*(in));
>>
>>
>>
>> This is server code:
>>
>>         @GET
>>
>>    @Path("/test/")
>>
>>    *public* Response test(InputStream is) {
>>
>>        *return* Response.*status*(Response.Status.*OK*).entity(
>> "<result>success</result>").build();
>>
>> }
>>
>> Would someone could help me, please. I really appreciate!
>>
>>
>>
>> Best wishes for you!
>>
>> Wayne Wang
>>
> 
> 
> 
> -- 
> Regards!
> 
> Chouxinxin Huang
>


Re: org.apache.cxf.interceptor.Fault: No Content-Type

Posted by Chouxinxin Huang <hu...@gmail.com>.
Hi Wayne,

I think you'd better try with the last version 2.1.3

because there's a issue on 2.1.2 and it was fixed on that version

http://issues.apache.org/jira/browse/CXF-1699



On Mon, Dec 15, 2008 at 1:35 PM, Wang Wayne <su...@gmail.com> wrote:

> Hello All,
>
>
>
> I have met a question when I request my local web service from Browser. The
> error from Tomcat server as following:
>
> Interceptor has thrown exception, unwinding now
>
> org.apache.cxf.interceptor.Fault: No Content-Type specified for HTTP GET
>
>
>
> But still the same web service when I request from Junit test, It's work.
> The request code as following:
>
> URL url = *new* URL("
> http://localhost:8000/sso/webservice/policyservice/test
> ");
>
>        InputStream in = url.openStream();
>
>        log.info(*getStringFromInputStream*(in));
>
>
>
> This is server code:
>
>         @GET
>
>    @Path("/test/")
>
>    *public* Response test(InputStream is) {
>
>        *return* Response.*status*(Response.Status.*OK*).entity(
> "<result>success</result>").build();
>
> }
>
> Would someone could help me, please. I really appreciate!
>
>
>
> Best wishes for you!
>
> Wayne Wang
>



-- 
Regards!

Chouxinxin Huang