• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

EJBException printing stacktrace even if handled in program

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a simple Stateless bean with a method that persists an entity. There is a JSF bean client using this method. I have declared "throws EJBException" in the stateless EJB and I catch that exception in JSF managed bean(client). The problem is that even if I am catching the EJB exception in my JSF managed bean, the container still prints out stack trace. Here is the code for ejb and jsf managed bean.

Stateless ejb - StateManager


JSF managed bean - StateBean


In the above code, if a PersistenceException is raised it is wrapped in EJBException as per ejb specs. Although this does happen, I still get stack trace in my server log. Any idea why I get a stack trace in server log.

regards,
Nirvan.
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
declaring that your ejb can throws EJBException isn't considered wise as by default any enterprise Bean instance can throw this exception (as it extends RuntimeException) to it's container to report that the invoked business method or callback method could not be completed because of an unexpected error. however to answer your question ejb container intercepts any call to your beans, throwing EJBException indicates to the container as mentioned before there is unexpected problem may be database connection problem so the ejb container should log this error for the administrator to check as it is not business logic error. In the end you can control what is logged depending on the configuration of your application server.
 
B Nirvan
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


declaring that your ejb can throws EJBException isn't considered wise as by default any enterprise Bean instance can throw this exception (as it extends RuntimeException) to it's container to report that the invoked business method or callback method could not be completed because of an unexpected error


Yes I should have thought this before. The throws clause is redundant.

however to answer your question ejb container intercepts any call to your beans, throwing EJBException indicates to the container as mentioned before there is unexpected problem may be database connection problem so the ejb container should log this error for the administrator to check as it is not business logic error. In the end you can control what is logged depending on the configuration of your application server


Yes, I think this exception is thrown under very exceptional conditions which would not occur during normal process. So it seems logical to print the trace.
Thanks for the explanation.

regards,
Nirvan.
reply
    Bookmark Topic Watch Topic
  • New Topic