Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another NullPointerException question

 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm wondering if one can receive a NullPointerException if there are null values for fields in a record that is being updated? In other words, is that ONE of the ways that can cause this error? The actual updating of the Oracle record does happen but I get the stack trace with NullPointerException. I'm just trying to get a lead to get started.

Thanks!
Barbara
 
Greg T Robertson
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NullPointerException is usually due to having a null object somewhere in your code that you are calling a method on. I have never seen this happen when putting a null value into a DB. If you have a stack trace it would be helpful to see.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg, here it is:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception
org.apache.jasper.JasperException: For input string: "null"
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:336)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:131)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)



root cause
java.lang.NumberFormatException: For input string: "null"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:426)
at java.lang.Integer.parseInt(Integer.java:476)
at org.apache.jsp.display_jsp._jspService(display_jsp.java:209)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:336)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:131)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)



Apache Tomcat/4.1.24-LE-jdk14




It looks like it's complaining about a number format exception. I inserted the data as a test record in the database with no problem, then I just add a word to the "comment" field. So the actual update of that field isn't doing it, right? It must be something in the update code but I'm such a newbie I was hoping for a pointer (np pun intended) in the right direction (what to look for). Thanks!!
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this is a really obvious question but if the database is being correctly updated is there just a "cosmetic loose end" that I need to tend to?
Thanks as always.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the JDBC forum...
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What code causes this exception?

Are you asking, "When inserting a number into a database, if the reference to the number object is a null reference, does the insert operation cause a null pointer exception?" It would seem to that a quick demo application would provide a good answer.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm not sure what you mean but I am able to insert data without error. When I try to update, say change a value in the comments fiedd), the update is quite successful (I can query again and get changed field). But a null pointer exception stack trace is the result of the update operation.

Possibly the programs are too complex to get an answer here but I was just hoping for some leads so I could start figuring it out myself. I am a *newbie* Java person who has tried to read as much as possible in a short time frame. I'm an Oracle DBA/UNix Sys Admin who has been given this monster system to debug as a "general IT person". My boss doesn't realize there are specialities and it can be complex to try to crossover....

*Whew* Thanks for sharing Sorry.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Barbara Norway:
... I am able to insert data without error. When I try to update, say change a value in the comments field), the update is quite successful (I can query again and get changed field). But a null pointer exception stack trace is the result of the update operation.


"insert data" ... Is the data null?

Can you spare a few lines of code? Not the whole thing, just a few lines in the vicinity of the error. If you don't know where the error is, perhaps some System.out.println statements in your code will help narrow it down.

What is the SQL you are using to do the update?

If you are inserting a word, why are you getting a NumberFormatException? What "number" is it trying to parse?
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marilyn,

I will post the code you requested tomorrow. I know I have been vague, partially because I didn't want anyone to think I was just posting code for others to debug. I will put together a much clearer response tomorrow.

I was inserting data in fields for a test record. THe data types matched the field types and were accepted through the JSP interface and into the database. I was also able to retrieve the inserted data via other JSP interface pages. When attempting to update the record (just a simple addition of a word to a comment field, say), it updated the database but the JSP page returned a NullPOinterException stack trace.

So I'm talking about a dozen or so JSP programs for inserting, deleting, updating, querying, etc. And I have about twenty five different modules with all of these functions and more. And no they're not all the same structure so programs differ based on cross references (Primary key/foreign key) relationships and various business rules. BUT, at this time, I'm just working on this isolated issue.

Thanks and until tomorrow!
Barbara
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,
I've been trying to post my code for over an hour without success. I changed all the "<" to < and all the ">" to > but still it will not post. I've read the FAQ. Is there anything else in the code I should change/delete? I see others are able to post blocks of code. I tried using the "code" UBB (but that's just for formatting I imagine) feature too but I'm still missing something.

Thanks.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This

Makes me think, that something with your jsp is wrong.
Not with the jdbc calls.

You can post display.jsp and display_jsp.java (which is somewhere in your tomcat work-directory (try os file search, if you don't know where to look).

maybe it helps

Axel
 
Junilu Lacar
Bartender
Pie
Posts: 7764
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Axel. It looks like there's a tag in display.jsp that is trying to format a number and the argument it is getting is null, hence, the NPE.
 
Barbara Norway
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone. Axel and Junilu, I will consult the .java files in the work directory and study the jsp code too, paying attention especially to the number vs. string, 0 vs. null particulars. Got a new car today so not much time to code. I will post again when (if?) I find the problem.

Thanks again.
Barbara
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic