Topic
No replies
SystemAdmin
SystemAdmin
9394 Posts
ACCEPTED ANSWER

Pinned topic getStackTrace is not working in websphere

‏2009-06-30T09:27:57Z |
Hi!
I am using getStackTrace() method of Throwable in my code snippet but it not supported in websphere 5.1 .JDK 1.4 we are using .I come to know this problem occurs because of ServletErrorReport method getStackTrace clashes with Throwable getStackTrace().Belwo mention is the code snippet.This code is working in Tomcat.Please provide the alternative way to handle the problem in websphere.
---------1st approach------
private static void dbmsLogEntry(Connection conn) throws Exception {
Throwable e = new Throwable();

StackTraceElement elem[] = e.getStackTrace();
System.out.println(elem.toString());

for (int i = 0 ; i < elem.length; i++) {

if (elem[i].getFileName().toUpperCase().indexOf("DAO") != -1) {
logger.info("module name---------+++++"+elem[i].getFileName());
logger.info("method name---------+++++"+elem[i].getMethodName());
conn.prepareCall("{call dbms_application_info.set_module('" elem[i].getFileName() "', '" elem[i].getMethodName()"' )}").execute();
break;

}

}

}

2nd Approach I used reflection api...then also not working
private static void dbmsLogEntry(Connection conn) throws Exception {
Throwable e = new Throwable();
Method methods[] = e.getClass().getDeclaredMethods();
StackTraceElement elem[]=null;
String methodName="getOurStackTrace";
for(int i=0;i<methods.length;i++)
{ System.out.println("methodname"+methods[i].getName());
if(methodName.equals(methods[i].getName()))
{
methods[i].setAccessible(true);
elem= (StackTraceElement[])methods[i].invoke(e, null);

}
}

System.out.println(elem.length);

for (int i = 0 ; i < elem.length; i++) {

if (elem[i].getFileName().toUpperCase().indexOf("DAO") != -1) {
System.out.println("module name---------+++++"+elem[i].getFileName());
System.out.println("method name---------+++++"+elem[i].getMethodName());
conn.prepareCall("{call dbms_application_info.set_module('" elem[i].getFileName() "', '" elem[i].getMethodName()"' )}").execute();
break;

}

}