The problem I have is that jsf tags are not being parsed, so I'm not seeing richfaces components in my pages. I'm using richfaces 4, tomcat 7, and jsf 2.0
This is my faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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_2_0.xsd"
version="2.0">
</faces-config>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>bisis-please-work</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<description>
This parameter tells MyFaces if javascript code should be allowed in
the rendered HTML output.
If javascript is allowed, command_link anchors will have javascript code
that submits the corresponding form.
If javascript is not allowed, the state saving info and nested parameters
will be added as url parameters.
Default is 'true'</description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>
If true, rendered HTML code will be formatted, so that it is 'human-readable'
i.e. additional line separators and whitespace will be written, that do not
influence the HTML code.
Default is 'true'</description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>
If true, a javascript function will be rendered that is able to restore the
former vertical scroll on every request. Convenient feature if you have pages
with long lists and you do not want the browser page to always jump to the top
if you trigger a link or button action that stays on the same page.
Default is 'false'
</description>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>
And this is what I get when starting Tomcat 7
Nov 7, 2011 1:33:45 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.6.0_25\bin;D:\svn\My\GAE\_sdk_python\;C:\Users\Brankica\Desktop\eclipse;;.
Nov 7, 2011 1:33:46 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:bisis-please-work' did not find a matching property.
Nov 7, 2011 1:33:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Nov 7, 2011 1:33:46 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 7, 2011 1:33:46 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1896 ms
Nov 7, 2011 1:33:46 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 7, 2011 1:33:46 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.22
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsf/core is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsf/html is already defined
Nov 7, 2011 1:33:58 AM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener" is already configured for this context. The duplicate definition has been ignored.
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS' found, using default value true
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getLongInitParameter
INFO: No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.VIEWSTATE_JAVASCRIPT' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getStringInitParameter
INFO: No context init parameter 'org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS' found, using default value auto
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.VALIDATE_XML' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG' found, using default value true
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.DEBUG_PHASE_LISTENER' found, using default value false
Nov 7, 2011 1:33:58 AM org.apache.myfaces.shared.config.MyfacesConfig createAndInitializeMyFacesConfig
INFO: Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.
Nov 7, 2011 1:33:58 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getStandardFacesConfig
INFO: Reading standard config META-INF/standard-faces-config.xml
Nov 7, 2011 1:33:58 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getWebAppFacesConfig
INFO: Reading config /WEB-INF/faces-config.xml
Nov 7, 2011 1:33:58 AM org.apache.myfaces.config.annotation.DefaultAnnotationProvider webClasses
WARNING: AnnotationConfigurator does not found classes for annotations in /WEB-INF/classes/ . This could happen because maven jetty plugin is used (goal jetty:run). Try configure org.apache.myfaces.annotation.SCAN_PACKAGES init parameter or use jetty:run-exploded instead.
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getClassloaderFacesConfig
INFO: Reading config : jar:file:/D:/informaticki%20projekat/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bisis-please-work/WEB-INF/lib/richfaces-components-ui-4.0.0.Final.jar!/META-INF/faces-config.xml
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getClassloaderFacesConfig
INFO: Reading config : jar:file:/D:/informaticki%20projekat/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bisis-please-work/WEB-INF/lib/richfaces-core-impl-4.0.0.Final.jar!/META-INF/faces-config.xml
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.LogMetaInfUtils logArtifact
INFO: Artifact 'myfaces-api' was found in version '2.1.3' from path 'file:/D:/informaticki%20projekat/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bisis-please-work/WEB-INF/lib/myfaces-api-2.1.3.jar'
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.LogMetaInfUtils logArtifact
INFO: Artifact 'myfaces-bundle' was found in version '2.1.3' from path 'file:/D:/informaticki%20projekat/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bisis-please-work/WEB-INF/lib/myfaces-bundle-2.1.3.jar'
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.LogMetaInfUtils logArtifact
INFO: Artifact 'myfaces-impl' was found in version '2.1.3' from path 'file:/D:/informaticki%20projekat/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/bisis-please-work/WEB-INF/lib/myfaces-impl-2.1.3.jar'
Nov 7, 2011 1:34:00 AM org.apache.myfaces.util.ExternalSpecifications isBeanValidationAvailable
INFO: MyFaces Bean Validation support disabled
Nov 7, 2011 1:34:00 AM org.apache.myfaces.application.ApplicationImpl getProjectStage
INFO: Couldn't discover the current project stage, using Production
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.FacesConfigurator handleSerialFactory
INFO: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
Nov 7, 2011 1:34:00 AM org.apache.myfaces.config.annotation.DefaultLifecycleProviderFactory getLifecycleProvider
INFO: Using LifecycleProvider org.apache.myfaces.config.annotation.Tomcat7AnnotationLifecycleProvider
Nov 7, 2011 1:34:01 AM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
INFO: ServletContext 'D:\informaticki projekat\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\bisis-please-work\' initialized.
Nov 7, 2011 1:34:01 AM org.richfaces.javascript.ClientServiceConfigParser parse
WARNING: Found JavaScript function definition for class org.hibernate.validator.constraints.NotEmpty, but that class is not presented
Nov 7, 2011 1:34:01 AM org.richfaces.cache.CacheManager getCacheFactory
INFO: Selected fallback cache factory
Nov 7, 2011 1:34:01 AM org.richfaces.cache.lru.LRUMapCacheFactory createCache
INFO: Creating LRUMap cache instance using parameters: {org.apache.myfaces.DETECT_JAVASCRIPT=false, org.apache.myfaces.PRETTY_HTML=true, org.apache.myfaces.AUTO_SCROLL=true, org.apache.myfaces.ALLOW_JAVASCRIPT=true, javax.servlet.jsp.jstl.fmt.localizationContext=resources.application, javax.faces.STATE_SAVING_METHOD=client}
Nov 7, 2011 1:34:01 AM org.richfaces.cache.lru.LRUMapCacheFactory createCache
INFO: Creating LRUMap cache instance of 512 items capacity
Nov 7, 2011 1:34:01 AM org.richfaces.application.InitializationListener onStart
INFO: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.0.0.Final SVN r.22269
Nov 7, 2011 1:34:01 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Nov 7, 2011 1:34:02 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Nov 7, 2011 1:34:02 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 15218 ms
Example I use for testing (the source code I get from browser is identical):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich">
<f:view contentType="text/html">
<h:head>
<title>Calendar</title>
</h:head>
<h:body>
<rich:calendar datePattern="dd/MM/yyyy hh:mm:ss" />
</h:body>
If anyone has some suggestions, please write.. Thanks in advance
the source code I get from browser is identical
In other words, the FacesServlet
wasn't called and was therefore not able to do its job. That can only mean that the request URL did not match the URL pattern of the FacesServlet
as definied in web.xml
. Perhaps you opened the page by http://localhost:8080/bisis-please-work/somepage.xhtml instead of by http://localhost:8080/bisis-please-work/somepage.jsf which would match <url-pattern>*.jsf</url-pattern>
as you've definied in web.xml
.
Alternatively, you can also replace *.jsf
by *.xhtml
so that you don't need to fiddle with URLs anymore and also don't need to worry about the client being able to see the raw JSF source code. The only disadvantage is that you won't be able to serve "plain vanilla" XHTML files without invoking the FacesServlet
, but that shouldn't matter, those files should have the .html
extension anyway.
I had the same problem, but with a different root cause. For me, richfaces components, in particular the rich:tabPanel, were not rendering because there were plain html tags in the page.
<head>...</head>
instead of
<h:head>...</h:head>
caused the rich:tabPanel to not display at all.
Using plain html body tags caused the tabs to render, but not be clickable.
来源:https://stackoverflow.com/questions/8031619/richfaces-4-components-dont-render