Struts 2 Tutorial: Create Struts 2 Application in Eclipse
Struts 2 Tutorial List
- Part 1: Introduction to Struts 2 Framework
- Part 2: Create Hello World Application in Struts 2
- Part 3: Struts 2 Validation Framework Tutorial with Example
- Part 4: Struts 2 Tiles Plugin Tutorial with Example
- Part 5: Struts 2 Interceptors Tutorial with Example
- Part 6: Struts 2 File Upload and Save Example
- Part 7: Struts 2 Ajax Tutorial with Example
Things We Need
Before we starts with our first Hello World Struts 2 Example, we will need few tools.
- JDK 1.5 above (download)
- Tomcat 5.x above or any other container (Glassfish, JBoss, Websphere, Weblogic etc) (download)
- Eclipse 3.2.x above (download)
- Apache Struts2 JAR files:(download). Following are the list of JAR files required for this application.
- commons-logging-1.0.4.jar
- freemarker-2.3.8.jar
- ognl-2.6.11.jar
- struts2-core-2.0.12.jar
- xwork-2.0.6.jar
Note that depending on the current version of Struts2, the version number of above jar files may change.
Our Goal
Our goal is to create a basic Struts2 application with a Login page. User will enter login credential and if authenticated successfully she will be redirected to a Welcome page which will display message ” Howdy, <username>…!“. If user is not authenticated, she will be redirected back to the login page.

Getting Started
Let us start with our first Struts2 based application.
Open Eclipse and goto File -> New -> Project and select Dynamic Web Project in the New Project wizard screen.

After selecting Dynamic Web Project, press Next.

Write the name of the project. For example StrutsHelloWorld. Once this is done, select the target runtime environment (e.g. Apache Tomcat v6.0). This is to run the project inside Eclipse environment. After this press Finish.
Once the project is created, you can see its structure in Project Explorer.

Now copy all the required JAR files in WebContent -> WEB-INF -> lib folder. Create this folder if it does not exists.

Mapping Struts2 in WEB.xml
As discussed in the previous article (Introduction to Struts2), the entry point of Struts2 application will be the Filter define in deployment descriptor (web.xml). Hence we will define an entry of org.apache.struts2.dispatcher.FilterDispatcher class in web.xml.
Open web.xml file which is under WEB-INF folder and copy paste following code.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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>Struts2 Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
</web-app>
The above code in web.xml will map Struts2 filter with url /*. The default url mapping for struts2 application will be /*.action. Also note that we have define Login.jsp as welcome file.
The Action Class
We will need an Action class that will authenticate our user and holds the value for username and password. For this we will create a package net.viralpatel.struts2 in the source folder. This package will contain the action file.

Create a class called LoginAction in net.viralpatel.struts2 package with following content.
package net.viralpatel.struts2;
public class LoginAction {
private String username;
private String password;
public String execute() {
if (this.username.equals("admin")
&& this.password.equals("admin123")) {
return "success";
} else {
return "error";
}
}
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;
}
}
Note that, above action class contains two fields, username and password which will hold the values from form and also contains an execute() method that will authenticate the user. In this simple example, we are checking if username is admin and password is admin123.
Also note that unlike Action class in Struts1, Struts2 action class is a simple POJO class with required attributes and method.
The execute() method returns a String value which will determine the result page. Also, in Struts2 the name of the method is not fixed. In this example we have define method execute(). You may want to define a method authenticate() instead.
The ResourceBundle
ResourceBundle is very useful Java entity that helps in putting the static content away from the source file. Most of the application define a resource bundle file such as ApplicationResources.properties file which contains static messages such as Username or Password and include this with the application.
ResourceBundle comes handy when we want to add Internationalization (I18N) support to an application.
We will define an ApplicationResources.properties file for our application. This property file should be present in WEB-INF/classes folders when the source is compiled. Thus we will create a source folder called resources and put the ApplicationResources.properties file in it.
To create a source folder, right click on your project in Project Explorer and select New -> Source Folder.

Specify folder name resources and press Finish.
Create a file ApplicationResources.properties under resources folder.

Copy following content in ApplicationResources.properties.
label.username= Username
label.password= Password
label.login= Login
The JSP
We will create two JSP files to render the output to user. Login.jsp will be the starting point of our application which will contain a simple login form with username and password. On successful authentication, user will be redirected to Welcome.jsp which will display a simple welcome message.
Create two JSP files Login.jsp and Welcome.jsp in WebContent folder of your project. Copy following content into it.
Login.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Struts 2 - Login Application | ViralPatel.net</title>
</head>
<body>
<h2>Struts 2 - Login Application</h2>
<s:actionerror />
<s:form action="login.action" method="post">
<s:textfield name="username" key="label.username" size="20" />
<s:password name="password" key="label.password" size="20" />
<s:submit method="execute" key="label.login" align="center" />
</s:form>
</body>
</html>
Welcome.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h2>Howdy, <s:property value="username" />...!</h2>
</body>
</html>
Note that we have used struts2 <s:> tag to render the textboxes and labels. Struts2 comes with a powerful built-in tag library to render UI elements more efficiently.
The struts.xml file
Struts2 reads the configuration and class definition from an xml file called struts.xml. This file is loaded from the classpath of the project. We will define struts.xml file in the resources folder. Create file struts.xml in resources folder.

Copy following content into 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.custom.i18n.resources"
value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<action name="login"
class="net.viralpatel.struts2.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
</package>
</struts>
Note that in above configuration file, we have defined Login action of our application. Two result paths are mapped with LoginAction depending on the outcome of execute() method. If execute() method returns success, user will be redirected to Welcome.jsp else to Login.jsp.
Also note that a constant is specified with name struts.custom.i18n.resources. This constant specify the resource bundle file that we created in above steps. We just have to specify name of resource bundle file without extension (ApplicationResources without .properties).
Our LoginAction contains the method execute() which is the default method getting called by Sturts2. If the name of method is different, e.g. authenticate(); then we should specify the method name in <action> tag.
<action name="login" method="authenticate"
class="net.viralpatel.struts2.LoginAction">
Almost Done
We are almost done with the application. You may want to run the application now and see the result yourself. I assume you have already configured Tomcat in eclipse. All you need to do:
Open Server view from Windows -> Show View -> Server. Right click in this view and select New -> Server and add your server details.
To run the project, right click on Project name from Project Explorer and select Run as -> Run on Server (Shortcut: Alt+Shift+X, R)
But there is one small problem. Our application runs perfectly fine at this point. But when user enters wrong credential, she is redirected to Login page. But no error message is displayed. User does not know what just happened. A good application always show proper error messages to user. So we must display an error message Invalid Username/Password. Please try again when user authentication is failed.
Final Touch
To add this functionality first we will add the error message in our ResourceBundle file.
Open ApplicationResources.properties and add an entry for error.login in it. The final ApplicationResources.properties will look like:
label.username= Username
label.password= Password
label.login= Login
error.login= Invalid Username/Password. Please try again.
Also we need to add logic in LoginAction to add error message if user is not authenticated. But there is one problem. Our error message is specified in ApplicationResources.properties file. We must specify key error.login in LoginAction and the message should be displayed on JSP page.
For this we must implement com.opensymphony.xwork2.TextProvider interface which provides method getText(). This method returns String value from resource bundle file. We just have to pass the key value as argument to getText() method. The TextProvider interface defines several method that we must implement in order to get hold on getText() method. But we don’t want to spoil our code by adding all those methods which we do not intend to use. There is a good way of dealing with this problem.
Struts2 comes with a very useful class com.opensymphony.xwork2.ActionSupport. We just have to extend our LoginAction class with this class and directly use methods such as getText(), addActionErrors() etc. Thus we will extend the LoginAction class with ActionSupport class and add the logic for error reporting into it. The final code in LoginAction must look like:
package net.viralpatel.struts2;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private String username;
private String password;
public String execute() {
if (this.username.equals("admin")
&& this.password.equals("admin123")) {
return "success";
} else {
addActionError(getText("error.login"));
return "error";
}
}
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;
}
}
And that’s it. Our first Hello World Struts2 Application is now ready.
That’s All Folks
Execute the application in Eclipse and run it in your favorite browser.
Login page

Welcome page

Login page with error

Download Source Code
Click here to download Source Code without JAR files (9KB).
Moving On
Now that we have created our first webapp using Struts2 framework, we know how the request flows in Struts2. We also know the use of struts.xml and properties file. In this application we implemented a preliminary form of validation. In next part we will learn more about Validation Framework in Struts2 and implement it in our example.
Original article: http://viralpatel.net/blogs/2009/12/tutorial-create-struts-2-application-eclipse-example.html
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)





Comments
Dave Newton replied on Tue, 2010/01/19 - 10:15am
Heinrich Winter replied on Tue, 2010/06/29 - 2:41am
Pourya Shahroudi replied on Thu, 2010/07/15 - 6:41pm
Heinrich Winter if you have created struts.properties you need to add the resource there instead of the struts.xml file
struts.custom.i18n.resources=ApplicationResources,languages_actions,languages_views
This should probably solve your problem...
Sarav Sri replied on Tue, 2010/07/27 - 11:14pm
Jul 27, 2010 11:54:59 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsHelloWorld' did not find a matching property. Jul 27, 2010 11:54:59 PM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Jul 27, 2010 11:54:59 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 689 ms Jul 27, 2010 11:54:59 PM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jul 27, 2010 11:54:59 PM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.26 Jul 27, 2010 11:55:00 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger info INFO: Parsing configuration file [struts-default.xml] Jul 27, 2010 11:55:00 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger error SEVERE: Dispatcher initialization failed Unable to load configuration. - bean - jar:file:/C:/JavaDevelopment/Workspace/StrutsHelloWorld/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418) at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/C:/JavaDevelopment/Workspace/StrutsHelloWorld/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:221) at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) ... 21 more Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getDeclaredConstructors(Unknown Source) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:211) ... 24 more Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361) ... 28 more Jul 27, 2010 11:55:00 PM org.apache.catalina.core.StandardContext filterStart SEVERE: Exception starting filter struts2 Unable to load configuration. - bean - jar:file:/C:/JavaDevelopment/Workspace/StrutsHelloWorld/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178 at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431) at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:115) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) at org.apache.catalina.core.StandardService.start(StandardService.java:519) at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) at org.apache.catalina.startup.Catalina.start(Catalina.java:581) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: Unable to load configuration. - bean - jar:file:/C:/JavaDevelopment/Workspace/StrutsHelloWorld/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178 at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58) at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374) at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418) ... 19 more Caused by: Unable to load bean: type:org.apache.struts2.dispatcher.multipart.MultiPartRequest class:org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest - bean - jar:file:/C:/JavaDevelopment/Workspace/StrutsHelloWorld/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsHelloWorld/WEB-INF/lib/struts2-core-2.1.8.1.jar!/struts-default.xml:47:178 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:221) at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101) at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:169) at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55) ... 21 more Caused by: java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getDeclaredConstructors(Unknown Source) at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:211) ... 24 more Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileUploadException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361) ... 28 more Jul 27, 2010 11:55:00 PM org.apache.catalina.core.StandardContext start SEVERE: Error filterStart Jul 27, 2010 11:55:00 PM org.apache.catalina.core.StandardContext start SEVERE: Context [/StrutsHelloWorld] startup failed due to previous errors
Sarav Sri replied on Wed, 2010/07/28 - 12:06am
Jul 28, 2010 12:53:35 AM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Sun\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Sun/Java/jre6/bin/client;C:/Sun/Java/jre6/bin;C:/Sun/Java/jre6/lib/i386;C:\oracle\product\10.2.0\db_1\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\CyberLink\Power2Go\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\MySQL\MySQL Server 5.1\bin;C:\Sun\AppServer\bin;C:\Sun\Java\jdk1.6.0_20\bin
Jul 28, 2010 12:53:35 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:StrutsHelloWorld' did not find a matching property.
Jul 28, 2010 12:53:35 AM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 Jul 28, 2010 12:53:35 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 613 ms Jul 28, 2010 12:53:35 AM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jul 28, 2010 12:53:35 AM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
Jul 28, 2010 12:53:36 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.ClassNotFoundException: org.apache.struts2.dispatcher.FilterDispatcher
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:269)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3838)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4488)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
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:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Jul 28, 2010 12:53:36 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Jul 28, 2010 12:53:36 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/StrutsHelloWorld] startup failed due to previous errors
Shrinivas Krish... replied on Thu, 2010/08/05 - 1:53am
@Sarav Sri: I got the exact same errors that you have posted. After some trials, I was able to overcome them by removing all the struts jar files except the 5 jars that have are needed from my project build path.
commons-logging-1.0.4.jar, freemarker-2.3.8.jar, ognl-2.6.11.jar, struts2-core-2.0.14.jar, xwork-2.0.7.jar
Remove all the others, export your project as a war file to tomcat/webapps and start the server, your tomcat startup will be clean. If you are still facing any trouble, let us know.
I initially added all the jars from the struts-2.0.14-lib.zip, assuming that they will be needed for the remaining struts2 tutorials (2 through 7). I guess I'll find out which jars are actually needed as I progress through the remaining tuts.
@Viral Patel: Thank you for this tutorial, and the rest. They are very well written and explained. Teach by Trying works very well for me, Thank you.
Vinnie Pamula replied on Wed, 2010/09/22 - 2:22am
Sreedhar Gundavarapu replied on Thu, 2010/12/23 - 10:46pm
Leon Kuperman replied on Tue, 2011/01/11 - 4:04pm
Thanks for the excellent tutorial!
New to the Struts, I was able to configure my environment and get the example running in 2 hours.
Dilip Patel replied on Fri, 2011/03/25 - 11:04am
Gozy Hs replied on Tue, 2011/03/29 - 9:48am
Hey Guys,
I downloaded application, but whenever i run the application it gives 404 error.
I got struck in the beginning. Please some body help me.
Gozy.
Faisal Md replied on Thu, 2011/05/05 - 11:49pm
Any idea how to overcome this situation? Thanks
Duminda Duleep replied on Thu, 2011/06/02 - 5:54am
Ailia Shahid replied on Mon, 2011/06/13 - 2:20am
Dear All
Who are here to learn Struts2 with this Tute... This tute is very poor & will not work anymore... I would suggest you guys to look out for some thig else... As this tutorial simply shows To become the early bird it was written there is no testing have been done on this code... if the owner have written this on his own showld have tested it, is it working or not....
This tutorial is a copy pasted version from different sites, the owner just want to become the Early Bird of Struts2 Tutorial.
To The Owner of this Code: Dude I know it would hurt you but dear you should think if some body comes here & after working with your examples/tutorial he/she faces problem. will those buddies will come again to your tutorial... If you are trying to help someone then please do it in a way that it should be fruitful....
If your code was working on your side you should list down the steps or specifications clearly to run this app...
If you are here to sell your support services then remove the tag Tutorial... Like if somebody is having problem with your code you would give support to them & charge for that.
I have not seen a realy poor CHAIN of Tutorial on web Like this.
:(
Sana Umair replied on Wed, 2011/06/15 - 4:42am
I AM VERY NEW IN STRUTS2 ..I HAVE MADE SAME APLLICATION...BUT GETTING THIS ERROR
HTTP Status 404 -type Status report
message
description The requested resource () is not available.
Apache Tomcat/6.0.32
AND MY ECLIPSEVERSION IS Eclipse Java EE IDE for Web Developers.
Version: Helios Service Release 2
Build id: 20110218-0911
TOMCAT IS 6.0.32
CAN ANY ONE HELP ME OUT
MANY THANKS
Paul Gorbas replied on Mon, 2011/06/20 - 12:23pm
You will get a 404 error for several resons, look at your console for details. One cause that shows NO error is if your directories are read only. Eclipse will does not write projects to a read only directory, but you will get no error or warning of anyt kind.
If all else fails check your directory permissions.
Dejan Stolic replied on Wed, 2011/08/10 - 8:17am
Hi, thanks for nice and simple tutorial. It took me only few minutes to make web app and start it.
No errors at all.
I have to admit I'm surpised with few negative comments, cause this is prefect begginers tutorial for Struts 2.
Good luck and thanks again
Shakthi Nagaiyan replied on Tue, 2011/12/06 - 1:22am
Shakthi Nagaiyan replied on Tue, 2011/12/06 - 1:24am
Prabath Manjula replied on Fri, 2011/12/30 - 1:59am
Hi
I'm also getting same issue as explaned by Heinrich Winter. I would be thankful, If you can explain further more to sort out that issue. The given solution is not clear to me.
Thanks
Prabath Manjula replied on Fri, 2011/12/30 - 3:55am
Hi
I sorted out previously posted issue. After running the program i can view Login.jsp file. But After entering the username and password , unable to log in to next page. I'm getting below mentioned error in browser
java.lang.NoSuchMethodException: net.viralpatel.struts2.LoginAction.authenticate()
Please help me to sortout above mentioned issue. Thanks.
Prabath
Sindy Loreal replied on Sat, 2012/02/25 - 8:25am
While copying jar files to your lib folder just copy only following jar files..
commons-logging-1.0.4.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.12.jar
xwork-2.0.6.jar
Don’t copy entire lib folder that you have downloaded from Apache Struts2 JAR files
Ashok Bhairwal replied on Tue, 2012/03/20 - 9:39am
Mar 20, 2012 8:00:41 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
WARNING: Could not create JarEntryRevision for [jar:file:/C:/apache-tomcat-7.0.25/webapps/Struts/WEB-INF/lib/struts2-core-2.3.1.2.jar]!
java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
at com.opensymphony.xwork2.util.FileManager$JarEntryRevision.build(FileManager.java:309)
at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:145)
at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:105)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:935)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:155)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:122)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:179)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:436)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:195)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4638)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5294)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:958)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1599)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Mar 20, 2012 8:00:41 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Mar 20, 2012 8:00:41 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Struts] startup failed due to previous errors
Mar 20, 2012 8:00:41 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.25\webapps\docs
Mar 20, 2012 8:00:42 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.25\webapps\host-manager
Mar 20, 2012 8:00:42 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.25\webapps\manager
Mar 20, 2012 8:00:42 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\apache-tomcat-7.0.25\webapps\ROOT
Mar 20, 2012 8:00:42 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Mar 20, 2012 8:00:42 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Mar 20, 2012 8:00:43 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 5430 ms
============================
I am new to struts2 was following the tutorial. But I got above error, I don't know how to resolve this issue. Any one could suggest me ?
Thank you
Mohit Sharma replied on Mon, 2012/05/14 - 2:10am
hi..
this is one of the greatest tutorial i ever read
thanks
Nagarjun Vemoori replied on Wed, 2012/06/20 - 2:44am
in response to:
Ashok Bhairwal
HI Ashok,
You need to make sure that the below .jar files has to be there in your project lib folder .
1.commons-fileupload-1.2.2.jar
2.commons-io-2.0.1.jar
3.commons-lang3-3.1.jar
4.commons-logging-1.1.1.jar
5.freemarker-2.3.19.jar
6.javassist-3.11.0.GA.jar
7.ognl-3.0.5.jar
8.struts2-core-2.3.4.jar
9.xwork-core-2.3.4.jar