File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes java.lang.NullPointerException in a simple servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "java.lang.NullPointerException in a simple servlet" Watch "java.lang.NullPointerException in a simple servlet" New topic
Author

java.lang.NullPointerException in a simple servlet

matt love
Ranch Hand

Joined: Jan 25, 2010
Posts: 65
I am having difficulty with a simple servlet.

If I utilize org.apache.struts.action.ActionServlet in the web-app/servlet/servlet-class attribute, then the welcome-file comes up fine.

If I use my own servlet, servlet2, then I get
“SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException: Module 'null' not found.”, and a blank page.

Using a println, I know servlet2.init() method is firing ok.

It looks to me, a newbie, that the container can’t find a moduleConfig object. But, neither GenericServlet or HttpServlet reference this module. And my servlet doesn’t reference it. ActionServlet does provide a method which returns this object.

I included ActionServlet’s getModuleConfig(HttpServletRequest request) in my servlet, but received the same result. Based upon the println, control doesn’t reach this method anyway.

Code is below.

As an aside, do the parentheses in “return (config);” have any significance?

Many thanks.

Matt

loginPackage.servlet2.java



--------------------------------------------
Web.xml
--------------------------------------------
struts-config
--------------------------------------------
stack trace
Feb 22, 2010 3:52:28 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException: Module 'null' not found.
at org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:755)
at org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:735)
at org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:818)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:488)
at org.apache.jsp.login_jsp._jspx_meth_html_005fform_005f0(login_jsp.java:168)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:100)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:619)

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.

Also, please UseCodeTags.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How are you accessing the page with the Struts form on it? If you're not getting there via an action, you'll get any of several errors; I can't remember which at this point.

Why are you writing a replacement action servlet? Heck, why are you using Struts 1.0 (or 1.1, can't tell)? Why do you have TLD definitions in the web.xml, are you running on a very old container?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NullPointerException in a simple servlet
 
Similar Threads
struts forward link?
Servlet action is not available
Struts module problem
servlet action is not available
error while creating struts application