0

我们有一个 Struts+Spring+Hibernate 应用程序,我们正在尝试集成 JSF。为此,我们在web.xml和中进行了一些配置struts-config.xml。我已将一些 JAR 文件添加到WEB-INF/lib.

我的 WEB-INF/lib 中包含的 jar 文件在此处列出:

antlr-2.7.6rc1.jar,asm.jar,asm-attrs.jar,bsh-2.0b2.jar,c3p0-0.9.1.2-jdk1.3.jar,cglib-2.1.3.jar,commons-beanutils-1.7 .jar,commons-betwixt-0.8.jar,commons-cli-1.0.jar,commons-codec-1.3.jar,commons-collections-3.jar,commons-dbcp-1.2.1.jar,commons-digester-1.7 .jar,commons-discovery-0.2.jar,commons-fileupload.jar,commons-httpclient-3.1.jar,commons-io-1.3.1.jar,commons-lang-2.3.jar,commons-logging-1.1.jar ,commons-pool-1.2.jar,commons-validator.jar,connector-1_5.jar,dom4j-1.6.1.jar,ehcache-1.1.jar,el-api-6.0.20.jar,el-impl-2.2 .0-SNAPSHOT.jar,hibernate-3.1.3.jar,jetty-util-6.0.0,.jar,servlet-api-2.3.jar,spring-2.5.6.jar,standard.jar,struts.jar, xercesImpl-2.6.2.jar,xmlParserAPIs-2.6.2.jar,xstream-1.3.1

以下 jar 文件是新添加的用于集成 JSF 的文件:

jsf-api-2.0.jar,jsf-impl-2.0.jar,myfaces-jsf-api-1.0.9.jar.jar.jar,struts-faces-1.3.10.jar

web.xml的是:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>SSHIntgr</display-name>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:/config/applicationContext.xml</param-value>
    </context-param>


     <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>
            org.apache.struts.action.ActionServlet
        </servlet-class>

        <init-param>
            <param-name>config</param-name>
            <param-value>/config/struts-config.xml</param-value>
        </init-param>
        <init-param>
            <param-name>debug</param-name>
            <param-value>3</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>3</param-value>
        </init-param>
        <init-param>
            <param-name>locale</param-name>
            <param-value>true</param-value>
        </init-param>

        <load-on-startup>2</load-on-startup>
    </servlet>
    <!-- struts-faces configuration start -->
     <servlet>
      <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- struts-faces configuration start -->
<listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
 <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>     
</web-app>

struts-config.xml的是

<struts-config>

    <form-beans>
        <form-bean name="usrForm" type="com.sshi.web.form.UsrForm" />
    </form-beans>

    <global-exceptions />

    <global-forwards />

    <action-mappings>

        <action path="/login" type="com.sshi.web.action.LoginAction"
            name="usrForm" scope="request">
            <forward name="allowUser" path="/pages/Welcome.jsp"/>
            <forward name="denyUser" path="/index.jsp"/>
        </action>

    </action-mappings>

  <controller>
<set-property property="processorClass"
value="org.apache.struts.faces.
application.FacesRequestProcessor"/>
</controller>
 <message-resources key="MessageResources" parameter="MessageResources"  null="false" />
     <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames"
            value="/config/validator-rules.xml,/config/validation.xml" />
        <set-property property="stopOnFirstError" value="true" />
    </plug-in>
</struts-config>

我正在使用 Spring 源收费套件、Tomcat 5.5 和 JDK 1.5。我的Tomcat 5.5\common\lib包含 JAR 文件

commons-el.jar,jasper-compiler.jar,jasper-compiler-jdt.jar,jasper-runtime.jar,jsp-api.jar,naming-factory.jar,naming-factory-dbcp.jar,命名资源。罐子,servlet-api.jar

我的服务器正常启动但无法加载 JSP 页面,我收到异常

org.apache.jasper.JasperException: Unable to read TLD "META-INF/jsf_core.tld" from JAR file "file:/SSHIntgr/WEB-INF/lib/jsf-impl-2.0.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: com.sun.faces.taglib.jsf_core.CoreValidator
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:179)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:181)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:418)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483)

我该如何解决这个问题?

4

1 回答 1

2

您使用的是 Servlet 2.4 容器的 tomcat 5.5,但 JSF 2.0 需要 Servlet 2.5 或更高版本。

所以你有2个选择:

  • 将您的 servletcontainer 升级到与 Servlet 2.5 相当的容器(例如 Tomcat 6.0)。
  • 将 JSF 降级到与 Servlet 2.4 兼容的 1.2。

与具体问题无关:该文件servlet-api-2.3.jar属于. WEB-INF/lib摆脱它。它应该已经由 servletcontainer 提供(在这种情况下,是 Tomcat's 中的那个/lib)。保留此文件只会导致运行时丢失类定义或抽象方法错误。

于 2011-04-12T14:21:26.710 回答