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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:14:21+00:00 2026-06-05T15:14:21+00:00

I have a stateless session bean with a method which throws an exception (which

  • 0

I have a stateless session bean with a method which throws an exception (which extends from Exception).

@Stateless
@LocalBean
public class MyBean {
    ...
    public void myMethod() throws MyException {
        ...
    }
}

But I am not able to catch the exception.

try {
    myBean.myMethod
} catch (MyException e) {
    ...
}

Here is stack:

WARNING: StandardWrapperValve[MyServlet]: PWC1406: Servlet.service() for servlet MyServlet threw exception
java.lang.IllegalAccessError: example/MyException
at $Proxy327.myMethod(Unknown Source)
at example.EJB31_Generated_MyBean_Intf_Bean_.myMethod(Unknown Source)
at example.MyServlet.processRequest(MyServlet.java:36)
at example.MyServlet.doGet(MyServlet.java:71)
...

I think, it’s because calling the bean method goes through proxy. How can I catch the exception? Or methods throwing exceptions in a session bean should be avoided? – I hope not.

  • 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-05T15:14:22+00:00Added an answer on June 5, 2026 at 3:14 pm

    as the stacktrace shows it’s actually an IllegalAccessError which is thrown… see its API doc: http://docs.oracle.com/javase/6/docs/api/java/lang/IllegalAccessError.html

    you wont be able to catch this by adding catch (Exception e) {...}… as it’s an Error, which is not a subclass of Exception. If you REALLY want to catch it, you would have to add a catch (Throwable t) {...} which I highly discourage. Rather find the reason for the error being thrown. I think we need to see more of your code…

    As the API says “Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed”… did you redeploy on server and client to be sure to use the same interface definition?

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

Sidebar

Related Questions

I have a stateless session bean which needs access to a factory class. Is
I have a Stateless Session Bean (java ee 6, cdi) which throw events @Stateless
I have a stateless EJB-3.1 session bean containing an asynchronous method that does some
I have a stateless session bean which is exposed as webservice. There are two
i have created a demo application Using JSF & EJB 3.0 (Stateless session bean
I have a stateless session bean and a standalone-java-program acting as a client. The
I'm creating a stateless session bean (the façade) which will be used for managing
What would a stateless session bean provide over just a regular class that has
I have a stateless session bean, but I want to add a reference to
I have an EJB3 stateless session bean that uses some other ejbs to do

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.