Exception- "java.lang.NullPointerException: module" null "not found" in Java-Struts 1.3

When using the Struts 1.3 Login application on localhost 8080 (Apache Tomcat 6.0.16 server). I get the following error.

HTTP Status 500 -


Exception Report Type

message

Description The server detected an internal error () that prevented it from completing this request.

an exception

org.apache.jasper.JasperException: An exception occurred while processing the JSP / Login.jsp page on line 13

10: </head> 11: <body> 12: 13: <html:form action="/Login.do"> 14: Username : <html:text name="LoginForm" property="userName"/><br/> 15: Password : <html:password name="LoginForm" property="password"/><br/> 16: <html:submit value="Login"/> 

Stacktrace:

 org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 

The main reason

 java.lang.NullPointerException: Module 'null' not found. org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:755) org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:735) org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:818) org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:488) org.apache.jsp.Login_jsp._jspx_meth_html_005fform_005f0(Login_jsp.java:105) org.apache.jsp.Login_jsp._jspService(Login_jsp.java:78) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) 

note A complete trace of the root cause stack is available in the Apache Tomcat / 6.0.16 logs.


Apache Tomcat / 6.0.16

Login.jsp

  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Login Form</title> </head> <body> <html:form action="/Login"> Username : <html:text name="LoginForm" property="userName"/><br> Password : <html:password name="LoginForm" property="password"/><br> <html:submit value="Login"/> </html:form> </body> </html> 

Struts-config.xml

 <?xml version="1.0" encoding="UTF-8"?> <struts-config> <!-- ========== Form Bean Definitions ================================== --> <form-beans> <form-bean name="loginForm" type="org.suraj.form.LoginForm"/> </form-beans> <!-- ========== Action Mapping Definitions ============================= --> <action-mappings> <action name="loginForm" path="/Login" type="org.suraj.action.LoginAction" scope="request" input="/Login.jsp" validate="true"> <forward name="failure" path="/Failure.jsp" redirect="true"/> <forward name="success" path="/Success.jsp" redirect="true"/> </action> </action-mappings> </struts-config> 

web.xml

 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>Login</display-name> <servlet> <servlet-name>action</servlet-name> <servlet-class> org.apache.struts.action.ActionServlet </servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>Login.jsp</welcome-file> </welcome-file-list> </web-app> 

LoginForm.java

 package org.suraj.form; import org.apache.struts.action.ActionForm; public class LoginForm extends ActionForm { private static final long serialVersionUID = 1029546343415365160L; private String userName; private String password; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } 

LoginAction.java

 package org.suraj.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.suraj.form.LoginForm; public class LoginAction extends Action{ private static final long serialVersionUID = -8847579600418060362L; private final static String SUCCESS = "success"; private final static String FAILURE = "failure"; public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { LoginForm loginForm = (LoginForm) form; if (loginForm.getUserName().equals(loginForm.getPassword())) { return mapping.findForward(SUCCESS); } else { return mapping.findForward(FAILURE); } } } 
+4
source share
6 answers

This may be for several reasons. Check here

Extract link

This error occurs when you try to display the JSP before the Struts ActionServlet is initialized and active. The reasons for this error are usually either:

  • You were unable to specify 2 for the Struts ActionServlet in the web.xml file or
  • You indicated above, but the Struts ActionServlet did not initialize properly due to an error. Check log file entries
    during the period of time when the server first starts up to see if it is correctly initialized or
  • You accessed the JSP page directly without performing an action
+5
source

My problem appeared in the struts application contained in the pom.xml maven-compiler-plugin with the source / target parameter for 1.7 → reset to 1.5 / 1.6, it fixed my problem (the build was done using Java 7). This application was deployed to Tomcat 7, but using java 6. Maybe this can help someone ...

+2
source

Check if TomCat Server should start under JDK 1.7. Remember to restart the server after the change.

+1
source

Provide load at startup as 1 in the ActionServlet in web.xml. this problem fix myt.

+1
source

This may be due to an Internet problem or system code. Problem

Decision:

1) Download the http://struts.apache.org/dtds/struts-config_1_3.dtd dtd file and copy it to the web-inf folder.

2) Change the struts-config file Doctype to !DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration1.3//EN" "**struts-config_1_3.dtd**">

0
source

I had the same problem, but the solution I found was different. After I checked the catalina.out file, I realized that I was having a problem with the version of the class extended from ValidatorForm. And finally, I decided to upgrade the jdk version. This happened because I used a different version for development than the installed version in tomcat.

0
source

Source: https://habr.com/ru/post/1402586/


All Articles