dev@glassfish.java.net

Re: [Jersey] Re: Question about returning 404

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Fri, 11 Oct 2013 17:33:45 +0900

Marek,

Is the same issue with https://java.net/jira/browse/GLASSFISH-20699?

If being the same issue, I will close the issue using "works as designed".

Thanks
Tang

Marek Potociar wrote:
> On Sep 20, 2013, at 2:10 AM, Rawat <geegalrawat_at_gmail.com> wrote:
>
>> Hi All,
>>
>> I am using Jersey 1.14 and in my Servlet POJO i am trying to return 404 to the client
>
> You cannot throw JAX-RS exceptions from a Servlet and expect it to get processed properly. You can only throw it from JAX-RS resources or providers.
>
> Marek
>
>> if(respMap == null) {
>> throw new WebApplicationException(new Exception("No data found"), 404);
>> }
>>
>> But client received 500. Can anyone copy paste some sample code to return a standard http status code ?
>>
>>
>
>
>

-- 
----------------------
Tang Yong
Senior Engineer
GlassFish Committer (OSGi & OSGi-JavaEE)
OSGi Alliance Supporter
Blog: http://osgizone.typepad.com/tangyong/
Nanjing Fujitsu NanDa Software Tec CO.,LTD
http://www.fujitsu.com/cn/fnst
Tel: +86-25-86630566-8310
Fax: +86-25-83317685              
----------------------