• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSF keeps appending the context root directory in navigation rules  RSS feed

 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have my application in webapps/songcrit. I have Apache hpptd set up with a virtual host to send www.songcrit.com to that directory. But jsf keeps sending back the results of navigation rules with the songcrit directory attached so if it's supposed to direct to http://www.songcrit.com/user.jsf, it directs to http://www.songcrit.com/songcrit/user.jsf. And of course that doesn't exist, so I get a 404 error.

If you get there by going to http://www.onlinehomepoker.com/songcrit/ then it works.

Anyone know how to solve this?
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSF navigation rules are not general URL rules. They are only designed to navigate within the webapp and not to external sites or other arbitrary destinations.

In order to navigate to external sites, you should either use a JSF outputLink element, the new link tag introduced in JSF2, or an HTTP redirect (NOT a JSF redirect!)
 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks for the reply, but I am trying to navigate within the webapp as described above.
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
webapps/songcrit is not a "directory" according the the server's configuration, it is the physical location of a deployed exploded WAR and as such is only indirectly associated with a URL.

J2EE permits the deployment of multiple webapps within a server, but the only way that the server can tell which webapp to dispatch a given URL to is by looking at the context path part of the URL. The context path is the fragment of the URL that the server has associated with the webapp; by default, if you deploy a webapp in the webapps/songcrit directory of a Tomcat server and do not supply an explicit context path, Tomcat will default the context URL to be "http://hostname:port/songcrit", using the appropriate hostname and the default port of 8080.

Thus, the "songcrit" context name is not optional. Without it, the J2EE server cannot route the request properly. At best, it will route to the default webapp (if any) for that server, and not to the songcrit app.

With apache running the front-end, you can give the illusion of removing "songcrit" from the URL, but you have to use mod_proxy or mod_jk to proxy the requests to Tomcat. Simply rewriting the incoming URLs isn't sufficient.
 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Thanks for the reply. Maybe this is becoming less of a JSF question, but here is the section from my httpd.conf

Am I doing things right here? If not how can I fix it? If so, where do you think the problem lies.



I have searched Google endlessly for days on this issue. I can't believe no one has had this problem before. Surely other people host multiple sites on their servers and don't want their to be a directory name in the URL...
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're using the wrong port, I do believe. For mod_proxy, the default port is 8009, not 8080. It's not just redirecting, it's tunnelling.
 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

changing the port just made it stop working completely.

I wrote a custom view handler to try to fix the problem. This makes the outcome correct for the dynamic link on the page but... the postbacks still don't work.

It tries to send me to http://127.0.0.1:8080/user.jsf instead of http://www.songcrit.com/user.jsf


Here is my getActionURL:

 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fat-fingered the port ID. It should have been 8109. It's marked as the "ajp" port in Tomcat's server.xml file.
 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

actually it turns out it was 8009 as you originally stated but I forgot to change http: to ajp:

However, fixing that issue just made it go back to doing the same thing that was originally the problem, so I'm using ajp now, but it didn't solve anything
 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed... kind of.

Ok, here's what I had to do in case anyone else has this problem:



the context root directory still appears in the url sometimes, but it works either way now, so that's good enough.
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, mine look more like this:



Where "WMS-tomcat" is the application's context root.
 
Elie Steckruebe
Greenhorn
Posts: 26
Chrome Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No idea why the same exact thing didn't work for me. Weird.

At least I found something that works acceptably. ...after spending as much time troubleshooting this one problem as writing the application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!