异常-“java.lang.NullPointerException: Module 'null' not found” in Java-Struts 1.3

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9799083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 07:46:12  来源:igfitidea点击:

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

javanullpointerexceptionstruts-1

提问by suraj_fale

While deplyoing Struts 1.3 Login application on localhost 8080 (Apache Tomcat 6.0.16 Server). I am getting following error.

在本地主机 8080(Apache Tomcat 6.0.16 服务器)上部署 Struts 1.3 登录应用程序时。我收到以下错误。

HTTP Status 500 -

HTTP 状态 500 -



type Exception report

输入异常报告

message

信息

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

说明 服务器遇到内部错误 (),阻止它完成此请求。

exception

例外

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

org.apache.jasper.JasperException:在第 13 行处理 JSP 页面 /Login.jsp 时发生异常

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)

root cause

根本原因

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 The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.

注意 Apache Tomcat/6.0.16 日志中提供了根本原因的完整堆栈跟踪。



Apache Tomcat/6.0.16

Apache Tomcat/6.0.16

Login.jsp

登录.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

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

<?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

登录操作.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);

        }
    }
}

采纳答案by Shashank Kadne

It could be for multiple reasons. Check here

这可能有多种原因。在这里查看

Extract from the link,

从链接中提取,

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

  • You failed to specify 2 for the Struts ActionServlet in your web.xml file or
  • You did specify the above, but the Struts ActionServlet didn't initialize properly because of an error. Check the log file entries
    for the time period when the Server first starts up to see if it
    initialized properly or
  • You accessed a JSP page directly without going through an action

当您在 Struts ActionServlet 初始化并处于活动状态之前尝试显示 JSP 时,会发生此错误。此错误的原因通常是:

  • 您未能在 web.xml 文件中为 Struts ActionServlet 指定 2 或
  • 您确实指定了上述内容,但 Struts ActionServlet 由于错误而未正确初始化。检查
    服务器首次启动时间段的日志文件条目,以查看它
    是否正确初始化或
  • 您直接访问了 JSP 页面,而无需通过任何操作

回答by Renjith P.N.

This may be due to internet problem or systemconfig. problem

这可能是由于互联网问题或系统配置。问题

Solution:

解决方案:

1) Download http://struts.apache.org/dtds/struts-config_1_3.dtddtd file and copy it into web-inffolder.

1) 下载http://struts.apache.org/dtds/struts-config_1_3.dtddtd 文件并将其复制到web-inf文件夹中。

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

2)将struts-config文件Doctype标签更改为!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration1.3//EN" "**struts-config_1_3.dtd**">

回答by dellasavia

Verify if the TomCat Server must be run under JDK 1.7. Don't forget restart the server after the change.

验证 TomCat 服务器是否必须在 JDK 1.7 下运行。更改后不要忘记重新启动服务器。

回答by jpenaab

I had the same problem but the solution that I found was different. After I checked the catalina.out file I realized that I had a problem with version of a class extended from ValidatorForm. And finally I solved it updating the jdk version. It happened because I was using a different version for develop than the installed version in tomcat.

我遇到了同样的问题,但我找到的解决方案不同。在检查 catalina.out 文件后,我意识到从 ValidatorForm 扩展的类的版本有问题。最后我解决了它更新jdk版本。发生这种情况是因为我使用的开发版本与 tomcat 中安装的版本不同。

回答by Nolf

My issue appeared on the struts application having in pom.xml maven-compiler-plugin with setting source/target to 1.7 -> reset it to 1.5/1.6 it fixed my issue (building was done with Java 7). This application was deployed on Tomcat 7 but using java 6. Maybe it could help somebody...

我的问题出现在 pom.xml maven-compiler-plugin 中的 struts 应用程序上,将源/目标设置为 1.7 -> 将其重置为 1.5/1.6 它解决了我的问题(构建是用 Java 7 完成的)。此应用程序部署在 Tomcat 7 上,但使用的是 java 6。也许它可以帮助某人...

回答by Pavan Kumar G

Give load on startup as 1 to ActionServlet in web.xml. this myt fix problem.

将启动时的负载作为 1 赋予 web.xml 中的 ActionServlet。这个 myt 修复问题。