Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts doesn't want to work

 
Piotr Gorajski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to build web application using Struts2 (2.2.1.1), Maven2 in Eclipse (Helios). I was trying to do it according to official tutorial:
http://struts.apache.org/2.x/docs/create-struts-2-web-application-using-maven-to-manage-artifacts-and-to-build-the-application.html
However for making maven app skeleton I used plugin from: http://m2eclipse.sonatype.org/installing-m2eclipse.html and created Maven Project.
In the result when I try to enter: http://localhost:8080/test_app/index.action, I'm getting HTTP Status 404 - /test_app/index.action.
Moreover, there are completly no logs apart from server starting in console :/ Not any struts logs :/

Below is my source code:

--log4j.xml--


--struts.xml--


--web.xml--


--pom.xml--


Folder structure of project:
http://img339.imageshack.us/i/navigatorfolderstructur.jpg

I'm running it on Tomcat 7.0
Please help, what am I doing wrong? I'm quite deseperate..

Thanks.
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to check your web.xml ... you have the filter and filter-mapping outside the web-app tag and you should not use FilterDispatcher as its been deprecated since 2.1.3 You should use probably use org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter instead.

But thats the only thing that jumps out at me
 
Piotr Gorajski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for pointing me these mistakes. After correction, my web.xml looks now like this:



Unfortunately, my problem still exists the same way it did before. Any further advices?
It seems like struts dispatcher is ommited.. I don't know why :/
 
Jesus Mireles
Ranch Hand
Posts: 122
IntelliJ IDE Java Mac
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then you should try turning on trace and you should verify what is actually being deployed to the tomcat server ...
 
Piotr Gorajski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. By turning on trace, you mean debug? If yes then where should I place break points? And How can i check what is being actually deployed to the tomcat server? Honestly I've never done it.. And I've got a hunch, this is my deploying fault.
When I deploy my app for the first time, I rgiht click on project, New -> Server, and than add Tomcat. After this, I open added tomcat configuration and in Modules tab -> Add External Web Module, and from browse i set path to my app's target folder. Is it correct? Should I do this in another way? After this i start server in debug mode. The rest you already know..


EDIT: Ok, I've just figured it out Just like i thought, i deployed to tomcat the whole target folder instead of the one correct subfolder of it, with the name of my project Now it seems to work properly. Thanks very much for pointing these thigs.
 
Sahil Dave
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am facing a similar problem with the routing to index.action failing with a 404. However if i go to the context root of the app, it goes to index.jsp as expected.

web.xml


struts.xml


I am using Weblogic 9.2 as the application server and deploying the app as a war.
Please help.

Thanks
 
Joe Ess
Bartender
Pie
Posts: 9258
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sahil Dave wrote:I am facing a similar problem with the routing to index.action failing with a 404. However if i go to the context root of the app, it goes to index.jsp as expected.


A Struts action cannot be configured as a "welcome file" without a workaround. Several are discussed here.
 
Sahil Dave
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created a new index.html and set it as the welcome file in web.xml

index.html


I pushed the index.jsp into a 'jsp' dir inside WebContent.

struts.xml


Now pointing to the context root takes me to index.html and consequently to index.action
But I am still getting a 404 instead of the jsp/index.jsp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic