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 6019421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:25:09+00:00 2026-05-23T03:25:09+00:00

I need some direction how to best use Exceptions in a Java EE environment,

  • 0

I need some direction how to best use Exceptions in a Java EE environment, serving clients via JAX-RS.

At the moment, I have a number of exceptions, all extending RuntimeException, and annotated with @ApplicationException(rollback=false). In order to transport them to the clients, they carry a JAXB-annotated entity; and an ExceptionMapper is ready to convert them to proper, meaningful HTTP Responses (HTTP Status codes included).

I have nothing specified regarding transactional behaviour, so I guess it defaults to CMT.

Great stuff so far: when the server decides, it cannot fulfill a request, because input data is not valid/sufficient/whatever, it throws one of my BadRequestException, which makes it to the JAX-RS resource, where it gets mapped to a HTTP Response. Client is informed about what went wrong.

The issue I have is that I always get a javax.ejb.TransactionRolledbackLocalException, caused by BadRequestException! I don’t want the transaction to be rolled back! The @ApplicationException seems to be ignored…

Should I not extend from RuntimeException but rather use checked exceptions? I though @ApplicationException was supposed to be the right way…

For background information: all of my Exceptions leave the container/beans in a working state. No need for the bean instance to be destroyed or stuff like that.

  • 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-23T03:25:10+00:00Added an answer on May 23, 2026 at 3:25 am

    Ok, turns out reading the manuals does help sometimes :).

    An @ApplicationException is by definition not a RuntimeException. In fact, throwing RuntimeExceptions seems to be a very bad idea, that’s what’ll tear down a bean instance, rollback transactions, etc.

    After switching everything to be based on checked Exceptions, my code not only looks much better, the IDE supports me much better as well. And it works like a charm. Now I can control, if my ApplicationException should cause transaction rollback or not.

    I found this link useful, even though it describes it for Bea Weblogic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a website using MVC3 along with the Razor view engine. What
I'm a long-time client-side (Swing) developer and I operated pretty much by myself in
I'm building an app that requires downloading a lot of html5 content. Essentially it
I'm a Delphi, Ruby, and Javascript programmer that is finally learning C - starting
Hopefully this question won't be too convoluted or vague. I know what I want
I realize there are several solutions to this problem. I am looking for advice
I'm trying to figure out to create a behavior that will copy a boolean
I am not a LINQ power user by any means, but can fumble my
Another edition to my .htaccess rewriting saga. Everything is now working to a degree
Background Info A bug exists currently in IE9 where it thinks that the NodeFilter

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.