Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3979396
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:09:54+00:00 2026-05-20T05:09:54+00:00

I am using the RESTEasy Spring MVC integration (springmvc-resteasy using RestEasy 2.0, Spring 3.0)

  • 0

I am using the RESTEasy Spring MVC integration (springmvc-resteasy using RestEasy 2.0, Spring 3.0) I would like to map my application exceptions to HTTP responses by declaring the RESTEasy exception mapping providers. Currently my application does not explicitly extend javax.ws.rs.core.Application and ideally I would like to rely on the framework’s automatic scanning of exception mapping providers.

Here is what one of my exception mappers looks like.

@Provider public class MyAppExceptionMapper implements ExceptionMapper<MyAppException> {
    public Response toResponse(MyAppException exception) {
            return Response.status(Response.Status.BAD_REQUEST).build();
    } 
}

And my exception class looks like this

public class MyAppException extends RuntimeException {
    public MyAppException(String s, Throwable t) {
     super(s,t);
    }
}

When my application throws a MyAppException, it does not get mapped to a HTTP-400 response (I get the usual HTTP-500 from the framework)

Is there something I am missing? If this is a problem with not "registering" the provider with the framework, how do I register my exception mappers when I am using springmvc-resteasy?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:09:55+00:00Added an answer on May 20, 2026 at 5:09 am

    I received an answer from Solomon Duskis that I am posting here to make sure other folks who run into this issue can solve it quickly. As I suspected, I had to somehow configure Spring to configure RESTEasy to scan for my exception mapping provider. I added a @Component to my exception mapper and it does work for mapping MyAppException to the right HTTP response code (in this case 400 instead of 500). However, here’s a caveat: MyAppException is not serialized by RESTEasy because “java.lang.StackTraceElement does not have a no-arg default constructor.” I am looking for a solution for this secondary issue.

    You can either customize the component-scan to @Providers, or add
    a @Component to your exception mapper to add it to your context. Here’s how you can scan from @Providers:

    <context:component-scan base-package="bean">
        <context:include-filter type="annotation" expression="javax.ws.rs.ext.Provider"/>
    </context:component-scan>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I am using seam with EJB3 + JSF and I would like to add
I'm using RESTEasy services in my application and now I'm forced to get the
Is there an easy, not using spring, way to have RESTeasy return a jsp
My service side code is implemented using Resteasy @GET @Path(/ad-details/{query}) @Produces(application/json) public String getAdDetails(@PathParam(query)
In one of our projects we are using the spring mvc. The spring mvc
Using ASP.NET MVC there are situations (such as form submission) that may require a
I am using the RestEasy library to do JAX-RS web services. I am not
I'm developing a REST-ful web service using RESTEasy deployed on Tomcat. I've configured an
I would like to create a RESTful app on Google App Engine. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.