Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nullpointerexception in Tomcat

 
Jeff Johnston
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application that I developed and tested successfully in JDeveloper. It is going to eventually be put on a Tomcat server in production. I am trying to test it on Tomcat running on my machine. I took the .war created in JDeveloper and put it in the Tomcat webapps directory, started Tomcat, and got the app's initial html form displayed in a browser. But when I tried to submit the form info to a servlet, I got this exception:

java.lang.NullPointerException
cu.servlets.telcomreq.TelcomReqServlet.getPidStuff(TelcomReqServlet.java:223)
cu.servlets.telcomreq.TelcomReqServlet.processFormInfo(TelcomReqServlet.java:136)
cu.servlets.telcomreq.TelcomReqServlet.doPost(TelcomReqServlet.java:41)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Line 223 in the servlet seems like a totally random place to get this exception. I am mostly clueless about Tomcat. Is this some sort of configuration issue with Tomcat, the servlet, both, neither? Please help. Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we diagnose the problem with line 223 if you don't show it?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Miruts Yifter", please check your private messages for an important administrative matter. Thank you.
 
Jeff Johnston
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't include the code because I don't think the code is the problem...this thing works running within JDeveloper. But here is a snippet:

Line 223 is phone = at.get().toString(); I have an older version of the app that does not have the above code, and works fine in Oracle App Server environment. Put that in Tomcat on my machine, and ran it. Got the nullpointerexception on this line of code:

if (area.equals("CU-P"))
production = 1;

I think I need to change something, maybe the web.xml, to make it run correctly in Tomcat. Any ideas are appreciated. Thanks.


[BPSouther: Added code tags]
[ February 28, 2008: Message edited by: Ben Souther ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read Paul's message?
 
Jeff Johnston
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's pretty clear that at = ats.get("telephoneNumber"); is returning null. This is causing the NullPointerException (NPE) to be thrown when you try to call phone = at.get().toString();

Where are you setting this attribute?
Are you verifying that it isn't null?

What is en?
How is it being populated?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic