java 无法从 JAR 文件中读取 TLD“META-INF/c.tld”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10321430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 00:33:36  来源:igfitidea点击:

Unable to read TLD "META-INF/c.tld" from JAR file

javaspringjsptomcatspring-mvc

提问by quarks

I create a Spring MVC project from Spring template using the STS plugin. However when I run the application there's an error:

我使用 STS 插件从 Spring 模板创建了一个 Spring MVC 项目。但是,当我运行该应用程序时出现错误:

org.apache.jasper.JasperException: /WEB-INF/views/home.jsp(1,63) Unable to read TLD "META-INF/c.tld" from JAR file "file:/H:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/imgateway/WEB-INF/lib/jstl-1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV

Anyone have experienced this kind of issue?

任何人都遇到过这种问题?

回答by flurdy

Asked a several times before on StackOverflow: Unable to read TLD "META-INF/c.tld"

之前在 StackOverflow 上问过几次: 无法读取 TLD "META-INF/c.tld"

I did blog a potential answer to this once: http://blog.flurdy.com/2010/07/jetty-tomcat-jsp.html

我曾经在博客上写过一个可能的答案:http: //blog.flurdy.com/2010/07/jetty-tomcat-jsp.html

Depending on if your project uses maven you will need to ensure jsp-api is not included but provided by Tomcat instead by eg:

根据您的项目是否使用 maven,您需要确保不包含 jsp-api 而是由 Tomcat 提供,例如:

<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>2.5</version>
   <scope>provided</scope>
</dependency>
<dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>2.1</version>
   <scope>provided</scope>
</dependency>
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.2</version>
</dependency>
<dependency>
   <groupId>org.apache.tomcat</groupId>
   <artifactId>jasper-el</artifactId>
   <version>6.0.26</version>
</dependency>

回答by Veerayya

do NOT package javax.servlet.jsp.jar with your webapp, it confuses tomcat :P

不要将 javax.servlet.jsp.jar 与您的 webapp 打包在一起,它会混淆 tomcat :P

We were getting the exact same error, removing javax.servlet.jsp.jar from the WEB-INF/lib sorted it

我们得到了完全相同的错误,从 WEB-INF/lib 中删除 javax.servlet.jsp.jar 对其进行排序

回答by Rubens Mariuzzo

I was facing with the same situation and I realize that the error is thrown, obviously, because something went wrong with JSTL. Since, STS templates rely on Maven2, you should need to manually delete the JSTL artifact from your local Maven2 repository.

我面临着同样的情况,我意识到错误被抛出,显然,因为 JSTL 出了问题。由于 STS 模板依赖于 Maven2,您应该需要从本地 Maven2 存储库中手动删除 JSTL 工件

In Windows 7:Delete the folder c:\Users\<Username>\.m2\repository\javax\servlet\jstl\.

在 Windows 7 中:删除文件夹c:\Users\<Username>\.m2\repository\javax\servlet\jstl\

In Linux:Delete the folder /home/<Username>/.m2/repository/javax/servlet/jstl/

在 Linux 中:删除文件夹/home/<Username>/.m2/repository/javax/servlet/jstl/

Note:This is not the fault of STS, it just happens when an artifact was corrupted while being downloaded from the Internet. Deleting the arfifact will forceMaven2 to re-download it. Finally, it could happen with any artifact/file downloaded from the web.

注意:这不是 STS 的错,它只是在从 Internet 下载工件时发生损坏时发生。删除 arfifact 将强制Maven2 重新下载它。最后,从网上下载的任何工件/文件都可能发生这种情况。

回答by Thibaut

With Eclipse, please assure that you installed 'Maven Integration for Eclipse WTP' With the other plugin without WTP, eclipse change your classpath and include servlet-api.jar in your webapps.

对于 Eclipse,请确保您安装了 'Maven Integration for Eclipse WTP' 对于没有 WTP 的其他插件,eclipse 会更改您的类路径并在您的 web 应用程序中包含 servlet-api.jar。

回答by Jianchao Lee

The same default come with me today. This is a mistake caused by servlet-api.jarand jsp-api.jar,and you may need this two in you develop code,so ensure them appear in your pom.xml with provided. It looks work fine with me

今天我也有同样的默认。这是由servlet-api.jarand 引起的错误jsp-api.jar,你在开发代码时可能需要这两个,所以确保它们出现在你的 pom.xml 中并提供。它看起来对我很好

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.1</version>
    <scope>provided</scope>
</dependency>