The FacesServlet cannot have a url-pattern of /*
January 13, 2011 at 2:50 pm #17852
I want to map my JSF to /*:
The homepage is displayed OK, but when I go to some link (defined by <pretty:link>), I receive the error from the subject.
If I try the URL pattern /faces/*, the homepage is still displayed OK, but links defined via <pretty:link> tag are just non clickable plain text and it seems the mapped URLActions in beans are never called.
Thanks.January 13, 2011 at 3:10 pm #20614
Why do you want to map the
/*. That is very uncommon. If you are using PrettyFaces you don’t have to do so to get pretty URLs. I don’t think that the error you are seeing is cause by PrettyFaces.
Regarding the non-clickable PrettyFaces links. Could you take a look what is rendered to the HTML page. Perhaps you forgot to declare the
prettyprefix in your Facelets page?January 13, 2011 at 6:10 pm #20615
Lincoln Baxter IIIKeymaster
If you are still having troubles – you could post some of your Facelet source code, and your pretty-config.xml. We will do our best to helpJanuary 20, 2011 at 4:10 pm #20616
sorry, this was my mistake. This error appears when I access an URL I don’t have defined in the matching patterns.
How can I map URLs of my application from the root of the domain and without mapping FacesServlet to /*? Thanks.January 20, 2011 at 4:25 pm #20617
I have problems to map any resources with this kind of errors. If I keep the pattern to /*, from this source code in index.xhtml:
<h:outputStylesheet library="css" name="reset.css"/>
<h:outputStylesheet library="css" name="screen.css"/>
I get this:
<link type="text/css" rel="stylesheet" href="/gowalla-war/*/javax.faces.resource/reset.css?ln=css" />
<link type="text/css" rel="stylesheet" href="/gowalla-war/*/javax.faces.resource/screen.css?ln=css" />
(notice the /*/ part in the path). If I access that URL, I get that error from the thread subject (The FacesServlet cannot have a url-pattern of /*).
How should my web.xml look? It looks like this now:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
If I try to change the url-pattern to, for example, /faces/* and hit the Run button in netbeans, the source code is not parsed at all – I get the HTML with all the <h:…> tags in the browser.
I really don’t what the pattern should be set to, even after reading the documentation.
Thanks.January 20, 2011 at 4:35 pm #20618
Sorry, for the spamming, but I am facing really weird behaviour.
If I set the pattern to /faces/* and go to http://localhost:8080/gowalla-war/, I get an unparsed code of index.xhtml. If I go to http://localhost:8080/gowalla-war/faces, I get GlassFish 404. If I go to http://localhost:8080/gowalla-war/faces/ (additional slash), I get an unparsed code again. If I go to http://localhost:8080/gowalla-war/faces/index.xhtml, I finally get what I want – parsed code with successfully loaded resources.
But I really can’t force users to type this address and to reveal my source codes if the URL is not typed correctly, so please, tell me, what am I doing wrong Thanks.January 20, 2011 at 8:27 pm #20619
Add this at the end of your web.xml:
Nothing to do with PrettyFaces, though.January 20, 2011 at 8:32 pm #20620
That didn’t help, behaviour of all problems I described above is the same.January 23, 2011 at 3:07 pm #20621
As I said before mapping the
/*is really not a good idea because it can cause all kinds of trouble.
How can I map URLs of my application from the root of the domain and without mapping FacesServlet to /*? Thanks.
If I understand you correctly you want to remove the context path of your application from the URLs? How to do this depends on the container you are using. In Tomcat for example you have to rename the WAR archive to
ROOT.warbefore you deploy it. In this case there will be no context path in your URL.January 23, 2011 at 4:22 pm #20622
I usually map the Faces Servlet to
and set the welcome-file to
That way, I simply put a index.xhtml in the root of my web
application have / mapped to the faces file I created.
You must be logged in to reply to this topic.