I have a Customer who has an application which prints java.lang.NullPoinerException and no stack trace associated with this.
For example take this JSP Code (test.jsp)
<%@page import="java.util.*" %>
<%@page import="java.sql.*" %>
<%@page import="javax.sql.*" %>
<%@page import="javax.naming.*" %>
<%@page import="oracle.jdbc.pool.*" %>
<HTML>
<HEAD>
<TITLE>JSP Example</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffcc">
<CENTER>
<%
try {
String p1=null;
out.println(p1.indexOf("123"));
}
catch (Exception e1)
{
System.out.println(e1.toString());
}
%>
</CENTER>
</BODY>
</HTML>
When you run this program this only prints 09/01/15 17:58:15 java.lang.NullPointerException
and you have no idea from where this exception is coming from.
You can use JDB to find out from where this exception is coming from
Run the OC4J with the following option
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10444 -jar oc4j.jar
Now open another command prompt
run the jdb command with the following option
jdb -connect com.sun.jdi.SocketAttach:port=10444
At the jdb prompt enter the follwoing command
catch java.lang.NullPointerException
Now run your Application , when the NPE exception comes up the jdb displays the following info
Exception occurred: java.lang.NullPointerException (to be caught at: _t1._jspService(), line=58 bci=144)"thread=HTTPThreadGroup-8", _t1._jspService(), line=56 bci=135
HTTPThreadGroup-8[1]
Now type the command
where
to get the stack that is causing this problem
This will display the following stack
HTTPThreadGroup-8[1]HTTPThreadGroup-8[1] where [1] _t1._jspService (_t1.java:56) [2] com.orionserver.http.OrionHttpJspPage.service (OrionHttpJspPage.java:59) [3] oracle.jsp.runtimev2.JspPageTable.service (JspPageTable.java:462) [4] oracle.jsp.runtimev2.JspServlet.internalService (JspServlet.java:594) [5] oracle.jsp.runtimev2.JspServlet.service (JspServlet.java:518) [6] javax.servlet.http.HttpServlet.service (HttpServlet.java:856) [7] com.evermind.server.http.ServletRequestDispatcher.invoke (ServletRequestDispatcher.java:713) [8] com.evermind.server.http.ServletRequestDispatcher.forwardInternal (ServletRequestDispatcher.java:370) [9] com.evermind.server.http.HttpRequestHandler.doProcessRequest (HttpRequestHandler.java:871) [10] com.evermind.server.http.HttpRequestHandler.processRequest (HttpRequestHandler.java:453) [11] com.evermind.server.http.HttpRequestHandler.serveOneRequest (HttpRequestHandler.java:221) [12] com.evermind.server.http.HttpRequestHandler.run (HttpRequestHandler.java:122) [13] com.evermind.server.http.HttpRequestHandler.run (HttpRequestHandler.java:111) [14] oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run (ServerSocketReadHandler.java:260) [15] oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket (ServerSocketAcceptHandler.java:239) [16] oracle.oc4j.network.ServerSocketAcceptHandler.access$700 (ServerSocketAcceptHandler.java:34) [17] oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run (ServerSocketAcceptHandler.java:880) [18] com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run (ReleasableResourcePooledExecutor.java:303) [19] java.lang.Thread.run (Thread.java:595)HTTPThreadGroup-8[1]
Now we know that we got the exception from t1.jsp.
After this run the command
run to proceede further.
No comments:
Post a Comment