my dog learned polymorphism*
The moose likes Servlets and the fly likes nullpointerexception in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "nullpointerexception in Tomcat" Watch "nullpointerexception in Tomcat" New topic
Author

nullpointerexception in Tomcat

Jeff Johnston
Greenhorn

Joined: Feb 27, 2008
Posts: 3
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

Joined: Jan 10, 2002
Posts: 60063
    
  65

How can we diagnose the problem with line 223 if you don't show it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

"Miruts Yifter", please check your private messages for an important administrative matter. Thank you.
Jeff Johnston
Greenhorn

Joined: Feb 27, 2008
Posts: 3
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

Joined: Jan 10, 2002
Posts: 60063
    
  65

Did you read Paul's message?
Jeff Johnston
Greenhorn

Joined: Feb 27, 2008
Posts: 3
Yes.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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?


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: nullpointerexception in Tomcat
 
Similar Threads
mail servlet SMTP exception on Tomcat
servlet exception occurs at "dispatcher.forward()"
HTTP Status 500
request.getPart("name") in Tomcat 7
HTTP Status 500