This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Exception while configuring Struts2.1.6 with Tomcat 5.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Exception while configuring Struts2.1.6 with Tomcat 5.0" Watch "Exception while configuring Struts2.1.6 with Tomcat 5.0" New topic
Author

Exception while configuring Struts2.1.6 with Tomcat 5.0

Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
Hi,

I am new to Struts 2. While configuring Struts 2 with Tomcat 5, I received the following exception. I have searched many forums but none gave any solutions.

Here is the exception stack trace:

java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:203)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:511)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:482)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:438)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:265)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:189)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:225)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:308)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:79)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3600)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4232)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:823)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:807)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:276)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:832)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:680)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:430)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:961)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:347)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1091)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:789)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1083)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:478)
at org.apache.catalina.core.StandardService.start(StandardService.java:476)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2298)
at org.apache.catalina.startup.Catalina.start(Catalina.java:547)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:286)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:387)




Here is my web.xml file:


Here is struts.xml file
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What libraries are you deploying? What version of S2? Did you try with logging set to DEBUG level and setting devmode to true?
Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
I am using Struts 2.1.6....
I have the following jars on my classpath:

commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-lang-2.4.jar
commons-logging-1.0.4.jar
commons-net-1.4.1.jar
commons-validator-1.3.0.jar
displaytag-1.1.jar
displaytag-export-poi-1.1.jar
freemarker-2.3.13.jar
ibatis-2.3.4.726.jar
iText-2.1.3.jar
jstl.jar
log4j-1.2.15.jar
mail-1.3.3.jar
ognl-2.6.11.jar
poi-3.0-rc4-20070503.jar
spring.jar
standard.jar
struts2-convention-plugin-2.1.6.jar
struts2-core-2.1.6.jar
struts2-spring-plugin-2.0.11.1.jar
struts2-tiles-plugin-2.1.6.jar
tiles-api-2.0.6.jar
tiles-core-2.0.6.jar
tiles-jsp-2.0.6.jar
xwork-2.1.2.jar
Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
Ok I got it. I had that jar struts2-spring-plugin-2.0.11.1.jar on classpath which was causing problem. What I did was put minimum required jars. These are the minimum required jars: commons-logging-1.1.jar, freemarker-2.3.8.jar jstl.jar, ognl-2.6.11.jar, struts2-core-2.0.6.jar, xwork-2.0.1.jar
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Sidd Kulk wrote:Ok I got it. I had that jar struts2-spring-plugin-2.0.11.1.jar on classpath which was causing problem. What I did was put minimum required jars. These are the minimum required jars: commons-logging-1.1.jar, freemarker-2.3.8.jar jstl.jar, ognl-2.6.11.jar, struts2-core-2.0.6.jar, xwork-2.0.1.jar

That's a pretty old version of Struts 2; I recommend against using it.
v gang
Greenhorn

Joined: May 07, 2008
Posts: 3
I working on a project from scratch using RAD7.5,struts2.1.6,spring and hibernate. I just started integrating all these and created login page. when i tried to access the loginaction i am getting the following error.

com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn Could not find action or result
No result defined for action gov.tx.hhsc.hraps.action.LoginAction and result success
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:363).....

Here are the configurations,

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

<display-name>hrapsWeb</display-name>
<context-param>
<param-name>tilesDefinitions</param-name>
<param-value>/WEB-INF/tiles.xml</param-value>
</context-param>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/struts/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.apache.struts2.tiles.StrutsTilesListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

MY Struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.action.extension" value="action" />



<package name="gov" namespace="/hraps" extends="struts-default">
<result-types>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>

<action name="login" class="hraps.LoginAction" >
<result type="tiles">tiles.login</result>
</action>
</package>
</struts>

Tiles.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
<definition name="tiles.login" template="/base/Layout.jsp">
<put-attribute name="application" value="(HRAPS)"/>
<put-attribute name="header" value="/base/Header.jsp"/>
<put-attribute name="navigation" value=""/>
<put-attribute name="body" value="/base/Login.jsp"></put-attribute>
<put-attribute name="footer" value="/base/Footer.jsp"/>
</definition>
</tiles-definitions>

Action class

public class LoginAction extends BaseAction {

/**
*
*/
private static final long serialVersionUID = 1L;

public LoginAction() {
// TODO Auto-generated constructor stub
}

public String execute() throws Exception {
System.out.println("In LoginAction execute method");
return SUCCESS;
}

}

Login.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/struts-dojo-tags" prefix="sx"%>
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<s:form name="frmLogin" action="login" theme="simple">
<div class="ContentRow">


</div>
<div class="ContentRow">
<div class="FieldLabel" style="width:22%">
<s:label value="Employee ID:" />
</div>
<div class="Field" style="width:38%" align="left">
<s:textfield name="user.employeeData.emplid" maxlength="25" size="25" required="true" />
</div>
</div>
<div class="ContentRow">
<div class="FieldLabel" style="width:22%">
<s:label name="password" value="Password:" />
</div>
<div class="Field" style="width:38%" align="left">
<s:password name="password" maxlength="25" size="25" required="true" />
</div>
</div>
<div class="displayButton">
<s:submit name="submit" value=" Submit " onclick="return validate();" />
<s:reset name="reset" value=" Reset " />
</div>
</s:form>
</body>
</html>

Can you please help me what is wrong in my files. I am struck here.

Thanks,
gang.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception while configuring Struts2.1.6 with Tomcat 5.0
 
Similar Threads
struts 2 application not running
web.xml problem in struts2
Struts 2.1.8 + Jfree Chart + tomcat 6 + jdk 1.5.0
Action-Redirection. Very Frustrating problem
Struts2 & XWork