0

I've got an NullPointerException while making a website with JSP(containing iBatis, Sitemesh...), but I couldn't fix it. Could anyone help me?

There's a java.lang.NullPointerException at org.apache.jsp, but I couldn't handle it. After adding or removing code lines before line 207, there's no change. The exception code is still pointing line 207.

I think I can't fix it because I'm knowledgeless about Java - JSP - HTML structure. How does the error occur?

Console says:

java.lang.NullPointerException
    at org.apache.jsp.searchList_jsp._jspService(searchList_jsp.java:207)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at startkr.util.UTF8EncodingFilter.doFilter(UTF8EncodingFilter.java:26)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
    at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

Question added:

My question was poor. What I need to know is that how to debug the NullPointerException in JSP. Because the exception occured in Java file which is compiled version of JSP.

Heedo Kim
  • 87
  • 1
  • 4
  • 16
  • 2
    Possible duplicate of [What is a Null Pointer Exception, and how do I fix it?](http://stackoverflow.com/questions/218384/what-is-a-null-pointer-exception-and-how-do-i-fix-it) – Pradeep Simha Jan 22 '16 at 04:54
  • You need to find out what line in your JSP is causing that (it's not line 207 most likely, that is the line number of the compiled version). – Thilo Jan 22 '16 at 04:54
  • 2
    He's not asking "what is a Null Pointer Exception". We need to look at your code to help solve the problem – bmarkham Jan 22 '16 at 04:56
  • Post the code of your JSP – Pritam Banerjee Jan 22 '16 at 04:58
  • @bmarkham yes, he maybe asking why NullPointerException is occuring. But in that case also above link helps OP to understand why it's happening. In question, OP is asking "How does it happen" so that link helps OP. – Pradeep Simha Jan 22 '16 at 05:01
  • 1
    @Simze so even if that post has nothing to do with JSP, the OP should be fine just by looking at it? – bmarkham Jan 22 '16 at 05:11
  • @Thilo I checked related codes (a.jsp, aDao.java, a.xml) several times but I couldn't find it. May I ask how to see the compiled version of jsp? – Heedo Kim Jan 22 '16 at 05:11
  • @PritamBanerjee It's not my own code, and some reason I can't post it. – Heedo Kim Jan 22 '16 at 05:16
  • Some Servlet containers can be put in development mode and then show you a nice error page with the JSP source in question, indicating where the error happened. – Thilo Jan 22 '16 at 05:16
  • @bmarkham Yes, I know what the exception is... But I don't know how to fix it, especially when it occurs in Java file compiled from JSP file. – Heedo Kim Jan 22 '16 at 05:23

1 Answers1

0

I believe that u must have used the try{..}catch(NullPointerExcepton np){..}. The error can be caused any of the variable inside the try{}catch() having null value and such variable is used for further processing...so please sysout the variables and check the variables have values.

Sebin Thomas
  • 279
  • 8
  • 21
  • You saves me. There's too many variables in the code, but when the scope it limited in try-catch phrase, I could easily find the error code. – Heedo Kim Jan 22 '16 at 05:40
  • @devheedoo also remove try catch for null pointer exception after solveing your problem. it is not good practice to catch null pointer exception. – bNd Jan 22 '16 at 05:57