"Unable to read TLD META-INF/jsf_core.tld from jsf-impl-2.0.jar" error when integrating JSF

2.3k views Asked by At

We have a Struts+Spring+Hibernate Application and we are trying to integrate JSF. For that we have done some configuration in web.xml and struts-config.xml. I have added some JAR files to WEB-INF/lib.

The jar files containing in my WEB-INF/lib are listed here:

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

The below jar file are the ones newly added for integrating 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

My web.xml is:

<?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>

My struts-config.xml is

<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>

I am using Spring source toll suite, Tomcat 5.5 and JDK 1.5. My Tomcat 5.5\common\lib contains JAR files

commons-el.jar,jasper-compiler.jar,jasper-compiler-jdt.jar,jasper-runtime.jar,jsp-api.jar,naming-factory.jar,naming-factory-dbcp.jar, naming-resources.jar,servlet-api.jar

My Server is starting properly but not able to load JSP page, I am getting the exception as

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)

How can I solve this?

1

There are 1 answers

0
BalusC On

You're using tomcat 5.5 which is a Servlet 2.4 container, but JSF 2.0 requires Servlet 2.5 or newer.

So you have 2 options:

  • Upgrade your servletcontainer to a Servlet 2.5 comparible one (e.g. Tomcat 6.0).
  • Downgrade JSF to 1.2 which is compatible with Servlet 2.4.

Unrelated to the concrete problem: the file servlet-api-2.3.jar does not belong in WEB-INF/lib. Get rid of it. It's supposed to be already provided by the servletcontainer (in this case, the one in Tomcat's /lib). Keeping this file will only lead to missing class def or abstract method errors during runtime.