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

  • SEARCH
  • Home
  • 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 8403443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:20:48+00:00 2026-06-09T22:20:48+00:00

A simple throw new WebApplicationException(400); or any other throw new … Gets thrown by

  • 0

A simple

throw new WebApplicationException(400);

or any other

throw new ...

Gets thrown by javax.ejb.EJBException with the Caused by: being the exception you just threw. When monitoring the log, this is a pain because not every exception prints a stack trace. But EJBException does that. >:(

Please understand – EJBException does not affect the application at all, only that it prints an unwanted stack trace with every thrown exception.

The EJBException javadoc says:

The EJBException is thrown to report that the invoked business method
or callback method could not be completed because of an unexpected
error (e.g. the instance failed to open a database connection).

There must be a way to keep EJBException quiet…

(Update) Example:

@Stateless
@Path("roads")
public class RoadsREST {

    @PersistenceContext(unitName = "rd")

    @GET
    @Produces("application/json")
    public List<NationalRoads> retrieve() {

        CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
        Root subs = cq.from(NationalRoads.class);

        List<NationalRoads> roads = em.createQuery(cq).getResultList();

        if (roads.isEmpty()) {
            throw new WebApplicationException(404);
        }

        return roads;
    }

}
  • 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-06-09T22:20:50+00:00Added an answer on June 9, 2026 at 10:20 pm

    Simplest solution would be to create a subclass of WebApplicationException and annotate it with @ApplicationException, like so:

    @ApplicationException
    public class RESTException extends WebApplicationException {
        private static final long serialVersionUID = 1L;
        public RESTException(Status status, String msg) {
            super(Response.status(status).entity(msg).type(MediaType.TEXT_PLAIN).build());
        }
    }
    

    this should stop the Exceptions from appearing in your logfiles as well

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

Sidebar

Related Questions

* Simple question : Why does this function throw an exception when evaluated ?
Argument exception error is thrown at the following code. It's a simple code but
I have an simple (webprofile) EJB 3.1 Application and try do determine the current
I'm looking to learn how to throw a super simple exception in java. I
I know throw new Exception(); has a pretty large overhead, since it creates a
I am new to WPF, I am using VS2010 beta2, .NET 4.0. Throw new
I got a simple List of ints. List<int> myInts = new List<int>(); myInts.Add(0); myInts.Add(1);
I'm looking for a simple method of converting between java.util.Date and javax.xml.datatype.XMLGregorianCalendar in both
The android.jar found in android-sdk is simply a stub. All methods will throw a
What am I doing wrong? Simple recursion a few thousand calls deep throws a

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.