Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in struts 2

 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best place to start is by working through the tutorials here.
 
j bande
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no use, getting same problem, can anyone give me one complete sample application for struts2 with velocity. Thanks in advance.
 
subhasish sahu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic