Did you publish your project before starting tomcat through eclipse?
[EMAIL PROTECTED] wrote:
Hi all
This problem has been driving me crazy and I know that it should be a
simple problem. I have already posted this in this mailing list, but a
simply configuration issue is stopping my development work!! Please help.
There is a reason why I post this in the struts mailing list because a
non-struts web application works fine with Eclipse WTP.
I have written the simplest struts-enabled HelloWorld application. It
works fine if I deploy it directly to the Tomcat server. But I get a 404
error while configuring it with Eclipse WTP.
Below is my configuration:
Java - 1.4.2_13
Tomcat 5.5.23 with Java 1.4 compatible jars
Struts 2.0.6 with Java 1.4 compatible jars
Eclipse WTP 3.2.2
I created a new "dynamic web project" with Tomcat 5.5 as runtime, "test"
as "context root" and "WebContent" as "Content Directory". I copied the
struts jars to the "WebContent/WEB-INF/lib" folder. The jsp files are
placed in "WebContent/WEB-INF/jsp" folder.
The following is my folder structure:
+ WebContent
- + WEB-INF
- + classes
- struts.xml
- + jsp
- + lib
- + src
- web.xml
Following are my codes:
web.xml
<?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>test</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>
</web-app>
struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="HelloWorld" class="gov.epa.r5sis.HelloWorld"
<result>/WEB-INF/jsp/HelloWorld.jsp</result>
</action>
</package>
</struts>
HelloWorld.java
package gov.epa.r5sis;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Hello World! Struts is up
and running ...";
public String execute() throws Exception {
setMessage(MESSAGE);
return SUCCESS;
}
private String message;
public void setMessage(String message){
this.message = message;
}
public String getMessage() {
return message;
}
}
HelloWorld.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java"
import="java.sql.*" errorPage="" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Hello World!</title>
</head>
<body>
<h2><s:property value="message" /></h2>
</body>
</html>
When I run the application by using "run on server" option, the tomcat
server starts without a problem and opens the url "http://localhost
:8080/test/" in the browser. "http://localhost
:8080/test/HelloWorld.action" gives a 404 error. But the same application
deployed directly in Tomcat, works fine!!
Please help.
Thanks
Vignesh Manickam Periaswamy
Web Application Developer Intern, Information Management Section
WPTD, EPA Region 5 312-886-0887
email: [EMAIL PROTECTED]