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

WAS 5.0 - Exception Stack Trace not printed in log file

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using WAS5.0 for a normal EJB application and I am using log4j for logging of messages.

When i get a sql exception, I am wrapping it to a NewException and throwing it back to the web layer. I catch the NewException in my servlet and print the stack trace in the servlet.

The problem is, the message "java.sql.SQLException: ORA....." message gets printed in a single line but the stack trace doesn't get printed in any of the log files. I tried to catch and print the exception in my web helper classes and it gets printed. But if I throw it back to the servlet for printing, it doesn't.

Please let me know where I am going wrong.

-
 
Marshal
Posts: 28296
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Naani Mui:
The problem is, the message "java.sql.SQLException: ORA....." message gets printed in a single line but the stack trace doesn't get printed in any of the log files.

Which one of those two things is the problem?

Stack trace shows up all on a single line in the HTML you output? That's because HTML converts newline characters to spaces -- unless you wrap your text in a <pre> element.

Stack trace doesn't get printed in any log file? You mean your log4j log files? Well, did you call any of the log4j methods to do that? You didn't say that you did.
 
Naani Mui
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that the stack trace is not getting printed.

I am wrapping the sql exception into NewException and throwing it back to the servlet. When I catch and print the NewException in servlet as follows:

catch(NewException ne){
ne.printStackTrace();
}

the stack trace is not printed. It just prints :java.sql.SQLException: ORA-0.....

For debugging, I tried to catch the exception in my helper class(before servlet) and applied the same code as above. Then I was able to get the stack trace.

But I dont know why the stack trace is lost when thrown back to the servlet.

I need to print the exception stack traces in the servlet.
 
Paul Clapham
Marshal
Posts: 28296
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Naani Mui:
The problem is that the stack trace is not getting printed.

It would help if you said what you mean by "printed". I asked if your problem was that the stack trace didn't get written to a log4j log file. You responded by ignoring that question and posting another question with even less information.

So far we have three possible destinations: the servlet response, your log4j log files, and the container's log files. Please tell us what you expected to happen.
 
Naani Mui
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you notice the first line of my previous post?

"The problem is that the stack trace is not getting printed."

I have responded to your question in the first line of my post. I dont know why you found it difficult to understand.

Moreover, I dont find any problem in using the terms "printed" or "written" or "shown up". These mean the same when we want to see any stack trace in websphere log file. printStackTrace() will write/print/show up the stack trace in log file.

Sorry if I am responding harshly. I am already in the middle of a problem. Your response is confusing me instead of helping me to find a solution.
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic