I finally got it! I spotted this attribute: <wb-module
deploy-name="MyProject"/> in org.eclipse.wst.common.component (see
below). I changed that and the context root to "/" and now I can access
my actions from the server root (http://localhost/foo.action)!
Thanks a lot for your help!
/Emil
-----org.eclipse.wst.common.component-----
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="MyProject">
<wb-resource deploy-path="/" source-path="/content"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<wb-resource deploy-path="/WEB-INF/classes"
source-path="/build/classes"/>
<wb-resource deploy-path="/WEB-INF/classes"
source-path="/classpath"/>
<property name="java-output-path"/>
<property name="context-root" value="MyProject"/>
</wb-module>
</project-modules>
---end org.eclipse.wst.common.component---
Dave Newton skrev:
The struts.xml file should be deployed to the classpath; this is correct
behavior.
See that "context-root" property? That's the *application context* (which you can discover more easily than that). Your URLs, then, will look like this:
http://localhost/MyProject/baz.action
Dave
Alberto Flores skrev:
I think this is hardly a Struts question, but an Eclipse question
(which granted could be a bit complicated when not understanding WTP
well enough).
I'm going to assume that the following assumptions are true:
- You are using WTP in Eclipse.
- You are using Eclipse 3.3.x
- You are working on a "Dynamic Web Project"
- You are using Tomcat 5.5.x for your deployment (although this may
not be as important)
If these are *all* true, then consider the following:
- According to the Struts2 documentation, struts2.xml needs to be in
the classpath of the application, specifically in the /WEB-INF/classes
folder within your war (when deployed). Doing development, this may
get a bit tricky (depending on your development environment).
- WTP uses the file org.eclipse.wst.common.component (I think you
posted this sometime ago). Independent of what path you put there, WTP
will look in the "WEB-INF/classes" directory on every source path that
needs to be deployed on the parent folder "/". Based on your posted
file, it looks to me you need to have a "/WEB-INF/classes" directory
in your "/content" directory. This is because WTP will recognize that
folder as part of "Web App Libraries" which means everything that you
put in such folder is effectively deployed (through Eclipse) as if it
were in "WEB-INF/classes" within a war file. If this is successful,
you should see a "WebApp Libraries" reference in your package explorer
as well as in the libraries of your project (Project>Properties>Java
Build Path>Libraries see end of list). If you don't see this, then you
need to fix this.
- WTP can use more than one "deploy-path" on "/" to in the eclipse
config file. Make sure that you only have one /WEB-INF/classes folder
in your entire application folder (if that's not the case, it better
have a good reason, but we can talk more about it later). This can be
a double edge sword and could be confusing (but a pretty powerful
feature I must admit). For starters, make sure that your file only
has ONE deploy-path to "/". This is the folder where all your JSPs
should live (I believe Eclipse's default folder is named
"WebContent"). In maven style, this is names /src/main/webapp.
Hope this helps!
PS: I'll be very interested to learn how in the world do you deploy to
the root context using Eclipse (at least doing development). I'm
pretty sure WTP always forces you to use a context name, which
typically is the name of the assigned project.
At a minimum, in your case, you should be seeing your app deployed in
http://localhost/MyProject/home.action
(you have your context-root defined in your
org.eclipse.wst.common.component file).
Good Luck!
Emil Lundberg wrote:
Dave:
Like I said, I'm using Eclipse, so I don't really know where
everything ends up on the server. I've set the default class
directory to <project root>/build/classes, and that's where
struts.xml is. The default content root is <project root>/content, if
that's any help.
Alberto:
Yes, I have a <project root>/classpath folder, and it seems to be the
same as <project root>/build/classes, because when I edit
classpath/struts.xml, build/classes/struts.xml recieves the same change.
What's strange about all this is that struts reads <constant
name="struts.devMode" value="true" /> and goes into devMode, but
doesn't find my actions...
/Emil
Dave Newton wrote:
You never answered the question about where you were deploying it
to: are you deploying it to the root context?
Dave
Alberto Flores skrev:
I just tried both on my own terminal and these work just fine. Here
is a layout of my war:
foo
- WEB-INF
-lib
struts2-core.jar (and the other 3 minimum jars you need)
-classes
-struts.xml
-jsp
-page
-home.jsp
-web.xml
you said you have a classpath folder?
Emil Lundberg wrote:
Yes, it is configured to intercept all requests, and I wouldn't get
a Struts error message if the FilterDispatcher didn't launch, would I?
And I did post my struts.xml and the URL, but Mr. Dave didn't
include it in his reply. Both http://localhost/home.action and
http://localhost/random.action return the same error message, see
my first post.
---classpath/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.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="home"
class="my.package.web.struts.action.HomeAction">
<result>/WEB-INF/jsp/page/home.jsp</result>
</action>
<action name="random"
class="my.package.web.struts.action.HomeAction">
<result>/WEB-INF/jsp/page/home.jsp</result>
</action>
</package>
</struts>
------end struts.xml------
---content/WEB-INF/web.xml---
<?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>MyProject</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>
---------end web.xml---------
Carlos Luis Zúñiga Sibaja wrote:
Is the Struts Dispatcher configured in your web.xml to intercept all
requests?
Carlos Luis Zúñiga Sibaja
__________________________
[EMAIL PROTECTED]
divide et impera...
Alberto A. Flores wrote:
please post your struts.xml and the url you are trying to hit.
Your web.xml
relevant part will also behelpful ...
On Mon, Sep 22, 2008 at 5:43 PM, Emil Lundberg
<[EMAIL PROTECTED]>wrote:
That's strange... When i set <constant name="struts.devMode"
value="true"
/> in struts.xml, struts goes into devMode, but still doesn't
find my action
mappings. Did I do something wrong? I've worked with struts
before but I
just can't seem to get this right for some reason... Could it
have something
to do with that I'm not using Spring yet in this project?
/Emil
Dave Newton wrote:
--- On Mon, 9/22/08, Emil Lundberg <[EMAIL PROTECTED]> wrote:
I'm having a problem with Struts2 in Eclipse. I've
set all the JARs up and the FilterDispatcher launches
properly. The problem is that it seems my struts.xml is never
read,
because I keep getting a message saying "There is no Action
mapped for
namespace / and action
name home. - [unknown location]" when trying to access
http://localhost/home.action (yes, Tomcat is configured to port
80).
I've searched all over for a week or so but I still haven't
found a
solution. I think the problem is where I put struts.xml or some
configuration somewhere.
Are you deploying it to the root application context?
If you put struts.xml at the root of your source directory it
should be
deployed properly.
If you haven't already, turn on devMode. You can also set the
XWork and S2
logging to DEBUG to get more of an idea what's happening with the
configuration.
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]