• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception : Server side stack traces

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
In order to manage my own exceptions in an EJB, i have created some classes extending Exception.
Now i would like to display proper messages to the final user, based on the messages defined in my exception classes.
Using standard try/catch, i can easily get reference to the exception that can occur during EJB execution.
The problem is that my message (myException.getMessage) is followed by the extra long message generated by the Server and starting with "Start server side stack trace:".
For exemple :
com.xx.ejb.myException: Can't find the price for this object (objId=7569, sizeCode=LI, colorCode=2)
Start server side stack trace: com.xx.ejb.myException: Can't find the price for this object (objId=7569, sizeCode=LI, colorCode=2)
at com.xx.ObjectAccess.getObjectPrice(Unknown Source)
at com.xx.ejb.ObjectBusinessService.getObjectPrice(Unknown Source)
<....>
about 20 lines here !!
<....>
Any idea about how to avoid the extra message ??
NB : I'm using BEA WebLogic Server v7.0 SP2
Thanx in advance
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A quick solution. One of the standard ways to pick messages are to store them in resource bundles against a key. In your exceptions pass some specific key to the constructor while throwing them.
Then when the client catches it, extract the key, look up the resource bundle and get the corresponding message and display it to the user.
That way your error messages can be internationlized as well.
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Catch the exception and display appropriate message for that exception.
If a single exception has different messages then search for the string in the exception message.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic