1

在配置带有richfaces的tomcat时遇到问题。我复制了:

richfaces-components-ui-4.2.2.Final.jar
richfaces-components-api-4.2.2.Final.jar
richfaces-core-api-4.2.2.Final.jar
richfaces-core-impl-4.2.2.Final.jar

jar 到 tomcat 的 \lib 并重新启动我的服务器。我的 xhtml 页面的定义如下所示:

  <html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ui="http://java.sun.com/jsf/facelets"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:a4j="http://richfaces.org/a4j"
     xmlns:rich="http://richfaces.org/rich">

但是eclipse会产生一个警告,上面写着

NSL missing: CANNOT_FIND_FACELET_TAGLIB in : org.eclipse.jst.jsf.core.validation.internal.facelet.messages

还有什么我需要配置的吗?我浏览了很多教程,但几乎所有教程都使用 JBoss。有没有办法用我的eclipse和tomcat配置richfaces?


已编辑

当我将 jars 添加为外部 jars 并添加依赖项时,它不会使站点崩溃,尽管在控制台中它会产生一个:

Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS' found, using default value true
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getLongInitParameter
INFO: No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.VIEWSTATE_JAVASCRIPT' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getStringInitParameter
INFO: No context init parameter 'org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS' found, using default value auto
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.VALIDATE_XML' found, using default value false
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG' found, using default value true
Jun 10, 2012 2:15:55 PM org.apache.myfaces.shared_impl.config.MyfacesConfig createAndInitializeMyFacesConfig
INFO: Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.
Jun 10, 2012 2:15:55 PM org.apache.myfaces.config.FacesConfigurator feedStandardConfig
INFO: Reading standard config META-INF/standard-faces-config.xml
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator getWebAppConfig
INFO: Reading config /WEB-INF/faces-config.xml
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: Starting up MyFaces-package : myfaces-api in version : 2.0.2 from path : file:/D:/Programming/Eclipse%20Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/OnTheRun/WEB-INF/lib/myfaces-api-2.0.2.jar
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: Starting up MyFaces-package : myfaces-impl in version : 2.0.2 from path : file:/D:/Programming/Eclipse%20Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/OnTheRun/WEB-INF/lib/myfaces-impl-2.0.2.jar
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk12 not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk-sandbox not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk-sandbox12 not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tomahawk-sandbox15 not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : myfaces-orchestra-core not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : myfaces-orchestra-core12 not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : trinidad-api not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : trinidad-impl not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : tobago not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : commons-el not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator startLib
INFO: MyFaces-package : jsp-api not found.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.util.ExternalSpecifications isBeanValidationAvailable
INFO: MyFaces Bean Validation support disabled
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.FacesConfigurator handleSerialFactory
INFO: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
Jun 10, 2012 2:15:56 PM org.apache.myfaces.config.annotation.DefaultLifecycleProviderFactory getLifecycleProvider
INFO: Using LifecycleProvider java.lang.String
Jun 10, 2012 2:15:56 PM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
INFO: ServletContext 'D:\Programming\Eclipse Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\OnTheRun\' initialized.
Jun 10, 2012 2:15:56 PM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces

我认为是因为缺少一些库


更新

这是我的配置文件:

<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">
<application>
    <resource-bundle>
        <base-name>on.run.messages</base-name>
        <var>msgs</var>
    </resource-bundle>
</application>




<navigation-rule>
        <from-view-id>/login.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>secret</from-outcome>
        <to-view-id>/restricted/transactions.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>



</faces-config>

<?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>OnTheRun</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>*.xhtml</url-pattern>
</servlet-mapping>

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

<filter>
        <filter-name>AuthFilter</filter-name>
        <filter-class>on.run.AuthFilter</filter-class>
 </filter>
 <filter-mapping>
        <filter-name>AuthFilter</filter-name>
        <url-pattern>/restricted/*</url-pattern>
 </filter-mapping>

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
</web-app>

我也尝试过 tomahawk lib,但我删除了它并清理了项目。我试过这个例子来测试richface,但没有显示任何内容。

控制台消息仍然有效,即使我没有对 tomahawk 的任何引用,我的构建路径中也没有它,并且项目和服务器是干净的。我也尝试将myfaces-impl.jar 添加到buildpath,没有帮助。出现相同的控制台消息。

4

2 回答 2

3

但是eclipse会产生一个警告,上面写着

NSL missing: CANNOT_FIND_FACELET_TAGLIB in : org.eclipse.jst.jsf.core.validation.internal.facelet.messages

那是因为您将 RichFaces 库放在 Tomcat 中,而不是放在 webapp 本身中。这些库应该放在 webapp 自己的/WEB-INF/lib. 否则,您需要将 RichFaces 库添加到 Eclipse 项目构建路径设置中的服务器提供的库中。Eclipse 即不希望您修改 Tomcat 的默认库。


当我将 jars 添加为外部 jars 并添加依赖项时,它不会使站点崩溃,尽管在控制台中它会产生一个:

这些只是 INFO 消息,而不是 WARNING 消息。这是特定于 MyFaces 的,这些只是为了通知开发人员/服务器管理员 MyFaces 对设置一些应用程序范围的参数采取了哪些操作。只是忽略他们。只有当您收到警告、严重、错误或致命时,您才可能开始担心。您不一定需要战斧。

于 2012-06-11T13:49:46.433 回答
1

需要以下依赖项:

  • sac-1.3.jar,
  • cssparser-0.9.5.jar- 用于 CSS 样式。
  • guava-r09.jar- 核心运行时依赖。

当然javax.faces.jar对于 JSF(或 myfaces 替代品),看看这里

更新:

@BalusC建议了以下步骤:

  • 关闭/重新打开项目。
  • 右键单击项目 >验证
  • 项目 > 清理... 并清理选定的项目。
  • 重新启动 Eclipse。

更新 2:

我已经准备了一个基于 mojarra JSF 2.1的工作初始(动态 Web)项目,你可以在这里下载将此库放到其 WEB-INF\lib 文件夹中,在 tomcat7 服务器上启动它:

http://localhost:8080/TEST/
于 2012-06-10T08:12:47.783 回答