How to fix Faces Servlet (javax.faces.webapp.FacesServlet) not found in web context - cannot configure PrettyFaces DynaView?

StackOverflow https://stackoverflow.com/questions/19545203

Question

I currently added the prettyfaces-jsf2-3.3.3.jar to my netbeans project. I also added the pretty-config.xml in the WEB-INF folder with the following test rewrite rule:

<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                  http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">


<url-mapping id="viewRecipe"> 
    <pattern value="/#{ RecipeBean.filterRecipeName }/" />
    <view-id value="/faces/viewRecipe.jsf" />
</url-mapping>

With this configuration the url

http://localhost:8080/wie-koche-ich/Spaetzle
//wie-koche-ich is the name of the netbeans project

should refer to the viewRecipe.jsf page and set the filterName to Spaetzle. But when I enter the url the glassfish 4.0 server returns a 404 page and the log says "Faces Servlet (javax.faces.webapp.FacesServlet) not found in web context - cannot configure PrettyFaces DynaView".

What exactly throws this Exception and how can i fix this?

It seems that the pretty-config.xml wasn't loaded.

Was it helpful?

Solution

This basically means, that PrettyFaces isn't able to find the mapping of the FacesServlet. See:

https://github.com/ocpsoft/prettyfaces/blob/3.3.3/core/src/main/java/com/ocpsoft/pretty/faces/config/servlet/WebXmlParser.java#L73

Did you manually define the mapping for the FacesServlet in your web.xml? If not, you could try to add it. Or you could perhaps try to debug this class to find out what's going on. Actually this class should (in case of a Servlet 3.x) environment, iterate over all the servlet registrations and find the servlet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top