spring 无法读取 TLD“META-INF/c.tld”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3452403/
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-09-08 04:06:26  来源:igfitidea点击:

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

springmaven-2jstl

提问by DS.

there's this issue with JSTL I'm stuck with for the past couple of days. Any help is appreciated.

JSTL 有这个问题,我在过去几天一直被困。任何帮助表示赞赏。

Tomcat 6.0.28
Eclipse: Helios

Tomcat 6.0.28
Eclipse:太阳神

pom.xml :

pom.xml :

 <dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>jstl</artifactId>
   <version>1.1.2</version>
 </dependency>
 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.4</version>
  <scope>provided</scope>
</dependency>
<dependency>   
  <groupId>taglibs</groupId> 
  <artifactId>standard</artifactId> 
  <version>1.1.2</version> 
</dependency>
<dependency>   
  <groupId>javax.servlet.jsp</groupId> 
  <artifactId>jsp-api</artifactId> 
  <version>2.0</version>
  <scope>provided</scope>
</dependency>

JSP:

JSP:

<%@ page session="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="utilfn" uri="/utility-functions" %>

web.xml:

网页.xml:

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

When I deploy the Maven-built war on tomcat 6 using the manager it works fine. When I run it as "Run As > Run On Server" inside eclipse, I get this:

当我使用管理器在 tomcat 6 上部署 Maven 构建的War时,它工作正常。当我在 eclipse 中以“运行方式 > 在服务器上运行”的方式运行它时,我得到了这个:

Unable to read TLD "META-INF/c.tld" from JAR file "file:/<- location ->/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/standard-1.1.2.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagLibraryValidator class: org.apache.taglibs.standard.tlv.JstlCoreTLV

无法从 JAR 文件“file:/<- location ->/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-”中读取 TLD“META-INF/c.tld” INF/lib/standard-1.1.2.jar”:org.apache.jasper.JasperException:无法加载或实例化 TagLibraryValidator 类:org.apache.taglibs.standard.tlv.JstlCoreTLV

Wherever I look, it says the same thing:

无论我看哪里,它都说同样的话:

  1. Make sure servlet-api and jsp-api are not in lib
  2. Make sure to use the right JSTL version and URI that goes with JSP 2.0.
  1. 确保 servlet-api 和 jsp-api 不在 lib 中
  2. 确保使用与 JSP 2.0 一致的正确 JSTL 版本和 URI。

And they seem to be fine as I can deploy the war independently. So what's wrong here!?

他们似乎很好,因为我可以独立部署War。那么这里有什么问题!?

采纳答案by Pascal Thivent

Check that .metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/standard-1.1.2.jaris not corrupted (and do some cleanup if required).

检查 .metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/standard-1.1.2.jar未损坏(并在需要时进行一些清理)。

回答by Sobree Maenchi

After i moved using Indigo Eclipse 3.7 and took the lasted update of m2e, this problem happened to me, i remove the dependency below it worked well.

在我使用 Indigo Eclipse 3.7 移动并进行了 m2e 的最新更新后,这个问题发生在我身上,我删除了它下面的依赖项,它运行良好。

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

I'm not sure why the issues was gone, as my understanding new version of m2e has jsp compilation library already.

我不确定为什么问题消失了,因为我理解新版本的 m2e 已经有了 jsp 编译库。

回答by Alok Avjeet

remove :
javax.servlet.jsp jsp-api 2.0 provided

删除:提供
javax.servlet.jsp jsp-api 2.0

from you pom.xml and that should do.. it worked in my case :-)

来自您的 pom.xml 并且应该这样做..它在我的情况下有效:-)

回答by Jay

It looks like there is an issue with maven/m2eclipse plugin. Even I am seeing the same issue. By default it is pushing all the jar files to server lib directory. Which includes the scope "provided" jar files. This issue was fixed in old versions of m2eclipse. But it got introduced again it seems.

看起来 maven/m2eclipse 插件有问题。即使我看到了同样的问题。默认情况下,它将所有 jar 文件推送到服务器 lib 目录。其中包括范围“提供”的 jar 文件。此问题已在旧版本的 m2eclipse 中修复。但它似乎又被引入了。

回答by Josh Unger

Quickfix:

快速解决:

Make a backup of .classpath and .project and .settings/org.eclipse.wst.common.component.

备份 .classpath 和 .project 以及 .settings/org.eclipse.wst.common.component。

Run this command:

运行此命令:

mvn eclipse:eclipse

Or, right-clickover the project, in the Mavensub-menu, you have an Update Project...command which I think does the same thing.

或者,右键单击项目,在Maven子菜单中,您有一个Update Project...命令,我认为它可以做同样的事情。

Republish.

重新发布。

Explanation:

解释:

You likely added all Maven Dependencies as a Deployment Assembly to your project. This copies all Maven class path entries to the WEB-INF/lib directory. Open your .classpath file (at the root of your project) and you'll probably find the following XML:

您可能将所有 Maven 依赖项作为部署程序集添加到您的项目中。这会将所有 Maven 类路径条目复制到 WEB-INF/lib 目录。打开您的 .classpath 文件(在您项目的根目录下),您可能会发现以下 XML:

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
</classpathentry>

That means copy EVERY .jar file which becomes a problem in this case.

这意味着复制每个 .jar 文件,这在这种情况下会成为问题。

Updating the project should remove the XML block above and explicitly list the JAR files.

更新项目应该删除上面的 XML 块并明确列出 JAR 文件。

So, if you re-open .classpath, you'll see this instead:

所以,如果你重新打开 .classpath,你会看到这个:

<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.1/gson-2.2.1.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.1/gson-2.2.1-sources.jar"/>
<classpathentry kind="var" path="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar" sourcepath="M2_REPO/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1-sources.jar"/>
...

This is for the classpath which you still need, but it removed the dependency to copy them to lib. Instead, if you open .settings/org.eclipse.wst.common.component/, you'll see that the JAR files are now explicitly listed:

这是您仍然需要的类路径,但它删除了将它们复制到 lib 的依赖项。相反,如果您打开 .settings/org.eclipse.wst.common.component/,您将看到现在明确列出了 JAR 文件:

<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/com/google/code/gson/gson/2.2.1/gson-2.2.1.jar">
  <dependency-type>uses</dependency-type>
</dependent-module>

And, you'll note that jsp-api-2.1.jar is now missing. Apply the same logic to the other JAR files.

而且,您会注意到现在缺少 jsp-api-2.1.jar。将相同的逻辑应用于其他 JAR 文件。

Does anyone know how to make this automatic?

有谁知道如何使这个自动?

回答by hadf

You must exclude jsp-api dependency from jstl import in your pom.xml :

您必须从 pom.xml 中的 jstl 导入中排除 jsp-api 依赖项:

<dependency>
    <groupId>javax.servlet.jsp.jstl</groupId>
    <artifactId>jstl-api</artifactId>
    <version>1.2</version>
    <exclusions>
        <exclusion>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
        </exclusion>
        <exclusion>
            <artifactId>jsp-api</artifactId>
            <groupId>javax.servlet.jsp</groupId>
        </exclusion>
    </exclusions>
</dependency>

回答by charu

Removed jsp-api 2.0 from .metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/ this worked for me .

从 .metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/Myproject/WEB-INF/lib/ 中删除了 jsp-api 2.0 这对我有用。

回答by rene1234

I was getting the same error in netbeans IDE 8.0.2. It turns out my part was set to 8080 for outgoing and shutdown. I changed the outgoing to 8081 for Tomcat server. It worked! I then changed my shutdown port 8005. To change go to Tools>Servers>

我在 netbeans IDE 8.0.2 中遇到了同样的错误。事实证明,我的部分设置为 8080 用于传出和关闭。我将 Tomcat 服务器的传出更改为 8081。有效!然后我改变了我的关闭端口 8005。要改变去工具>服务器>

My tomcat server now works.

我的 tomcat 服务器现在可以工作了。

回答by theRiley

platform: eclipse 3.7 indigo, tomcat 6.0.29
commented out the following dependencies in pom.xml:

平台:eclipse 3.7 indigo,tomcat 6.0.29
注释掉了pom.xml中的如下依赖:

javax.servlet  
org.apache.taglibs  

this cleared up the issue (as they are provided via tomcat) ...

这解决了问题(因为它们是通过 tomcat 提供的)......

回答by Leo Huang

I agree with Jay's answer. I have same issue here. If I remove jsp-api from pom.xlm, maven test will fail because it cannot find jspWriter class in jsp-api jar. If I keep jsp-api in pom and set it to 'provided' or 'test', tomcat side will fail as the m2e plugin pushes jsp-api jar to maven dependencies which is then included in my tomcat deployed lib. I would say it's plugin issue as jsp-api has to be declared in pom.xml as provided because it is provided by application servers. I can't find any way of solving this issue but to manually delete the jsp-api every time after tomcat server synch.

我同意杰的回答。我在这里有同样的问题。如果我从 pom.xlm 中删除 jsp-api,maven 测试将失败,因为它在 jsp-api jar 中找不到 jspWriter 类。如果我将 jsp-api 保留在 pom 中并将其设置为“提供”或“测试”,则 tomcat 端将失败,因为 m2e 插件将 jsp-api jar 推送到 maven 依赖项,然后将其包含在我的 tomcat 部署库中。我会说这是插件问题,因为 jsp-api 必须在 pom.xml 中声明为所提供的,因为它是由应用程序服务器提供的。我找不到任何解决此问题的方法,只能在tomcat服务器同步后每次手动删除jsp-api。