aspose file tools*
The moose likes Struts and the fly likes Problem while running struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem while running struts application" Watch "Problem while running struts application" New topic
Author

Problem while running struts application

Rahul B. Shah
Greenhorn

Joined: Jan 17, 2011
Posts: 24
Hello everybody,
I am new to struts & working on login application where keep on getting following exception :


type Exception report

message

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

exception

org.apache.jasper.JasperException: Module 'null' not found.
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:498)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)


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:127)
org.apache.jsp.login_jsp._jspService(login_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

please have a look at my files :

web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>FreshStruts1</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>

------------------------------------------------------------------------------------------------------------------------------------------
struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

<struts-config>
<form-beans>
<form-bean name="LoginForm" type="freshstrutsform.LoginForm"/>
</form-beans>

<global-forwards>
<forward name="login" path="/login.do"/>
</global-forwards>

<action-mappings>
<action path="/login"
type="freshstrutsaction.LoginAction"
name="LoginForm"
scope="session">
<forward name="success" path="/success.jsp" />
<forward name="failure" path="/failure.jsp" />
</action>
</action-mappings>
</struts-config>

------------------------------------------------------------------------------------------------------------------------------------------

LoginForm.java

package freshstrutsform;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm
{
private String userName="";
private String password="";

public LoginForm()
{
super();
}

public ActionErrors validate(ActionMapping mapping,HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if(userName == null || userName.length() < 1)
{
errors.add("userName",new ActionMessage("error.userName.required"));
}
else if(password == null || password.length() < 1)
{
errors.add("password",new ActionMessage("error.password.required"));
}
return errors;
}

public String getUserName()
{
return userName;
}

public void setUserName(String usr)
{
this.userName = usr;
}

public String getPassword()
{
return password;
}

public void setPassword(String psswd)
{
this.password = psswd;
}
}

------------------------------------------------------------------------------------------------------------------------------------------

LoginAction.java

package freshstrutsaction;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;

import freshstrutsform.LoginForm;

public class LoginAction extends Action
{
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
{
LoginForm loginForm = (LoginForm)form;
if(loginForm.getUserName().equalsIgnoreCase(loginForm.getPassword()))
{
return mapping.findForward("success");
}
else
{
return mapping.findForward("failure");
}
}
}

------------------------------------------------------------------------------------------------------------------------------------------

login.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
<title>Login_Page</title>
</head>
<body>
<div style="color:red">
<html:errors/>
</div>
<html:form action="/login">
UserName: <html:text name="LoginForm" property="userName" />
Password: <html:password name="LoginForm" property="password" />
<html:submit value="LOGIN" />
</html:form>
</body>
</html>

------------------------------------------------------------------------------------------------------------------------------------------

success.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Success_Page</title>
</head>
<body>
<h1>SUCCESS</h1>
</body>
</html>

----------------------------------------------------------------------------------------------------------------------------------------

failure.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Failure_Page</title>
</head>
<body>
<h1>FAILURE</h1>
</body>
</html>

-----------------------------------------------------------------------------------------------------------------------------------------
ApplicationResource.properties

error.userName.required = User Name is required.
error.password.required = Password is required.

-----------------------------------------------------------------------------------------------------------------------------------------

also my lib folder contains following jars :
antlr-2.7.2.jar
commons-beanutils-1.6.jar
commons-chain-1.1.jar
commons-digester-1.8.jar
commons-logging-1.0.4.jar
commons-logging-api-1.1.jar
commons-validator-1.3.0.jar
oro-2.0.8.jar
struts-core-1.3.10.jar
struts-taglib-1.3.10.jar
struts-tiles-1.3.10.jar

------------------------------------------------------------------------------------------------------------------------------------------

my folder structure in apache tomcat is

webapps=>FreshStruts1=>META-INF(MANIFEST.MF),WEB-INF(lib,classes,web.xml,struts-config.xml,struts-html.tld) where lib has all jars & classes folder has LoginForm.java & its classfile & ApplicationResource.properties ,LoginAction.java & its class file.

I am trying to slove from past 2 days & i dont know what is wrong.

Thank-You

Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

You have to mention the struts tag libraries in deploymnet descriptor to use them.
Example,

Have Fun with Java
little,little.. little by little makes a lot..
Rahul B. Shah
Greenhorn

Joined: Jan 17, 2011
Posts: 24
Hello Shankar,
I am getting same message after adding <taglib></taglib> tag in web.xml & here is what i see in console :


SEVERE: Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency.
java.lang.NoClassDefFoundError: org/apache/commons/collections/ArrayStack
at org.apache.commons.digester.Digester.<init>(Digester.java:142)
at org.apache.struts.action.ActionServlet.initServlet(ActionServlet.java:1751)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:349)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.ArrayStack
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1438)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1284)
... 21 more
Aug 4, 2011 3:57:10 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet action as unavailable
Aug 4, 2011 3:57:10 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /FreshStruts1 threw load() exception
javax.servlet.UnavailableException: org/apache/commons/collections/ArrayStack
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:402)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Aug 4, 2011 3:57:10 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Aug 4, 2011 3:57:10 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Aug 4, 2011 3:57:10 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/18 config=null
Aug 4, 2011 3:57:10 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Aug 4, 2011 3:57:10 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1681 ms
Aug 4, 2011 3:57:10 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:127)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:84)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Rahul,
It is clear from the log that you are not adding commons-collection jar
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

This post is just beacuse I have little free time
Next time when you come across the exception "java.lang.NoClassDefFoundError", be noticed that your package doesnt have the class file to load or the class loader is trying to load some class from dependent jar files which is not available anywhere in the path. The logger itself is self explanatory that you would not require any help.
For example, java.lang.NoClassDefFoundError: org/apache/commons/collections/ArrayStack
How would i see this is, first i would verify if "org/apache/commons/collections/ArrayStack" belongs to my application. If yes, then ther eis some problem in my build procedure else i verify which jar file it belongs to and add it (quite simple, isn't it). To do the jar search I majorly use jarfinder site here.
Rahul B. Shah
Greenhorn

Joined: Jan 17, 2011
Posts: 24
Thanks Shankar it worked after adding commons-collection.jar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem while running struts application