You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Álvaro López López <al...@gmv.com> on 2013/03/21 12:34:48 UTC

Struts 2 Annotations Maven - No Action mapped

Hello everyone,

I am following the Struts2 Getting Started tutorial at http://struts.apache.org/development/2.x/docs/getting-started.html
I reached the "Struts 2 Annotations". I downloaded the Maven version: Struts2_Annotations_Mvn_2_2_1.zip
Then, I updated the pom.xml file to get the latest packaged compiled and ran the WAR under a JBoss AS 7.1 (struts2 version 2.3.12).

However, it seems it doesn´t find the actions correctly.
It just shows the register form (register-input.jsp) because it exists under WEB-INF/content:

- Index.jsp:

<p><a href="<s:url action='hello' />" >Get your hello.</a></p>
<p><a href="<s:url action='register-input' />" > Register for the drawing.</a></p>

- For instance, for the 'hello' action I get the following error:
"There is no Action mapped for namespace [/] and action name [hello] associated with context path [/Struts2_Annotations_Mvn]."

- And HelloAction.java (org.apache.struts.struts2annotations.action.HelloAction.java):

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

Is it possible to fix this project?
Thanks in advance

P Please consider the environment before printing this e-mail.

______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts 2 Annotations Maven - No Action mapped

Posted by Lukasz Lenart <lu...@apache.org>.
2013/3/21 Álvaro López López <al...@gmv.com>:
> After reviewing the "Convention Plugin documentation" I found "struts" and "action" are
> keywords for the plugin to find packages.
>
> As the classes were under "org.apache.struts.struts2annotations.action", the default
> Namespace didn´t find the action classes. I simply changed "struts" to "foo" and the
> Project started to work --> org.apache.foo.struts2annotations.action

So your action should be under namespace /struts2annotations/

> You can also check it looking into the default namespace in the Config Browser Plugin, where
> There should appear 3 actions: hello, register and register-input.

register-input ... hmm... interesting

> Finally, I would like to thank Łukasz for his quick comments.

Great :-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts 2 Annotations Maven - No Action mapped

Posted by Álvaro López López <al...@gmv.com>.
After reviewing the "Convention Plugin documentation" I found "struts" and "action" are
keywords for the plugin to find packages.

As the classes were under "org.apache.struts.struts2annotations.action", the default
Namespace didn´t find the action classes. I simply changed "struts" to "foo" and the
Project started to work --> org.apache.foo.struts2annotations.action

You can also check it looking into the default namespace in the Config Browser Plugin, where
There should appear 3 actions: hello, register and register-input.

As I am using JBoss, I also included two constants in struts.xml which are considered in the documentation.

Finally, I would like to thank Łukasz for his quick comments.

-----Mensaje original-----
De: Lukasz Lenart [mailto:lukaszlenart@apache.org]
Enviado el: jueves, 21 de marzo de 2013 14:34
Para: Struts Users Mailing List
Asunto: Re: Struts 2 Annotations Maven - No Action mapped

2013/3/21 Álvaro López López <al...@gmv.com>:
> I have tried to mimic that behavior in my version (struts2 - 2.312) but what explained in this paragraph is not working:
>
> "The input method above returns "input".
> By the standards of the Convention plugin, the view page rendered will be register-input.jsp (from WEB-INF/content).
> On that view page is a Struts 2 form tag with an action attribute value of register.
> When submitting the form, the execute method of class RegisterAction will be run.
> Since the execute method returns success, the view page rendered is register-success.jsp."
>
> I have changed the "action" parameters in JSP to register-success and hello-success.
> Also, I have annotated the corresponding methods with @Action("xxxxx-success") in the action classes.
>
> If you put any other string (e.g. hello-execute), it doesn´t work.
> It must be the same name as the WEB-INF/content/xxxx-yyyy.jsp you want to map.

Not it doesn't, action is action, result is result, don't mix them in @Action. See simple example:

public class RegisterAction extends ActionSupport {

   @Action("register") // basically not needed, just to show what I mean
   public String execute() {
       if (something)
            return "success";
       else
           return "input";
   }
}

and under WEB-INF/content/
- register-success.jsp (or just register.jsp)
- register-input.jsp

>
> After that, I get exceptions when assigning the personBean. For instance:
>
> "Error setting expression 'personBean.age' with value '[Ljava.lang.String;@340556b3': ognl.OgnlException: target is null for setProperty(null, "age", [Ljava.lang.String;@340556b3)"
>
> I also attached a "message" property to the HelloAction but it didn´t appear in the page, so the execute() method wasn´t called!
>
> I´m afraid the Action classes are not being found.
> I have also changed the namespace from "struts2annotations" to
> "Struts2_Annotations_Mvn" (the name of the project) but it still
> doesn´t work... :S
>
> Next step?

Read documentation [1] how the Convention plugin is working, basically

[1] http://struts.apache.org/development/2.x/docs/convention-plugin.html


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


P Please consider the environment before printing this e-mail.

______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________


Re: Struts 2 Annotations Maven - No Action mapped

Posted by Lukasz Lenart <lu...@apache.org>.
2013/3/21 Álvaro López López <al...@gmv.com>:
> I have tried to mimic that behavior in my version (struts2 - 2.312) but what explained in this paragraph is not working:
>
> "The input method above returns "input".
> By the standards of the Convention plugin, the view page rendered will be register-input.jsp (from WEB-INF/content).
> On that view page is a Struts 2 form tag with an action attribute value of register.
> When submitting the form, the execute method of class RegisterAction will be run.
> Since the execute method returns success, the view page rendered is register-success.jsp."
>
> I have changed the "action" parameters in JSP to register-success and hello-success.
> Also, I have annotated the corresponding methods with @Action("xxxxx-success") in the action classes.
>
> If you put any other string (e.g. hello-execute), it doesn´t work.
> It must be the same name as the WEB-INF/content/xxxx-yyyy.jsp you want to map.

Not it doesn't, action is action, result is result, don't mix them in
@Action. See simple example:

public class RegisterAction extends ActionSupport {

   @Action("register") // basically not needed, just to show what I mean
   public String execute() {
       if (something)
            return "success";
       else
           return "input";
   }
}

and under WEB-INF/content/
- register-success.jsp (or just register.jsp)
- register-input.jsp

>
> After that, I get exceptions when assigning the personBean. For instance:
>
> "Error setting expression 'personBean.age' with value '[Ljava.lang.String;@340556b3': ognl.OgnlException: target is null for setProperty(null, "age", [Ljava.lang.String;@340556b3)"
>
> I also attached a "message" property to the HelloAction but it didn´t appear in the page, so the execute() method wasn´t called!
>
> I´m afraid the Action classes are not being found.
> I have also changed the namespace from "struts2annotations" to  "Struts2_Annotations_Mvn" (the name of the project) but it still doesn´t work... :S
>
> Next step?

Read documentation [1] how the Convention plugin is working, basically

[1] http://struts.apache.org/development/2.x/docs/convention-plugin.html


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts 2 Annotations Maven - No Action mapped

Posted by Álvaro López López <al...@gmv.com>.
I have tried to mimic that behavior in my version (struts2 - 2.312) but what explained in this paragraph is not working:

"The input method above returns "input".
By the standards of the Convention plugin, the view page rendered will be register-input.jsp (from WEB-INF/content).
On that view page is a Struts 2 form tag with an action attribute value of register.
When submitting the form, the execute method of class RegisterAction will be run.
Since the execute method returns success, the view page rendered is register-success.jsp."

I have changed the "action" parameters in JSP to register-success and hello-success.
Also, I have annotated the corresponding methods with @Action("xxxxx-success") in the action classes.

If you put any other string (e.g. hello-execute), it doesn´t work.
It must be the same name as the WEB-INF/content/xxxx-yyyy.jsp you want to map.

After that, I get exceptions when assigning the personBean. For instance:

"Error setting expression 'personBean.age' with value '[Ljava.lang.String;@340556b3': ognl.OgnlException: target is null for setProperty(null, "age", [Ljava.lang.String;@340556b3)"

I also attached a "message" property to the HelloAction but it didn´t appear in the page, so the execute() method wasn´t called!

I´m afraid the Action classes are not being found.
I have also changed the namespace from "struts2annotations" to  "Struts2_Annotations_Mvn" (the name of the project) but it still doesn´t work... :S

Next step?


-----Mensaje original-----
De: Lukasz Lenart [mailto:lukaszlenart@apache.org]
Enviado el: jueves, 21 de marzo de 2013 12:40
Para: Struts Users Mailing List
Asunto: Re: Struts 2 Annotations Maven - No Action mapped

2013/3/21 Álvaro López López <al...@gmv.com>:
> Hello everyone,
>
> I am following the Struts2 Getting Started tutorial at
> http://struts.apache.org/development/2.x/docs/getting-started.html
> I reached the "Struts 2 Annotations". I downloaded the Maven version:
> Struts2_Annotations_Mvn_2_2_1.zip Then, I updated the pom.xml file to get the latest packaged compiled and ran the WAR under a JBoss AS 7.1 (struts2 version 2.3.12).
>
> However, it seems it doesn´t find the actions correctly.
> It just shows the register form (register-input.jsp) because it exists under WEB-INF/content:
>
> - Index.jsp:
>
> <p><a href="<s:url action='hello' />" >Get your hello.</a></p> <p><a
> href="<s:url action='register-input' />" > Register for the
> drawing.</a></p>
>
> - For instance, for the 'hello' action I get the following error:
> "There is no Action mapped for namespace [/] and action name [hello] associated with context path [/Struts2_Annotations_Mvn]."
>
> - And HelloAction.java (org.apache.struts.struts2annotations.action.HelloAction.java):
>
> public String execute() throws Exception { logger.info("In execute
> method of class Hello"); message = "Hello from Struts 2 with no XML
> configuration."; return SUCCESS; }
>
> Is it possible to fix this project?

Yes, you can do it on your own to learn something, basically follow RegisterAction setup.


Regards
--
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


P Please consider the environment before printing this e-mail.

______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Re: Struts 2 Annotations Maven - No Action mapped

Posted by Lukasz Lenart <lu...@apache.org>.
2013/3/21 Álvaro López López <al...@gmv.com>:
> Hello everyone,
>
> I am following the Struts2 Getting Started tutorial at http://struts.apache.org/development/2.x/docs/getting-started.html
> I reached the "Struts 2 Annotations". I downloaded the Maven version: Struts2_Annotations_Mvn_2_2_1.zip
> Then, I updated the pom.xml file to get the latest packaged compiled and ran the WAR under a JBoss AS 7.1 (struts2 version 2.3.12).
>
> However, it seems it doesn´t find the actions correctly.
> It just shows the register form (register-input.jsp) because it exists under WEB-INF/content:
>
> - Index.jsp:
>
> <p><a href="<s:url action='hello' />" >Get your hello.</a></p>
> <p><a href="<s:url action='register-input' />" > Register for the drawing.</a></p>
>
> - For instance, for the 'hello' action I get the following error:
> "There is no Action mapped for namespace [/] and action name [hello] associated with context path [/Struts2_Annotations_Mvn]."
>
> - And HelloAction.java (org.apache.struts.struts2annotations.action.HelloAction.java):
>
> public String execute() throws Exception {
> logger.info("In execute method of class Hello");
> message = "Hello from Struts 2 with no XML configuration.";
> return SUCCESS;
> }
>
> Is it possible to fix this project?

Yes, you can do it on your own to learn something, basically follow
RegisterAction setup.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org