aspose file tools*
The moose likes Struts and the fly likes problem in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in struts 2" Watch "problem in struts 2" New topic
Author

problem in struts 2

sachin yadav
Ranch Hand

Joined: Nov 24, 2005
Posts: 156
Hi everyone,

I have just started working with struts 2. Quit improved and much like Spring(except DI and AOP), this is first time i am working with struts and in HelloWorld programmer i am facing error when my action class is called and the error is : The requested resource (/hello_world/example/HelloWorld.action) is not available.

I am putting up my files below, any idea would be appreciated.

web.xml



struts.xml



HelloWorld.java

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Nothing jumps out at me as being wrong with your code. Here's what I'd suggest: This example is included as part of the struts-blank-2.0.6.war file that comes with the Struts 2 download. Try deploying this war file and verifying that the HelloWorld example works. If their example works, and yours doesn't, try unzipping the war file and comparing their source code to yours.


Merrill
Consultant, Sima Solutions
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

I'm not sure about Struts2, but since it is based on WebWork2, I think you have to include a file called webwork-defaults.xml in your struts.xml (ofcourse, webwork-defaults.xml is a file used in WW2 so you have to check what its name in Struts2).
The best way is to check an already working Struts2 example application...
sachin yadav
Ranch Hand

Joined: Nov 24, 2005
Posts: 156
Merrill and John,

Thanks for your suggestions. Merrill i explore the struts-blank.war and found no problem in both my and struts version. What i did is, i did the whole coding again in new file and you know what it's working this time. Amazing but true.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

We should have faith in ByteCode
Please, may I ask you to check your app again ? and tell us what you find.
Missing XML line, missing a lib, any thing.
j bande
Greenhorn

Joined: Mar 08, 2007
Posts: 24
hi everyone,
i am new to struts2, can anyone help me in this regard. how struts.xml works and what we have to give in web.xml and all the background scenario.
Thanks in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The best place to start is by working through the tutorials here.
j bande
Greenhorn

Joined: Mar 08, 2007
Posts: 24
hi merill,
i already went through this site. i want to work with struts2, velocity and tiles. I got documentation and read it but i am not getting complete example on how to integrate velocity and tiles into struts2. I think jsp is default view for struts2. Anyway thanks for your reply and expecting next reply.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can find examples of the use of velocity templates in the sample application that comes with the download. Just deploy struts2-showcase-2.0.6.war to your application server. You can get to the source code by unzipping the war file and looking in the WEB-INF/src directory.
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

WebWork In Action is good and it will help you to grasp many concepts.
Please note, it some how out-dated so maybe you have to wait for Struts2 books.
j bande
Greenhorn

Joined: Mar 08, 2007
Posts: 24
i am trying the same example which i got with struts2 download. when i deploy the war file of download its working but when i try the same thing from my work space it is give like........



HTTP Status 404 - /struts2-0.0.1/

type Status report

message /struts2-0.0.1/

description The requested resource (/struts2-0.0.1/) is not available.
Apache Tomcat/5.5.17
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The problem might be something as simple as the name of your war file. Since Tomcat automatically makes the name of your war file the context path, you must make sure that the file name follows the rules of what's allowed in a context path. Periods are not allowed in a context path. Change the war file name to one without periods (except the period in .war) and try redeploying.
j bande
Greenhorn

Joined: Mar 08, 2007
Posts: 24
no use, getting same problem, can anyone give me one complete sample application for struts2 with velocity. Thanks in advance.
subhasish sahu
Greenhorn

Joined: Nov 27, 2009
Posts: 3
put your struts.xml in under source packages directory if you are using netbeans

or put it in classes folder if you are manually deploying your web project on tomcat


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in struts 2