Problem getting started with Facelets and JSF

Hi,

When I want to load my facelets based webapplication I get the following error:

exception:

javax.servlet.ServletException: Requires FaceletFilter to be initialized with Application!!

root cause:

com.sun.facelets.FaceletException: Requires FaceletFilter to be initialized with Application!!

Does anyone what the problem might be and know how to solve this? Thank you very much.

Just in case, here are my web.xml and face-config.xml:

web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5" 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_2_5.xsd">

<!-- Use Documents Saved as *.xhtml -->

<context-param>

<param-name>javax.faces.DEFAULT_SUFFIX</param-name>

<param-value>.xhtml</param-value>

</context-param>

<!-- Faces Servlet -->

<servlet>

<servlet-name>Faces Servlet</servlet-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<!-- Faces Servlet Mapping -->

<servlet-mapping>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>*.xhtml</url-pattern>

</servlet-mapping>

<session-config>

<session-timeout>

30

</session-timeout>

</session-config>

<welcome-file-list>

<welcome-file>index.xhtml</welcome-file>

</welcome-file-list>

</web-app>

faces-config.xml

<faces-config version="1.2"

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-facesconfig_1_2.xsd">

<application>

<resource-bundle>

<base-name>com.sun.firstcup.web.WebMessages</base-name>

<var>bundle</var>

</resource-bundle>

<locale-config>

<default-locale>en</default-locale>

</locale-config>

<!-- tell JSF to use Facelets -->

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>

</application>

<managed-bean>

<managed-bean-name>user</managed-bean-name>

<managed-bean-class>com.corejsf.UserBean</managed-bean-class>

<managed-bean-scope>session</managed-bean-scope>

</managed-bean>

</faces-config>

Cheers,

Luke

[3118 byte] By [Sarmatiana] at [2007-11-26 15:10:22]
# 1

This is what the server log file says:

[#|2007-01-16T20:06:45.046+0100|WARNING|sun-appserver-pe9.0|javax.enterprise.resource.webcontainer.jsf.lifecycle|_ThreadID=19;_ThreadName=httpWorkerThread-8080-0;_RequestID=5a346cfe-d5bc-41ca-86f7-fb8b18cfadf3;|executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@12c83c6) threw exception

com.sun.facelets.FaceletException: Requires FaceletFilter to be initialized with Application!!

at com.sun.facelets.FaceletViewHandler.createFaceletConfig(FaceletViewHandler.java:138)

at com.sun.facelets.FaceletViewHandler.initialize(FaceletViewHandler.java:150)

at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:439)

at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:133)

at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)

at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)

at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)

at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)

at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)

|#]

[#|2007-01-16T20:06:45.062+0100|SEVERE|sun-appserver-pe9.0|javax.enterprise.system.container.web|_ThreadID=19;_ThreadName=httpWorkerThread-8080-0;_RequestID=5a346cfe-d5bc-41ca-86f7-fb8b18cfadf3;|StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception

com.sun.facelets.FaceletException: Requires FaceletFilter to be initialized with Application!!

at com.sun.facelets.FaceletViewHandler.createFaceletConfig(FaceletViewHandler.java:138)

at com.sun.facelets.FaceletViewHandler.initialize(FaceletViewHandler.java:150)

at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:439)

at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:133)

at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)

at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)

at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)

at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)

at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)

at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)

at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)

at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)

|#]

[#|2007-01-16T20:07:38.375+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.core|_ThreadID=20;_ThreadName=Thread-61;simplefacelets;|CORE5022: All ejb(s) of [simplefacelets] were unloaded successfully!|#]

[#|2007-01-16T20:09:45.453+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=httpWorkerThread-4848-1;C:\Documents and Settings\Lukasz\Local Settings\Temp\s1astempdomain1server1107657139\simplefacelets.ear;|ADM1064:The upload file at [C:\Documents and Settings\Lukasz\Local Settings\Temp\s1astempdomain1server1107657139\simplefacelets.ear] exists and will be overwritten.|#]

[#|2007-01-16T20:09:45.468+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=httpWorkerThread-4848-1;C:\Documents and Settings\Lukasz\Local Settings\Temp\s1astempdomain1server1107657139\simplefacelets.ear;|ADM1006:Uploading the file to:[C:\Documents and Settings\Lukasz\Local Settings\Temp\s1astempdomain1server1107657139\simplefacelets.ear]|#]

[#|2007-01-16T20:09:47.640+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=21;_ThreadName=Thread-62;|deployed with moduleid = simplefacelets|#]

[#|2007-01-16T20:09:47.984+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.admin|_ThreadID=13;_ThreadName=httpWorkerThread-4848-0;ApplicationDeployEvent -- enable simplefacelets;|ADM1041:Sent the event to instance:[ApplicationDeployEvent -- enable simplefacelets]|#]

[#|2007-01-16T20:09:48.218+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=13;_ThreadName=httpWorkerThread-4848-0;simplefacelets;|LDR5010: All ejb(s) of [simplefacelets] loaded successfully!|#]

[#|2007-01-16T20:09:48.218+0100|INFO|sun-appserver-pe9.0|javax.enterprise.system.container.web|_ThreadID=13;_ThreadName=httpWorkerThread-4848-0;simplefacelets:simplefacelets-war.war;server;/simplefacelets;|WEB0100: Loading web module [simplefacelets:simplefacelets-war.war] in virtual server [server] at [/simplefacelets]|#]

[#|2007-01-16T20:09:48.671+0100|INFO|sun-appserver-pe9.0|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=13;_ThreadName=httpWorkerThread-4848-0;/simplefacelets;|Initializing Sun's JavaServer Faces implementation (1.2_02-b03-FCS) for context '/simplefacelets'|#]

[#|2007-01-16T20:09:48.968+0100|INFO|sun-appserver-pe9.0|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=13;_ThreadName=httpWorkerThread-4848-0;/simplefacelets;|Completed initializing Sun's JavaServer Faces implementation (1.2_02-b03-FCS) for context '/simplefacelets'|#]

Please, anyone?

Sarmatiana at 2007-7-8 9:01:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I have solved the problem; I had to add a "Filter" in web.xml

Namely:

<filter>

<filter-name>facelets</filter-name>

<filter-class>com.sun.facelets.webapp.FaceletFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>facelets</filter-name>

<url-pattern>*.xhtml</url-pattern>

</filter-mapping>

I found this code in an example that I found on the internet. I don't understand why this is not mentioned in any of the guides on Facelets.

Do you guys also have to use this filter, to run facelets properly?

Sarmatiana at 2007-7-8 9:01:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
No I don't use this Filter - only the ViewHandler.Do you use an newer Version of Facelets?
hammouda at 2007-7-8 9:01:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Well, actually I downloaded the newest one:Dev Release of 1.2, of November 10, 2006Maybe that is what caused the problem, I have no idea. I always think, get the latest things, they always work the best (preasuming that they are tested and working well).
Sarmatiana at 2007-7-8 9:01:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Yes normally I too - for stable releases.1.1.12 is an Beta release.1.2 is an Dev release.What ever this should say us!Think this could be done better or it should be better described.
hammouda at 2007-7-8 9:01:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...