view-id is getting ignored and everything gets redirected to my "welcome-file"

Splash Forums PrettyFaces Users view-id is getting ignored and everything gets redirected to my "welcome-file"

This topic contains 9 replies, has 3 voices, and was last updated by  tiagoperes 3 years, 1 month ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #24111

    tiagoperes
    Participant

    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:

    <dependency>
    <groupId>com.ocpsoft</groupId>
    <artifactId>ocpsoft-pretty-faces</artifactId>
    <version>2.0.4</version>
    </dependency>

    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.

    • This topic was modified 3 years, 2 months ago by  tiagoperes.
    #24119

    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:
    http://search.maven.org/#search%7Cga%7C1%7Corg.ocpsoft.rewrite

    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.

    ~Lincoln

    #24124

    tiagoperes
    Participant

    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.

    #24128

    tiagoperes
    Participant

    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, 2 months ago by  tiagoperes.
    Attachments:
    1. web1.txt
    #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.

    #24136

    tiagoperes
    Participant

    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-7.0.34.0_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:

    • pom.xml
    • META-INF/context.xml
    • WEB-INF/web.xml
    • WEB-INF/pretty-config.xml
    • index.jsp

    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.

    #24141

    You can also attach a ZIP of everything, but I will try to put that together 🙂

    #24154

    tiagoperes
    Participant

    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:
    1. sample.zip
    #24157

    The problem is your web.xml:

    <web-app version="3.0" ....metadata-complete="true">

    Setting metadata-complete to true will tell the servlet container to ignore the web-fragment.xml that’s located in the Rewrite archive. You should either set it to false or remove it (the default is false).

    #24158

    tiagoperes
    Participant

    Thank you very much Christian! That was exactly the problem. I don’t know why Netbeans set this to true by default…

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Comments are closed.