Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Eclipse WTP - Struts 2 config gives 404 error
Eclipse WTP - Struts 2 config gives 404 error [message #191149] Thu, 05 April 2007 18:34 Go to next message
Eclipse UserFriend
Originally posted by: manickam-periaswamy.vignesh.epamail.epa.gov

I configured Eclipse WTP for a struts-enabled web application. When I ran
my application using "run on server" option, it gives a 404 error.

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, "r5sis"
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.

Find below my struts.xml and web.xml

<?xml version="1.0" encoding="UTF-8"?>
<struts>
<!-- Include Struts 2 default (from Struts 2 JAR). -->
<include file="struts-default.xml"/>

<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">

<!-- Default interceptor stack. -->
<action name="login" class="gov.epa.r5sis.struts.action.LoginAction" >
<result name="success"
type="dispatcher">/WEB-INF/jsp/welcome.jsp</result>
<result name="error"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

<action name="logout2"
class="gov.epa.r5sis.struts.action.LoginAction" method="logout" >
<result name="success"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

<action name="logout"
class="gov.epa.r5sis.struts.action.LogoutAction" >
<result name="success"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

</package>
</struts>


<?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>r5test</display-name>
<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>


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/r5sis/" in the browser.

It gives a 404 error, saying "The requested resource (/r5sis/) is not
available." "r5sis" is my project name. Also the project is placed only in
the eclipse workspace and not in the "<tomcat dir>/webapps" folder. Even
"localhost:8080/index.jsp" gives a 404 error.

When I tried running Tomcat from the command prompt, it runs properly and
"localhost:8080/index.jsp" works fine.

So the Tomcat is not working fine inside Eclipse WTP. Please let me know
what went wrong.

Thanks
Vignesh
Re: Eclipse WTP - Struts 2 config gives 404 error [message #191158 is a reply to message #191149] Thu, 05 April 2007 20:04 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
When you create a Tomcat server within WTP, it will default to creating
a separate server instance, rather than "take ownership" of your Tomcat
installation. To see where the separate instance is found, double click
the Tomcat server in the Servers view and in the server editor that
opens, click the "Open launch configuration" link. In the launch
properties dialog, select the Arguments tab and note the setting for the
catalina.base system property in the VM Arguments field. You can have
the server in Eclipse use your Tomcat installation as the server
instance by unchecking the "Run modules directly..." check box in the
server editor and saving. Be aware that changing the server instance to
the Tomcat installation means the configuration files found under the
Servers project in your workspace become the "master" files for this
Tomcat installation. They will overwrite those in your installation
each time the Tomcat server is published or started within Eclipse.

When requesting a URL like "http://localhost:8080/r5sis/", a directory
listing is the typical response if a "welcome" file doesn't exist.
However, in Tomcat 5.5.x, directory listings are disabled by default, so
a 404 is the normal response when no "welcome" file exists. My guess is
that you don't have a "welcome" file in your WebContent folder and
adding an index.jsp to this folder would fix would avoid the 404 error.

The default server instance that WTP creates includes an "empty" default
context. This is why "http://localhost:8080/index.jsp" also displays
404. In the server editor mentioned above, you can use the Modules tab
to add external contexts to this separate instance if you would like
make them available.

Cheers,
Larry


Vignesh wrote:
> I configured Eclipse WTP for a struts-enabled web application. When I
> ran my application using "run on server" option, it gives a 404 error.
>
> 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,
> "r5sis" 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.
>
> Find below my struts.xml and web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <struts>
> <!-- Include Struts 2 default (from Struts 2 JAR). -->
> <include file="struts-default.xml"/>
>
> <!-- Configuration for the default package. -->
> <package name="default" extends="struts-default">
>
> <!-- Default interceptor stack. -->
> <action name="login"
> class="gov.epa.r5sis.struts.action.LoginAction" >
> <result name="success"
> type="dispatcher">/WEB-INF/jsp/welcome.jsp</result>
> <result name="error"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> <action name="logout2"
> class="gov.epa.r5sis.struts.action.LoginAction" method="logout" >
> <result name="success"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> <action name="logout"
> class="gov.epa.r5sis.struts.action.LogoutAction" >
> <result name="success"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> </package>
> </struts>
>
>
> <?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>r5test</display-name>
> <filter>
> <filter-name>struts</filter-name>
>
> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
> </filter>
> <filter-mapping>
> <filter-name>struts</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <welcome-file-list>
> <welcome-file>login.jsp</welcome-file>
> <welcome-file>index.html</welcome-file>
> <welcome-file>index.htm</welcome-file>
> <welcome-file>default.html</welcome-file>
> <welcome-file>default.htm</welcome-file>
> <welcome-file>default.jsp</welcome-file>
> </welcome-file-list>
> </web-app>
>
>
> 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/r5sis/" in the browser.
>
> It gives a 404 error, saying "The requested resource (/r5sis/) is not
> available." "r5sis" is my project name. Also the project is placed only
> in the eclipse workspace and not in the "<tomcat dir>/webapps" folder.
> Even "localhost:8080/index.jsp" gives a 404 error.
> When I tried running Tomcat from the command prompt, it runs properly
> and "localhost:8080/index.jsp" works fine.
>
> So the Tomcat is not working fine inside Eclipse WTP. Please let me know
> what went wrong.
>
> Thanks
> Vignesh
>
Re: Eclipse WTP - Struts 2 config gives 404 error [message #191165 is a reply to message #191158] Thu, 05 April 2007 20:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manickam-periaswamy.vignesh.epamail.epa.gov

Thanks for your detailed response.

I think it doesn't matter to me whether it runs its own instance or uses
Tomcat installation. Thanks for the clarification. I would go with its own
instance other than disturbing the Tomcat installation. So I think my
application should still work fine without making this change.

Regarding the welcome files I have mentioned in my web.xml that:

<welcome-file-list>
<welcome-file>/jsp/login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

Actually "login.jsp" is my welcome file and it is present in the
"WebContent/WEB-INF/jsp" folder and "web.xml" is in the
"WebContent/WEB-INF" folder. But still I get the same error. I even tried
placing a "index.htm" in the "WebContent" folder, but still in vain.

Please let me know what am I missing?

Thanks
Vignesh.

---------------------
Subject: Re: Eclipse WTP - Struts 2 config gives 404 error
From: Larry.Isaacs@xxxxxxxxxxxx (Larry Isaacs)
Newsgroups: eclipse.webtools
Organization: SAS Institute, Inc.
Date: Apr 05 2007 15:04:27

When you create a Tomcat server within WTP, it will default to creating a
separate server instance, rather than "take ownership" of your Tomcat
installation. To see where the separate instance is found, double click
the Tomcat server in the Servers view and in the server editor that opens,
click the "Open launch configuration" link. In the launch properties
dialog, select the Arguments tab and note the setting for the
catalina.base system property in the VM Arguments field. You can have the
server in Eclipse use your Tomcat installation as the server instance by
unchecking the "Run modules directly..." check box in the server editor
and saving. Be aware that changing the server instance to the Tomcat
installation means the configuration files found under the Servers project
in your workspace become the "master" files for this Tomcat installation.
They will overwrite those in your installation each time the Tomcat server
is published or started within Eclipse.

When requesting a URL like "http://localhost:8080/r5sis/", a directory
listing is the typical response if a "welcome" file doesn't exist.
However, in Tomcat 5.5.x, directory listings are disabled by default, so a
404 is the normal response when no "welcome" file exists. My guess is
that you don't have a "welcome" file in your WebContent folder and adding
an index.jsp to this folder would fix would avoid the 404 error.

The default server instance that WTP creates includes an "empty" default
context. This is why "http://localhost:8080/index.jsp" also displays 404.
In the server editor mentioned above, you can use the Modules tab to add
external contexts to this separate instance if you would like make them
available.

Cheers,
Larry


Vignesh wrote:

I configured Eclipse WTP for a struts-enabled web application. When I ran
my application using "run on server" option, it gives a 404 error.

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, "r5sis"
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.

Find below my struts.xml and web.xml

<?xml version="1.0" encoding="UTF-8"?>
<struts>
<!-- Include Struts 2 default (from Struts 2 JAR). -->
<include file="struts-default.xml"/>

<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">

<!-- Default interceptor stack. -->
<action name="login"
class="gov.epa.r5sis.struts.action.LoginAction" >
<result name="success"
type="dispatcher">/WEB-INF/jsp/welcome.jsp</result>
<result name="error"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

<action name="logout2"
class="gov.epa.r5sis.struts.action.LoginAction" method="logout" >
<result name="success"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

<action name="logout"
class="gov.epa.r5sis.struts.action.LogoutAction" >
<result name="success"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

</package>
</struts>


<?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>r5test</display-name>
<filter>
<filter-name>struts</filter-name>

<filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>


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/r5sis/" in the browser.

It gives a 404 error, saying "The requested resource (/r5sis/) is not
available." "r5sis" is my project name. Also the project is placed only in
the eclipse workspace and not in the "<tomcat dir>/webapps" folder. Even
"localhost:8080/index.jsp" gives a 404 error.
When I tried running Tomcat from the command prompt, it runs properly and
"localhost:8080/index.jsp" works fine.

So the Tomcat is not working fine inside Eclipse WTP. Please let me know
what went wrong.

Thanks
Vignesh
Re: Eclipse WTP - Struts 2 config gives 404 error [message #191221 is a reply to message #191165] Fri, 06 April 2007 13:09 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
I haven't worked that much with Struts, but I don't believe the
"welcome" file handling and Struts inherently work together. You can
use one or the other, but I think the "welcome" file handling will
normally bypass the Struts handling. As a result, I don't think the
"welcome" file handling will be able to reach into the "WEB-INF"
directory. The trick of hiding JSP under WEB-INF only works for
includes and forwards, which Struts does, but for "welcome" file
handling that's getting bypassed.

Also, the way "welcome" files work is that when a "directory" resource
is requested, as in the URL in this case, the server checks for the
existence of a resource matching one of those in the welcome-file list.
The first one found is served. Specifying a "welcome" file like
"jsp/loging.jsp" kind of violates the intent of this feature by
"redirecting" to a resource in a different folder. It might work for
some servers, or it might not, or may work with side effects. It's not
a "feature" I would recommend using.

Thus, to get "http://localhost:8080/r5sis/" to work correctly, I think
you will need to declare "login.jsp" as the "welcome" file and actually
create such a file in the WebContent folder of your project. To get it
to perform the "real" login, put a "<jsp:forward />" in this file that
forwards to the appropriate Struts URL that will trigger the desired
login handling. I believe this will achieve the desired effect.

Cheers,
Larry

Vignesh wrote:
> Thanks for your detailed response.
>
> I think it doesn't matter to me whether it runs its own instance or uses
> Tomcat installation. Thanks for the clarification. I would go with its
> own instance other than disturbing the Tomcat installation. So I think
> my application should still work fine without making this change.
>
> Regarding the welcome files I have mentioned in my web.xml that:
>
> <welcome-file-list>
> <welcome-file>/jsp/login.jsp</welcome-file>
> <welcome-file>index.html</welcome-file>
> <welcome-file>index.htm</welcome-file>
> <welcome-file>default.html</welcome-file>
> <welcome-file>default.htm</welcome-file>
> <welcome-file>default.jsp</welcome-file>
> </welcome-file-list>
>
> Actually "login.jsp" is my welcome file and it is present in the
> "WebContent/WEB-INF/jsp" folder and "web.xml" is in the
> "WebContent/WEB-INF" folder. But still I get the same error. I even
> tried placing a "index.htm" in the "WebContent" folder, but still in vain.
> Please let me know what am I missing?
>
> Thanks
> Vignesh.
>
> ---------------------
> Subject: Re: Eclipse WTP - Struts 2 config gives 404 error
> From: Larry.Isaacs@xxxxxxxxxxxx (Larry Isaacs)
> Newsgroups: eclipse.webtools
> Organization: SAS Institute, Inc.
> Date: Apr 05 2007 15:04:27
>
> When you create a Tomcat server within WTP, it will default to creating
> a separate server instance, rather than "take ownership" of your Tomcat
> installation. To see where the separate instance is found, double click
> the Tomcat server in the Servers view and in the server editor that
> opens, click the "Open launch configuration" link. In the launch
> properties dialog, select the Arguments tab and note the setting for the
> catalina.base system property in the VM Arguments field. You can have
> the server in Eclipse use your Tomcat installation as the server
> instance by unchecking the "Run modules directly..." check box in the
> server editor and saving. Be aware that changing the server instance to
> the Tomcat installation means the configuration files found under the
> Servers project in your workspace become the "master" files for this
> Tomcat installation. They will overwrite those in your installation
> each time the Tomcat server is published or started within Eclipse.
>
> When requesting a URL like "http://localhost:8080/r5sis/", a directory
> listing is the typical response if a "welcome" file doesn't exist.
> However, in Tomcat 5.5.x, directory listings are disabled by default, so
> a 404 is the normal response when no "welcome" file exists. My guess is
> that you don't have a "welcome" file in your WebContent folder and
> adding an index.jsp to this folder would fix would avoid the 404 error.
>
> The default server instance that WTP creates includes an "empty" default
> context. This is why "http://localhost:8080/index.jsp" also displays
> 404. In the server editor mentioned above, you can use the Modules tab
> to add external contexts to this separate instance if you would like
> make them available.
>
> Cheers,
> Larry
>
>
> Vignesh wrote:
>
> I configured Eclipse WTP for a struts-enabled web application. When I
> ran my application using "run on server" option, it gives a 404 error.
>
> 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,
> "r5sis" 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.
>
> Find below my struts.xml and web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <struts>
> <!-- Include Struts 2 default (from Struts 2 JAR). -->
> <include file="struts-default.xml"/>
>
> <!-- Configuration for the default package. -->
> <package name="default" extends="struts-default">
>
> <!-- Default interceptor stack. -->
> <action name="login"
> class="gov.epa.r5sis.struts.action.LoginAction" >
> <result name="success"
> type="dispatcher">/WEB-INF/jsp/welcome.jsp</result>
> <result name="error"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> <action name="logout2"
> class="gov.epa.r5sis.struts.action.LoginAction" method="logout" >
> <result name="success"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> <action name="logout"
> class="gov.epa.r5sis.struts.action.LogoutAction" >
> <result name="success"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> </package>
> </struts>
>
>
> <?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>r5test</display-name>
> <filter>
> <filter-name>struts</filter-name>
>
> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
> </filter>
> <filter-mapping>
> <filter-name>struts</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <welcome-file-list>
> <welcome-file>login.jsp</welcome-file>
> <welcome-file>index.html</welcome-file>
> <welcome-file>index.htm</welcome-file>
> <welcome-file>default.html</welcome-file>
> <welcome-file>default.htm</welcome-file>
> <welcome-file>default.jsp</welcome-file>
> </welcome-file-list>
> </web-app>
>
>
> 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/r5sis/" in the browser.
>
> It gives a 404 error, saying "The requested resource (/r5sis/) is not
> available." "r5sis" is my project name. Also the project is placed only
> in the eclipse workspace and not in the "<tomcat dir>/webapps" folder.
> Even "localhost:8080/index.jsp" gives a 404 error.
> When I tried running Tomcat from the command prompt, it runs properly
> and "localhost:8080/index.jsp" works fine.
>
> So the Tomcat is not working fine inside Eclipse WTP. Please let me know
> what went wrong.
>
> Thanks
> Vignesh
>
>
Re: Eclipse WTP - Struts 2 config gives 404 error [message #191230 is a reply to message #191221] Fri, 06 April 2007 17:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manickam-periaswamy.vignesh.epamail.epa.gov

Thanks a lot for your help.

I understand what you said. I removed all the welcome files and just
included,

<welcome-file-list>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>

and created "index.htm" in the "WebContent" folder, which just displays
"Hello world!". Still it doesn't work!

Now I wonder if I have done some real silly mistake. Any help?

Thanks
Vignesh

-----------------------------
Subject: Re: Eclipse WTP - Struts 2 config gives 404 error
From: Larry.Isaacs@xxxxxxxxxxxx (Larry Isaacs)
Newsgroups: eclipse.webtools
Organization: SAS Institute, Inc.
Date: Apr 06 2007 08:09:30

I haven't worked that much with Struts, but I don't believe the "welcome"
file handling and Struts inherently work together. You can use one or the
other, but I think the "welcome" file handling will normally bypass the
Struts handling. As a result, I don't think the "welcome" file handling
will be able to reach into the "WEB-INF" directory. The trick of hiding
JSP under WEB-INF only works for includes and forwards, which Struts does,
but for "welcome" file handling that's getting bypassed.

Also, the way "welcome" files work is that when a "directory" resource is
requested, as in the URL in this case, the server checks for the existence
of a resource matching one of those in the welcome-file list. The first
one found is served. Specifying a "welcome" file like "jsp/loging.jsp"
kind of violates the intent of this feature by "redirecting" to a resource
in a different folder. It might work for some servers, or it might not,
or may work with side effects. It's not a "feature" I would recommend
using.

Thus, to get "http://localhost:8080/r5sis/" to work correctly, I think you
will need to declare "login.jsp" as the "welcome" file and actually create
such a file in the WebContent folder of your project. To get it to
perform the "real" login, put a "<jsp:forward />" in this file that
forwards to the appropriate Struts URL that will trigger the desired login
handling. I believe this will achieve the desired effect.

Cheers,
Larry

Vignesh wrote:

Thanks for your detailed response.

I think it doesn't matter to me whether it runs its own instance or uses
Tomcat installation. Thanks for the clarification. I would go with its own
instance other than disturbing the Tomcat installation. So I think my
application should still work fine without making this change.

Regarding the welcome files I have mentioned in my web.xml that:

<welcome-file-list>
<welcome-file>/jsp/login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

Actually "login.jsp" is my welcome file and it is present in the
"WebContent/WEB-INF/jsp" folder and "web.xml" is in the
"WebContent/WEB-INF" folder. But still I get the same error. I even tried
placing a "index.htm" in the "WebContent" folder, but still in vain.
Please let me know what am I missing?

Thanks
Vignesh.

---------------------
Subject: Re: Eclipse WTP - Struts 2 config gives 404 error
From: Larry.Isaacs@xxxxxxxxxxxx (Larry Isaacs)
Newsgroups: eclipse.webtools
Organization: SAS Institute, Inc.
Date: Apr 05 2007 15:04:27

When you create a Tomcat server within WTP, it will default to creating a
separate server instance, rather than "take ownership" of your Tomcat
installation. To see where the separate instance is found, double click
the Tomcat server in the Servers view and in the server editor that opens,
click the "Open launch configuration" link. In the launch properties
dialog, select the Arguments tab and note the setting for the
catalina.base system property in the VM Arguments field. You can have the
server in Eclipse use your Tomcat installation as the server instance by
unchecking the "Run modules directly..." check box in the server editor
and saving. Be aware that changing the server instance to the Tomcat
installation means the configuration files found under the Servers project
in your workspace become the "master" files for this Tomcat installation.
They will overwrite those in your installation each time the Tomcat server
is published or started within Eclipse.

When requesting a URL like "http://localhost:8080/r5sis/", a directory
listing is the typical response if a "welcome" file doesn't exist.
However, in Tomcat 5.5.x, directory listings are disabled by default, so a
404 is the normal response when no "welcome" file exists. My guess is
that you don't have a "welcome" file in your WebContent folder and adding
an index.jsp to this folder would fix would avoid the 404 error.

The default server instance that WTP creates includes an "empty" default
context. This is why "http://localhost:8080/index.jsp" also displays 404.
In the server editor mentioned above, you can use the Modules tab to add
external contexts to this separate instance if you would like make them
available.

Cheers,
Larry


Vignesh wrote:

I configured Eclipse WTP for a struts-enabled web application. When I ran
my application using "run on server" option, it gives a 404 error.

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, "r5sis"
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.

Find below my struts.xml and web.xml

<?xml version="1.0" encoding="UTF-8"?>
<struts>
<!-- Include Struts 2 default (from Struts 2 JAR). -->
<include file="struts-default.xml"/>

<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">

<!-- Default interceptor stack. -->
<action name="login"
class="gov.epa.r5sis.struts.action.LoginAction" >
<result name="success"
type="dispatcher">/WEB-INF/jsp/welcome.jsp</result>
<result name="error"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

<action name="logout2"
class="gov.epa.r5sis.struts.action.LoginAction" method="logout" >
<result name="success"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

<action name="logout"
class="gov.epa.r5sis.struts.action.LogoutAction" >
<result name="success"
type="redirect">/WEB-INF/jsp/login.jsp</result>
</action>

</package>
</struts>


<?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>r5test</display-name>
<filter>
<filter-name>struts</filter-name>

<filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
</filter>
<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>


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/r5sis/" in the browser.

It gives a 404 error, saying "The requested resource (/r5sis/) is not
available." "r5sis" is my project name. Also the project is placed only in
the eclipse workspace and not in the "<tomcat dir>/webapps" folder. Even
"localhost:8080/index.jsp" gives a 404 error.
When I tried running Tomcat from the command prompt, it runs properly and
"localhost:8080/index.jsp" works fine.

So the Tomcat is not working fine inside Eclipse WTP. Please let me know
what went wrong.

Thanks
Vignesh
Re: Eclipse WTP - Struts 2 config gives 404 error [message #191246 is a reply to message #191230] Mon, 09 April 2007 12:05 Go to previous message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1310
Registered: July 2009
Senior Member
My Struts knowledge, besides being rusty, never was that extensive in
the first play. Thus, on sight, I can't say if there is anything amiss
in your configuration. You could try creating another Dynamic Web
Project with just a welcome file and then start adding your Struts
configuration and see a what point the welcome file stops working. Then
research why that change is having the unexpected impact.

Cheers,
Larry

Vignesh wrote:
> Thanks a lot for your help.
>
> I understand what you said. I removed all the welcome files and just
> included,
>
> <welcome-file-list>
> <welcome-file>index.htm</welcome-file>
> </welcome-file-list>
>
> and created "index.htm" in the "WebContent" folder, which just displays
> "Hello world!". Still it doesn't work!
>
> Now I wonder if I have done some real silly mistake. Any help?
>
> Thanks
> Vignesh
>
> -----------------------------
> Subject: Re: Eclipse WTP - Struts 2 config gives 404 error
> From: Larry.Isaacs@xxxxxxxxxxxx (Larry Isaacs)
> Newsgroups: eclipse.webtools
> Organization: SAS Institute, Inc.
> Date: Apr 06 2007 08:09:30
>
> I haven't worked that much with Struts, but I don't believe the
> "welcome" file handling and Struts inherently work together. You can
> use one or the other, but I think the "welcome" file handling will
> normally bypass the Struts handling. As a result, I don't think the
> "welcome" file handling will be able to reach into the "WEB-INF"
> directory. The trick of hiding JSP under WEB-INF only works for
> includes and forwards, which Struts does, but for "welcome" file
> handling that's getting bypassed.
>
> Also, the way "welcome" files work is that when a "directory" resource
> is requested, as in the URL in this case, the server checks for the
> existence of a resource matching one of those in the welcome-file
> list. The first one found is served. Specifying a "welcome" file like
> "jsp/loging.jsp" kind of violates the intent of this feature by
> "redirecting" to a resource in a different folder. It might work for
> some servers, or it might not, or may work with side effects. It's not
> a "feature" I would recommend using.
>
> Thus, to get "http://localhost:8080/r5sis/" to work correctly, I think
> you will need to declare "login.jsp" as the "welcome" file and actually
> create such a file in the WebContent folder of your project. To get it
> to perform the "real" login, put a "<jsp:forward />" in this file that
> forwards to the appropriate Struts URL that will trigger the desired
> login handling. I believe this will achieve the desired effect.
>
> Cheers,
> Larry
>
> Vignesh wrote:
>
> Thanks for your detailed response.
>
> I think it doesn't matter to me whether it runs its own instance or uses
> Tomcat installation. Thanks for the clarification. I would go with its
> own instance other than disturbing the Tomcat installation. So I think
> my application should still work fine without making this change.
>
> Regarding the welcome files I have mentioned in my web.xml that:
>
> <welcome-file-list>
> <welcome-file>/jsp/login.jsp</welcome-file>
> <welcome-file>index.html</welcome-file>
> <welcome-file>index.htm</welcome-file>
> <welcome-file>default.html</welcome-file>
> <welcome-file>default.htm</welcome-file>
> <welcome-file>default.jsp</welcome-file>
> </welcome-file-list>
>
> Actually "login.jsp" is my welcome file and it is present in the
> "WebContent/WEB-INF/jsp" folder and "web.xml" is in the
> "WebContent/WEB-INF" folder. But still I get the same error. I even
> tried placing a "index.htm" in the "WebContent" folder, but still in vain.
> Please let me know what am I missing?
>
> Thanks
> Vignesh.
>
> ---------------------
> Subject: Re: Eclipse WTP - Struts 2 config gives 404 error
> From: Larry.Isaacs@xxxxxxxxxxxx (Larry Isaacs)
> Newsgroups: eclipse.webtools
> Organization: SAS Institute, Inc.
> Date: Apr 05 2007 15:04:27
>
> When you create a Tomcat server within WTP, it will default to creating
> a separate server instance, rather than "take ownership" of your Tomcat
> installation. To see where the separate instance is found, double click
> the Tomcat server in the Servers view and in the server editor that
> opens, click the "Open launch configuration" link. In the launch
> properties dialog, select the Arguments tab and note the setting for the
> catalina.base system property in the VM Arguments field. You can have
> the server in Eclipse use your Tomcat installation as the server
> instance by unchecking the "Run modules directly..." check box in the
> server editor and saving. Be aware that changing the server instance to
> the Tomcat installation means the configuration files found under the
> Servers project in your workspace become the "master" files for this
> Tomcat installation. They will overwrite those in your installation
> each time the Tomcat server is published or started within Eclipse.
>
> When requesting a URL like "http://localhost:8080/r5sis/", a directory
> listing is the typical response if a "welcome" file doesn't exist.
> However, in Tomcat 5.5.x, directory listings are disabled by default, so
> a 404 is the normal response when no "welcome" file exists. My guess is
> that you don't have a "welcome" file in your WebContent folder and
> adding an index.jsp to this folder would fix would avoid the 404 error.
>
> The default server instance that WTP creates includes an "empty" default
> context. This is why "http://localhost:8080/index.jsp" also displays
> 404. In the server editor mentioned above, you can use the Modules tab
> to add external contexts to this separate instance if you would like
> make them available.
>
> Cheers,
> Larry
>
>
> Vignesh wrote:
>
> I configured Eclipse WTP for a struts-enabled web application. When I
> ran my application using "run on server" option, it gives a 404 error.
>
> 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,
> "r5sis" 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.
>
> Find below my struts.xml and web.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <struts>
> <!-- Include Struts 2 default (from Struts 2 JAR). -->
> <include file="struts-default.xml"/>
>
> <!-- Configuration for the default package. -->
> <package name="default" extends="struts-default">
>
> <!-- Default interceptor stack. -->
> <action name="login"
> class="gov.epa.r5sis.struts.action.LoginAction" >
> <result name="success"
> type="dispatcher">/WEB-INF/jsp/welcome.jsp</result>
> <result name="error"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> <action name="logout2"
> class="gov.epa.r5sis.struts.action.LoginAction" method="logout" >
> <result name="success"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> <action name="logout"
> class="gov.epa.r5sis.struts.action.LogoutAction" >
> <result name="success"
> type="redirect">/WEB-INF/jsp/login.jsp</result>
> </action>
>
> </package>
> </struts>
>
>
> <?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>r5test</display-name>
> <filter>
> <filter-name>struts</filter-name>
>
> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher </filter-class>
> </filter>
> <filter-mapping>
> <filter-name>struts</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
> <welcome-file-list>
> <welcome-file>login.jsp</welcome-file>
> <welcome-file>index.html</welcome-file>
> <welcome-file>index.htm</welcome-file>
> <welcome-file>default.html</welcome-file>
> <welcome-file>default.htm</welcome-file>
> <welcome-file>default.jsp</welcome-file>
> </welcome-file-list>
> </web-app>
>
>
> 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/r5sis/" in the browser.
>
> It gives a 404 error, saying "The requested resource (/r5sis/) is not
> available." "r5sis" is my project name. Also the project is placed only
> in the eclipse workspace and not in the "<tomcat dir>/webapps" folder.
> Even "localhost:8080/index.jsp" gives a 404 error.
> When I tried running Tomcat from the command prompt, it runs properly
> and "localhost:8080/index.jsp" works fine.
>
> So the Tomcat is not working fine inside Eclipse WTP. Please let me know
> what went wrong.
>
> Thanks
> Vignesh
>
>
Previous Topic:3.3M6 SDK, but no WTP
Next Topic:JBoss 4 / EJB3 serverdefinition for JavaEE5 /WTP 2.0
Goto Forum:
  


Current Time: Thu Nov 27 13:29:52 GMT 2014

Powered by FUDForum. Page generated in 0.01913 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software