Discussion:
Struts 2 Annotation Tutorial
Steve Brierton
2011-09-28 01:08:23 UTC
Permalink
Hello,

I'm going through the Struts 2 Annotation tutorial and I'm having problems
with the first part of it, the "hello" convention plugin part. I'm getting
"There is no Action mapped for namespace / and action name hello." Along
with the following stack trace (partial):
There is no Action mapped for namespace / and action name hello. - [unknown
location]

com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:1
89)

org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)

org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsAct
ionProxyFactory.java:39)

com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultA
ctionProxyFactory.java:58)
....


My index.jsp has the following link:
<p><a href="<s:url action="hello" />" >Get your hello.</a></p>

I have a WebContent/WEB-INF/content/hello-success.jsp that is the following:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello</title> </head> <body> <h3><s:property value="message" /></h3>

<p><a href="index.jsp" >Return to home page</a>.</p>

</body>
</html>


I've searched the web and I've seen places mention about setting the
package.locator and action.suffix in the struts.xml so I've set my
struts.xml to this (it resides in my src folder):
<?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"></constant>

<constant name="struts.convention.package.locators" value="actions"/>
<constant name="struts.convention.action.suffix" value="Controller"/>
<constant name="struts.convention.action.mapAllMatches" value="true"/>

</struts>

My jar files (I got them out of the tutorial) are located in WEB-INF/lib and
are:
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemarker-2.3.16.jar
javassist-3.7.ga.jar
log4j-1.2.14.jar
ognl-3.0.jar
struts2-config-browser-plugin-2.1.8.1.jar
struts2-convention-plugin-2.2.1.jar
struts2-core-2.2.1.jar
xwork-core-2.2.1.jar



I'm using Eclipse and jre6.

Thank you for your assistance,
Steve
Łukasz Lenart
2011-09-28 05:08:24 UTC
Permalink
Do you have action class called HelloAction with execute method which
returns SUCCESS ?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/


2011/9/28 Steve Brierton <***@hotmail.com>:
> Hello,
>
> I'm going through the Struts 2 Annotation tutorial and I'm having problems
> with the first part of it, the "hello" convention plugin part.  I'm getting
> "There is no Action mapped for namespace / and action name hello."  Along
> with the following stack trace (partial):
> There is no Action mapped for namespace / and action name hello. - [unknown
> location]
>
> com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:1
> 89)
>
> org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
>
> org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsAct
> ionProxyFactory.java:39)
>
> com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultA
> ctionProxyFactory.java:58)
> ....
>
>
> My index.jsp has the following link:
> <p><a href="<s:url action="hello" />" >Get your hello.</a></p>
>
> I have a WebContent/WEB-INF/content/hello-success.jsp that is the following:
> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
>    pageEncoding="ISO-8859-1"%>
> <%@ taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC
> "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> <title>Hello</title> </head> <body> <h3><s:property value="message" /></h3>
>
> <p><a href="index.jsp" >Return to home page</a>.</p>
>
> </body>
> </html>
>
>
> I've searched the web and I've seen places mention about setting the
> package.locator and action.suffix in the struts.xml so I've set my
> struts.xml to this (it resides in my src folder):
> <?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"></constant>
>
>      <constant name="struts.convention.package.locators" value="actions"/>
>      <constant name="struts.convention.action.suffix" value="Controller"/>
>      <constant name="struts.convention.action.mapAllMatches" value="true"/>
>
> </struts>
>
> My jar files (I got them out of the tutorial) are located in WEB-INF/lib and
> are:
> commons-fileupload-1.2.1.jar
> commons-io-1.3.2.jar
> freemarker-2.3.16.jar
> javassist-3.7.ga.jar
> log4j-1.2.14.jar
> ognl-3.0.jar
> struts2-config-browser-plugin-2.1.8.1.jar
> struts2-convention-plugin-2.2.1.jar
> struts2-core-2.2.1.jar
> xwork-core-2.2.1.jar
>
>
>
> I'm using Eclipse and jre6.
>
> Thank you for your assistance,
> Steve
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-***@struts.apache.org
> For additional commands, e-mail: user-***@struts.apache.org
>
>
M. Rakowski
2011-09-28 14:52:01 UTC
Permalink
Hi,

<constant name="struts.convention.package.locators" value="actions"/>
<constant name="struts.convention.action.suffix" value="Controller"/>

make sure your Hallo-Action is in class HalloController in package
foo.actions.bar (foo and bar are random names).

That it should work.

Regards, Matthias
M. Rakowski
2011-09-28 15:49:01 UTC
Permalink
I wrote:

> make sure your Hallo-Action is in class HalloController in package
> foo.actions.bar (foo and bar are random names)

which is not quite correct:
the prefix of the actions-package can be random.
The sub-packages names defines the url namespace.
For example, you can access the foo.actions.HalloController
with /context-path/hallo and the foo.actions.bar.BazController action
with /context-path/bar/baz

Regards, Matthias
Steve
2011-09-29 04:01:15 UTC
Permalink
Thank you both for your responses.

Since I had " <constant name="struts.convention.action.suffix"
value="Controller"/>" listed in my struts.xml file, I tried renaming my
HelloAction class to "HelloController" or "HelloActionController" and tried
various urls to match but no luck. I even tried removing the
"struts.convention.action.suffix" element but it didn't seem to make any
difference.

I've reverted back and below is what I've currently got.

The URL I use is:
http://localhost:8080/Struts2_Annotations_Ant/hello.action



My HelloAction class is as follows (sorry for forgetting to send it in the
first place):
package org.apache.struts.struts2annotations.action;

import org.jboss.xnio.log.Logger;

import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport {

private static final long serialVersionUID = 1L;
private static final Logger logger =
Logger.getLogger(HelloAction.class.getName());

private String message;

public String execute() throws Exception {
logger.info("In execute method of class Hello");
message = "Hello from Struts 2 with no XML configurtaion";
return SUCCESS;
}

public void setMessage(String message) {
this.message = message;
}

public String getMessage() {
return message;
}

}

-----Original Message-----
From: M. Rakowski [mailto:***@rakowski.biz]
Sent: Wednesday, September 28, 2011 10:49 AM
To: ***@struts.apache.org
Subject: Re: Struts 2 Annotation Tutorial (additional info)

I wrote:

> make sure your Hallo-Action is in class HalloController in package >
foo.actions.bar (foo and bar are random names)

which is not quite correct:
the prefix of the actions-package can be random.
The sub-packages names defines the url namespace.
For example, you can access the foo.actions.HalloController with
/context-path/hallo and the foo.actions.bar.BazController action with
/context-path/bar/baz

Regards, Matthias

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-mail: user-***@struts.apache.org
Łukasz Lenart
2011-09-29 05:09:34 UTC
Permalink
Did you base on [1] ? If so, please remove struts.xml

[1] http://code.google.com/p/struts2-examples/downloads/detail?name=Struts_Annotations_Ant_2_2_1.zip&can=2&q=


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/
Steve
2011-09-30 04:02:44 UTC
Permalink
Hello,

Yes, I'm basing it off of the Struts_Annotations_Ant_2_2_1.zip. I removed the struts.xml like you instructed but still no luck.

I added the "struts.devMode" param to my web.xml file. So my web.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
<display-name>Struts2_Annotations_Ant</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.devMode</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>



I decided that I'd switch from the jar files located inside the " Struts_Annotations_Ant_2_2_1.zip" to the ones from "struts-2.2.3-all " so I can attach the source code. So the jars in my WEB-INF\lib folder are now:
asm-3.1.jar
asm-commons-3.1.jar
asm-tree-3.1.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
freemarker-2.3.16.jar
javassist-3.11.0.GA.jar
log4j-1.2.16.jar
ognl-3.0.1.jar
struts2-config-browser-plugin-2.2.3.jar
struts2-convention-plugin-2.2.3.jar
struts2-core-2.2.3.jar
xwork-core-2.2.3.jar


Of course that'd didn't make a difference. I still get:
There is no Action mapped for namespace / and action name hello. - [unknown location]
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:189)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)



However now I know that in the DefaultActionProxy.prepare method, the statement:
config = configuration.getRuntimeConfiguration().getActionConfig(namespace, actionName);

results in a null for config. Namespace is: "/" and actionName is: "hello"

If it helps you any, the Struts Configuration Browser shows nothing under the "default" namespace. Under "constants" I have the following settings:
logMissingProperties false
struts.multipart.saveDir
struts.convention.actionNameBuilder convention
struts.convention.result.path /WEB-INF/content/
struts.objectFactory.spring.useClassCache true
struts.url.includeParams none
struts.velocity.configfile velocity.properties
struts.convention.classes.reload false
struts.convention.action.mapAllMatches false
struts.convention.relative.result.types dispatcher,velocity,freemarker
struts.dispatcher.parametersWorkaround false
struts.serve.static true
enableOGNLExpressionCache true
struts.convention.action.name.lowercase true
struts.convention.package.locators.disable false
struts.ognl.enableExpressionCache true
struts.ui.templateSuffix ftl
struts.convention.package.locators action,actions,struts,struts2
struts.multipart.parser jakarta
struts.velocity.toolboxlocation
struts.i18n.reload true
struts.freemarker.beanwrapperCache false
struts.objectFactory.spring.autoWire name
struts.ui.templateDir template
struts.url.http.port 80
struts.ognl.allowStaticMethodAccess false
struts.convention.action.checkImplementsAction true
struts.enable.DynamicMethodInvocation true
struts.ognl.logMissingProperties false
struts.convention.action.fileProtocols jar
struts.convention.action.disableScanning false
devMode true
struts.action.extension action,,
struts.convention.exclude.parentClassLoader true
struts.enable.SlashesInActionNames false
struts.convention.default.parent.package convention-default
struts.multipart.handler jakarta
struts.convention.exclude.packages org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*
struts.i18n.encoding UTF-8
struts.convention.conventionsService convention
struts.convention.package.locators.basePackage
struts.multipart.maxSize 2097152
struts.convention.action.name.separator -
struts.tag.altSyntax true
struts.convention.redirect.to.slash true
struts.freemarker.mru.max.strong.size 100
struts.convention.action.alwaysMapExecute true
struts.convention.interceptorMapBuilder convention
struts.freemarker.templatesCache false
struts.convention.action.suffix Action
struts.mapper.alwaysSelectFullNamespace true
struts.convention.result.flatLayout true
struts.devMode true
allowStaticMethodAccess false
struts.freemarker.templatesCache.updateDelay 0
struts.url.https.port 443
struts.ui.theme xhtml
struts.velocity.contexts
struts.xslt.nocache false
struts.objectFactory.spring.autoWire.alwaysRespect false
struts.configuration.xml.reload true
struts.el.throwExceptionOnFailure false
struts.serve.static.browserCache true
struts.freemarker.wrapper.altMap true
struts.convention.actionConfigBuilder convention
struts.convention.resultMapBuilder convention



Remember, my app server is JBoss.

Thank you,
Steve

-----Original Message-----
From: Lukasz Lenart [mailto:***@googlemail.com]
Sent: Thursday, September 29, 2011 12:10 AM
To: Struts Users Mailing List
Subject: Re: Struts 2 Annotation Tutorial (additional info)

Did you base on [1] ? If so, please remove struts.xml

[1] http://code.google.com/p/struts2-examples/downloads/detail?name=Struts_Annotations_Ant_2_2_1.zip&can=2&q=


Regards
--
Lukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-mail: user-***@struts.apache.org
Łukasz Lenart
2011-09-30 05:41:47 UTC
Permalink
2011/9/30 Steve <***@hotmail.com>:
> Remember, my app server is JBoss.

Which version ? Could you try on Tomcat ?


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/
Steve
2011-10-01 05:49:05 UTC
Permalink
Hello Lukasz,

I'm using JBoss 5.1 via Eclipse and JBoss Tools. When I switched to Tomcat 6 and changed my logger's package it started to work. Makes you wonder what's up with JBoss?

Thank you for your assistance.
Steve

-----Original Message-----
From: Lukasz Lenart [mailto:***@googlemail.com]
Sent: Friday, September 30, 2011 12:42 AM
To: Struts Users Mailing List
Subject: Re: Struts 2 Annotation Tutorial (additional info)

2011/9/30 Steve <***@hotmail.com>:
> Remember, my app server is JBoss.

Which version ? Could you try on Tomcat ?


Regards
--
Lukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-mail: user-***@struts.apache.org
Łukasz Lenart
2011-10-01 14:43:58 UTC
Permalink
2011/10/1 Steve <***@hotmail.com>:
> Hello Lukasz,
>
> I'm using JBoss 5.1 via Eclipse and JBoss Tools.  When I switched to Tomcat 6 and changed my logger's package it started to work.  Makes you wonder what's up with JBoss?

Do you see any errors in the log ? Could double check ?
Struts 2 has some problems to run properly on JBoss 6/7, so maybe it's
the same case.


Thanks in advance
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/
Lwen.ma
2011-10-01 23:13:41 UTC
Permalink
With jboss 6 and 7 use 'Convention plugin', See 'https://issues.apache.org/jira/browse/WW-3558' and 'https://issues.apache.org/jira/browse/WW-3662' plz.


2011-10-02



Lwen.ma



发件人 Łukasz_Lenart
发送时闎 2011-10-01 22:44:26
收件人 Struts Users Mailing List
抄送
䞻题 Re: Struts 2 Annotation Tutorial (additional info)

2011/10/1 Steve <***@hotmail.com>:
> Hello Lukasz,
>
> I'm using JBoss 5.1 via Eclipse and JBoss Tools. When I switched to Tomcat 6 and changed my logger's package it started to work. Makes you wonder what's up with JBoss?
Do you see any errors in the log ? Could double check ?
Struts 2 has some problems to run properly on JBoss 6/7, so maybe it's
the same case.
Thanks in advance
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-mail: user-***@struts.apache.org
Steve
2011-10-04 04:02:15 UTC
Permalink
Hello,

I started up JBoss again and did a find across the log for "at " (that's at with a space at the end) but did not see any stack trace. I have log level debug turned on and I double checked that nothing rolled off my log file (it starts with "22:43:43,828 INFO [ServerImpl] Starting JBoss (Microcontainer)...").

Looking at the links you sent me, it could be the second one: WW-3662, where they are getting no stack trace. I have JBoss 6 and am running Struts-2.2.3 and that issue is with JBoss 7 and Struts_2_2_1_1 but it could be. It looks like Jason Pyeron is still working on it though.

Steve

-----Original Message-----
From: Lwen.ma [mailto:***@gmail.com]
Sent: Saturday, October 01, 2011 6:14 PM
To: Struts Users Mailing List
Subject: Re: Re: Struts 2 Annotation Tutorial (additional info)

With jboss 6 and 7 use 'Convention plugin', See 'https://issues.apache.org/jira/browse/WW-3558' and 'https://issues.apache.org/jira/browse/WW-3662' plz.


2011-10-02



Lwen.ma



???: Lukasz_Lenart
????: 2011-10-01 22:44:26
???: Struts Users Mailing List
??:
??: Re: Struts 2 Annotation Tutorial (additional info)

2011/10/1 Steve <***@hotmail.com>:
> Hello Lukasz,
>
> I'm using JBoss 5.1 via Eclipse and JBoss Tools. When I switched to Tomcat 6 and changed my logger's package it started to work. Makes you wonder what's up with JBoss?
Do you see any errors in the log ? Could double check ?
Struts 2 has some problems to run properly on JBoss 6/7, so maybe it's the same case.
Thanks in advance
--
Lukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@struts.apache.org
For additional commands, e-mail: user-***@struts.apache.org
Loading...