jsphttp-status-code-500struts-config

Java Struts 1 HTTP Status 500


I am writing my first helloworld web projet in java web JSP Struts 1. I have tried hard to fix this HTTP Status 500 error. Any help will be appreciate. Here is my githud code source: https://github.com/paeltc/Struts1Demo1.

This is the response I get:

HTTP Status 500 – Internal Server Error
Type Exception Report

Message java.lang.NullPointerException

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: java.lang.NullPointerException
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Root Cause

java.lang.NullPointerException
    org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:289)
    org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:357)
    org.apache.struts.chain.commands.CreateActionForm.execute(CreateActionForm.java:92)
    org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
    org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.

I am using Apache Tomcat/9.0.27


Solution

  • Your awkwardly-transposed package names have caused you a problem.

    Look at your struts-config.xml file:

    <form-bean name="helloStruts1Form" type="com.tpe.dev.form.HelloStruts1Form" />
    

    Now look at the only thing in your code that's named HelloStruts1Form:

    package com.dev.tpe.form;
    

    See the problem?