Hi, I am working on an appication, which uses struts 2 framework. After creating the war file, when deployed in tomcathome\webapps dir, and I start the server, I get the following error(below). Not sure where exactly the error is either with struts configuration or tomcat configuration.
Here is my web.xml file: <?xml version="1.0" encoding="UTF-8"?> <web-app 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"> <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>/jsp/login.jsp</welcome-file> </welcome-file-list> </web-app>
The error I get when tomcat starts(I get the message context startup failed):
Well, I don't really know, but I realized that you are using servlets 2.5. This is not compatible with tomcat 5.x, but compatible with tomcat 6.x. Either upgrade tomcat, or use servlets 2.4. Maybe this is the problem. Not sure of course
Hi Nassef, I did try with the following (I mean version 2.4 and several other configurations): <web-app 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"> ---- --- </web-app>
I tried in both the versions i.e., in tomcat 5.0.27 and tomcat 6.0.10
Hi Christophe Verre, I am also confused where is the struts-default.xml file. Why is it parsing it. If at all it should be parsing struts.xml but not struts-default.xml.
I am using eclipse 3.0. I am creating the war file through the eclipse IDE. No clue how to solve it.....
According to the struts 2 guide, struts-default.xml is
A base configuration file named struts-default.xml is included in the struts2.jar file. This file is automatically included into struts.xml file to provide the standard configuration settings without having to copy them.
Is struts.xml in /WEB-INF/classes? if so, can you paste the contents to see if there is a problem in it?
struts-default.xml is the built in configuration file that defines all of the built-in components that come with Struts 2, out of the box. I.e., this declares things like the default stack of interceptors.
The line you see is just the log statement of the Struts 2 filter running its config set up. I doubt this file is the cause of the problem . . .
Chad Davis<br />Co-author of Struts 2 in Action
K Kiran Kumar
Joined: Jan 04, 2006
My struts.xml file is in /WEB-INF/classes folder itself. I had found the file struts-default.xml. It is in struts2-core-18.104.22.168.jar.
May 1, 2008 11:49:06 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive struts2-blank-2.0.11.war May 1, 2008 11:49:07 AM com.opensymphony.xwork2.config.providers.XmlConfigurationProvider register INFO: Parsing configuration file [struts-default.xml] May 1, 2008 11:49:07 AM org.apache.catalina.core.StandardContext start SEVERE: Error filterStart May 1, 2008 11:49:07 AM org.apache.catalina.core.StandardContext start SEVERE: Context [/struts2-blank-2.0.11] startup failed due to previous errors
I guess there should be a minute configuration to be done at server side only or something to do with struts-default.xml file. Any help will be highly appreciated.
Ok, I had a similar problem today, and it came from one of my xml files not being well-formed. The problem obviously happens when the struts filter starts, but I was left with "Error filterStart" only... I thought that the filter must be logging errors somewhere, so I tried to use a SimpleLog : WEB-INF/classes/commons-logging.properties
I restarted the container, and the problem details were finally printed out in one of the container's log. So, maybe you could try to do the same, and see what gets printed out. You'll need the commons-logging library in your lib directory.
K Kiran Kumar
Joined: Jan 04, 2006
Hi Christophe Verre,
Finally with the help of logs, I fixed the issue.
A small error here.... I have the struts2-core-2.0.11.jar in my war file (FP) at FP/WEB-INF/lib/. Also there is one struts2-core-2.0.11.jar file present in tomcat/common/lib. So I have deleted the struts2-core-2.0.11.jar file in tomcat/common/lib dir since as per my understanding, it is trying to load this jar once again and failing to do so because it has already loaded it.
I have done the settings for logs that you suggested. Here is what it gives me in the logs: ------------------ 2008-05-02 13:59:01 StandardContext[/FP]Exception starting filter struts2 Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/D:/Tomcat%205.27/jakarta-tomcat-5.0.27/webapps/FP/WEB-INF/lib/struts2-core-2.0.11.jar!/struts-default.xml:30:72 at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:208) at . . . org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101) (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:284) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:422)
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file D:/Tomcat 5.27/jakarta-tomcat-5.0.27/common/lib/struts2-core-22.214.171.124.jar!/struts-default.xml:30:72 - bean - jar:file:/D:/Tomcat%205.27/jakarta-tomcat-5.0.27/webapps/FP/WEB-INF/lib/struts2-core-2.0.11.jar!/struts-default.xml:30:72at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:193) ... 34 more -------------------
Thanks a lot Christophe and others for assisting me.
Regards, Kiran. [ May 02, 2008: Message edited by: K Kiran Kumar ]