view-id is getting ignored and everything gets redirected to my "welcome-file"
Tagged: view-id ignored welcome file
June 5, 2013 at 4:52 pm #24111
I discovered PrettyFaces today, it seems just what I need to fix my ugly URLs in my JSF project. Unfortunately I passed my entire day in this and I can’t get it to work. My first problem I described in this topic. To fix this I used the following dependency, instead of the ones in the tutorial:
I don’t know if it’s correct to use this dependency with my version of JSF (Mojarra 2.1.22), maybe this is causing the problem I’ll describe below.
As the tutorial says, I added the filter in my web.xml and created a configuration file. Something bizarre happens: it doesn’t matter what I write in the “view-id” tag, every URL I declare redirects to the same page: the one I defined in my web.xml as the welcome file, through the tag <welcome-file>. I’m new to Prettyfaces and I tried everything I could already. Can someone help me?
Thanks in advance for any answer.
My web.xml and configuration file are attached.
June 5, 2013 at 10:11 pm #24119
- This topic was modified 3 years, 12 months ago by tiagoperes.
Hi! Sorry for the confusion. Please see my response on your other thread, but version 2.0.4 of PrettyFaces is over three years old! You should really use version 2.0.2.Final of Rewrite, using the PrettyFaces configuration module – this is the most up-to-date version.
THe versions may be confusing, but Rewrite is a newer framework, and PrettyFaces is now a part of that. All releases of PrettyFaces going forward are done as a release of Rewrite.
You can see all released artifacts here:
Version 2.0.2.Final was just released tonight, and should be sync’d to Maven central within an hour or two. (Until then, you can use 2.0.1.Final, following the instructions on http://ocpsoft.org/prettyfaces/)
Sorry for the mess; hopefully this helps to explain it.
~LincolnJune 6, 2013 at 1:47 pm #24124
Thank you for answering Lincoln. I updated my dependencies to “rewrite-servlet 2.0.2.Final” and “rewrite-config-prettyfaces 2.0.2.Final”. I also removed the PrettyFaces filter from my web.xml, now there’s nothing concerning Prettyfaces in this file. My pretty-config.xml continues under the WEB-INF folder.
When I initialize my application, the only log I get from Prettyfaces is:
Jun 06, 2013 2:29:52 PM org.ocpsoft.rewrite.faces.RewritePhaseListener INFO: RewritePhaseListener starting up
None of my mapping works, I get error 404 every time I try to access a URL that doesn’t correspond to a JSF view-id.
The pages are correctly loaded when I access the URLs directly (/faces/page.xhtml). I thought that, maybe, Prettyfaces was not loading pretty-config.xml, I tried to specify the config file in my web.xml through the parameter “com.ocpsoft.pretty.CONFIG_FILES”, but it didn’t work.
I also tried this in 2.0.1.Final, I had the same problem.
My mapping file is attached to the original post.June 6, 2013 at 1:52 pm #24128
Maybe my problem is the same described here: http://ocpsoft.org/support/topic/cant-get-prettyfaces-to-work/
I’m also uploading my web.xml.
- This reply was modified 3 years, 11 months ago by tiagoperes.
Attachments:June 6, 2013 at 2:07 pm #24133
Hmmm… do you not see anything about RewriteFilter starting up? There should be quite a big set of logs. Could you perhaps upload a sample project that reproduces this so that I can try to debug it? I’m guessing it’s just something simple that is mis-configured, but it’s not clear until I can see the whole app.
Thanks! Sorry you are having trouble.June 6, 2013 at 4:04 pm #24136
Ok, I created a new application, with only JSF and Prettyfaces as dependencies. I still have the same problem, I must be missing something…
My complete log file for the sample application:
Jun 06, 2013 4:31:16 PM org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor C:\Users\Tiago Peres\AppData\Roaming\NetBeans\7.3\apache-tomcat-188.8.131.52_base\conf\Catalina\localhost\sample.xml Jun 06, 2013 4:31:16 PM com.sun.faces.config.ConfigureListener contextInitialized INFO: Inicializando Mojarra 2.1.22 ( 20130508-2000 https://svn.java.net/svn/mojarra~svn/tags/2.1.22@11945) para o contexto '/sample' Jun 06, 2013 4:31:17 PM com.sun.faces.spi.InjectionProviderFactory createInstance INFO: JSF1048: Anotações PostConstruct/PreDestroy presentes. Os métodos ManagedBeans marcados com essas anotações informarão as anotações processadas. Jun 06, 2013 4:31:17 PM org.ocpsoft.rewrite.faces.RewritePhaseListener INFO: RewritePhaseListener starting up. Jun 06, 2013 4:31:17 PM org.apache.catalina.util.LifecycleBase start INFO: The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sample]] after start() had already been called. The second call will be ignored.
My sample application has:
I’m annexing all of these files to this post (unless index.jsp, due to the limit of 4 annexes per post).
I saw an example of web.xml for Prettyfaces including the RewriteFilter, for what you said before it’s not necessary, but I tried it anyway, when I do it, I get a lot of log from Prettyfaces, although it still doesn’t work.June 6, 2013 at 6:08 pm #24141
You can also attach a ZIP of everything, but I will try to put that together 🙂June 11, 2013 at 12:51 pm #24154
Lincoln, have u find anything wrong with my code? Thank you for taking your time to help me.
I’m annexing the zip file to make things easier.
Attachments:June 11, 2013 at 1:36 pm #24157
The problem is your web.xml:
<web-app version="3.0" ....metadata-complete="true">
truewill tell the servlet container to ignore the
web-fragment.xmlthat’s located in the Rewrite archive. You should either set it to
falseor remove it (the default is false).June 11, 2013 at 3:50 pm #24158
Thank you very much Christian! That was exactly the problem. I don’t know why Netbeans set this to true by default…
You must be logged in to reply to this topic.