1

PrettyFaces doesn't work for me. I'm trying to use of simple manner, with JSF 2.2, Servlet 3.1, PrettyFaces 3.3.3 and WildFly8. My project settings are as showed below:

Maven dependency artifact:

<dependency>
        <groupId>com.ocpsoft</groupId>
        <artifactId>prettyfaces-jsf2</artifactId>
        <version>3.3.3</version>
</dependency>

The content of web.xml file:

<?xml version="1.0"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<context-param>
    <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

<servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<session-config>
    <session-timeout>15</session-timeout>
</session-config>

</web-app>

See the content of my pretty-faces.config file:

<?xml version="1.0" encoding="UTF-8"?>
<pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3 http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">

<url-mapping id="home">
    <pattern value="/home" />
    <view-id value="/home.xhtml" />
</url-mapping>

When a make deploy into WildFly all works fine, as you can see in snippet log:

21:42:34,525 INFO  (DeploymentScanner-threads - 2) JBAS015003: Found populis.war in deployment directory. To trigger deployment create a file called populis.war.dodeploy
21:42:34,531 INFO  (MSC service thread 1-4) JBAS015876: Starting deployment of "populis.war" (runtime-name: "populis.war")
21:42:34,665 INFO  (MSC service thread 1-5) JBAS016002: Processing weld deployment populis.war
21:42:34,691 INFO  (MSC service thread 1-5) JBAS016005: Starting Services for CDI deployment: populis.war
21:42:34,705 INFO  (MSC service thread 1-6) JBAS016008: Starting weld service for deployment populis.war
21:42:34,993 INFO  (MSC service thread 1-1) Initializing Mojarra 2.2.5-jbossorg-3 20140128-1641 for context '/populis'
21:42:35,206 INFO  (MSC service thread 1-1) JBAS017534: Registered web context: /populis
21:42:35,218 INFO  (DeploymentScanner-threads - 1) JBAS018559: Deployed "populis.war" (runtime-name : "populis.war")
21:43:21,412 INFO  (default task-11) PrettyFilter starting up...
21:43:21,452 INFO  (default task-11) PrettyFilter initialized.

But when I try to access the URL of my page, I get not found message and no error message is displayed on log. Anyone has any idea what I doing wrong ? I follow the get staterd documentation (http://ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/GettingStarted.html).

Regards.

  • Which URL did you try? Did you include the context path? PrettyFaces cannot remove the context path. I'm just asking because people often run into this issue. – chkal May 09 '14 at 06:42
  • Yes, I did included context path, like http://localhost:8080/sample/home, but if I put /sample/home.xhtml it works fine for me. – Keuller Magalhães May 09 '14 at 13:31
  • Additionally, you are using an outdated version of PrettyFaces - you should be using the information found on http://ocpsoft.org/prettyfaces/ – Lincoln May 09 '14 at 15:27
  • Lincon I've tried to use that, but doesn't work as well. I got the same error as before. – Keuller Magalhães May 09 '14 at 16:45
  • Could you perhaps prepare a small sample app that reproduces this and post on the forums (http://ocpsoft.org/support/). It's difficult to tell what is going wrong without actually seeing you app. – chkal May 11 '14 at 07:30
  • @chkal I've created an entry on PrettyFaces Forum http://ocpsoft.org/support/topic/jsf2-2-prettyfaces-wildfly-doesnt-works. I did attached the sample application in there. – Keuller Magalhães May 14 '14 at 16:07

1 Answers1

1

There are two issues in the sample app you provided.

First your configuration file has an incorrect name. You named the config file pretty-faces.xml. The correct name is pretty-config.xml. So the problem was that PrettyFaces didn't find your file and therefore the rules didn't work.

The second issue is that you used an incorrect view-id. It has to be like this:

<url-mapping id="home">
    <pattern value="/home" />
    <view-id value="/home.jsf" />     <!-- note the .jsf here -->
</url-mapping>

I hope this helps. :)

chkal
  • 5,598
  • 21
  • 26