You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vrahul <vr...@gmail.com> on 2014/04/07 11:20:40 UTC

CXF jaxrs custome exception mapper with camel

Hi,
I am trying to use ExceptionMapper class for my custom exception, below is
my custom exception mapper class

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

import com.my.flm.item.exception.CustomException;

@Provider
public class ItemExceptionMapper implements ExceptionMapper<CustomException> 
{

    @Override
    public Response toResponse(CustomException exception) {
        System.out.println("ItemExceptionMapper-toResponse");
        Response.Status status;
        status = Response.Status.INTERNAL_SERVER_ERROR;
        return Response.status(status).header("exception",
exception.getMessage()).build();
    }
}

I have added this class to my cxf server provider list

<cxf:rsServer id="itemService"
        address="{{esb.item.rest.address}}"
        serviceClass="com.my.esb.service.flm.ItemServiceImpl"
        loggingFeatureEnabled="true">
        <cxf:providers>
            <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
	    <bean class="com.my.flm.esb.exception.ItemExceptionMapper"/>
        </cxf:providers>
    </cxf:rsServer>

But when ever ItemException is thrown from the background call, i can see it
never went through my exception mapper class. 
Is there any one who has used the ExceptionMapper class with camel. I can
see the same exception mapper  class is working very fine with mule and
spring-web. But when it comes to camel it always surprising. :( 



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF jaxrs custome exception mapper with camel

Posted by vrahul <vr...@gmail.com>.
Cxf with camel always surprised me. ExceptionMapper is a basic requirement
expected from the restfull server. Please let me know once you are done with
the investigation :) . 
This is a urgency for me to have a exception mapper or similar alternate. 





--
View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5749915.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF jaxrs custome exception mapper with camel

Posted by Sergey Beryozkin <sb...@gmail.com>.
Please watch
https://issues.apache.org/jira/browse/CAMEL-7357



Cheers, Sergey
On 08/04/14 18:51, Sergey Beryozkin wrote:
> On 08/04/14 05:59, vrahul wrote:
>> Cxf with camel always surprised me. ExceptionMapper is a basic
>> requirement
>> expected from the restfull server. Please let me know once you are
>> done with
>> the investigation :) .
>> This is a urgency for me to have a exception mapper or similar alternate.
> I guess the best way for you is to open a JIRA and create a patch.
> And as I said earlier, feel free to try something different
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5749916.html
>>
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: CXF jaxrs custome exception mapper with camel

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 08/04/14 05:59, vrahul wrote:
> Cxf with camel always surprised me. ExceptionMapper is a basic requirement
> expected from the restfull server. Please let me know once you are done with
> the investigation :) .
> This is a urgency for me to have a exception mapper or similar alternate.
I guess the best way for you is to open a JIRA and create a patch.
And as I said earlier, feel free to try something different
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5749916.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: CXF jaxrs custome exception mapper with camel

Posted by vrahul <vr...@gmail.com>.
Cxf with camel always surprised me. ExceptionMapper is a basic requirement
expected from the restfull server. Please let me know once you are done with
the investigation :) . 
This is a urgency for me to have a exception mapper or similar alternate. 





--
View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5749916.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF jaxrs custome exception mapper with camel

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
The Camel CXFRS invoker might need to be updated to delegate to CXF and 
see if it can map an exception to Response, I'll investigate

Cheers, Sergey
On 07/04/14 10:20, vrahul wrote:
> Hi,
> I am trying to use ExceptionMapper class for my custom exception, below is
> my custom exception mapper class
>
> import javax.ws.rs.core.Response;
> import javax.ws.rs.ext.ExceptionMapper;
> import javax.ws.rs.ext.Provider;
>
> import com.my.flm.item.exception.CustomException;
>
> @Provider
> public class ItemExceptionMapper implements ExceptionMapper<CustomException>
> {
>
>      @Override
>      public Response toResponse(CustomException exception) {
>          System.out.println("ItemExceptionMapper-toResponse");
>          Response.Status status;
>          status = Response.Status.INTERNAL_SERVER_ERROR;
>          return Response.status(status).header("exception",
> exception.getMessage()).build();
>      }
> }
>
> I have added this class to my cxf server provider list
>
> <cxf:rsServer id="itemService"
>          address="{{esb.item.rest.address}}"
>          serviceClass="com.my.esb.service.flm.ItemServiceImpl"
>          loggingFeatureEnabled="true">
>          <cxf:providers>
>              <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
> 	    <bean class="com.my.flm.esb.exception.ItemExceptionMapper"/>
>          </cxf:providers>
>      </cxf:rsServer>
>
> But when ever ItemException is thrown from the background call, i can see it
> never went through my exception mapper class.
> Is there any one who has used the ExceptionMapper class with camel. I can
> see the same exception mapper  class is working very fine with mule and
> spring-web. But when it comes to camel it always surprising. :(
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



Re: CXF jaxrs custome exception mapper with camel

Posted by arno noordover <ar...@noordover.net>.
Changes of jira-issue are available in
https://fisheye6.atlassian.com/changelog/camel-git?cs=94c01b98dfd0b4140a7ff51c47222b1f728ce45e
These changes are also available in your version.
The unittest call toResponse in CustomExceptionMapper.
Can you compare your solution with the unittest provided in this commit.



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5783083.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF jaxrs custome exception mapper with camel

Posted by somme2u <so...@gmail.com>.
Hi ,

I am using camel 2.16.1 version. I am using cxf. I have the same issue as
mentioned in the above mail chain. My exception mapper class is not getting
invoked. Kindly let me know if there are any updates in this issue.

Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5783054.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF jaxrs custome exception mapper with camel

Posted by neil2014 <in...@gmail.com>.
I am using camel 2.12.4. I am still facing the same issue.
@vrahul - were you able to resolve the issue after taking the 2.12.X/2.13.X
jars?



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-jaxrs-custome-exception-mapper-with-camel-tp5749882p5761170.html
Sent from the Camel - Users mailing list archive at Nabble.com.