简体   繁体   English

Eclipse“找不到自定义标签的标签库描述符”(不是JSTL!)

[英]Eclipse “cannot find the tag library descriptor” for custom tags (not JSTL!)

I have a Java EE project which build fine with Ant, deploys perfectly to JBoss, and runs without any trouble. 我有一个可以用Ant构建的Java EE项目,可以完美地部署到JBoss,并且可以毫无困难地运行。 This project includes a few custom tag libraries (which is not JSTL !), which are also working without any difficulties. 这个项目包括一些自定义标记库(不是JSTL !),它们也没有任何困难。

The problem is with the Eclipse IDE (Ganymede): in every single JSP file which uses our custom tags, the JSP parser flags the taglib include line with with this error: 问题出在Eclipse IDE(Ganymede)上:在每个使用我们自定义标记的JSP文件中,JSP解析器使用此错误标记taglib包含行:

Cannot find the tag library descriptor for (example).tld

This also causes every use of the tab library to be flagged as an error, and since the IDE doesn't have their definition, it can't check tag parameters, etc. 这也导致标签库的每次使用都被标记为错误,并且由于IDE没有它们的定义,因此无法检查标记参数等。

Our perfectly-working JSP files are a sea of red errors, and my eyes are beginning to burn. 我们完美工作的JSP文件是一个红色错误的海洋,我的眼睛开始燃烧。

How can I simply tell Eclipse, "The tag library descriptor you are looking for is "src/web/WEB-INF/(example)-taglib/(example).tld"? 我怎样才能简单地告诉Eclipse,“你要找的标签库描述符是”src / web / WEB-INF /(example)-taglib /(example).tld“?

I've already asked this question on the Eclipse support forums, with no helpful results. 我已经在Eclipse支持论坛上问过这个问题,没有任何有用的结果。

In Eclipse Helios "Java EE Module Dependencies" in the project properties has been replaced with "Deployment Assembly". 在Eclipse Helios中,项目属性中的“Java EE Module Dependencies”已替换为“Deployment Assembly”。

So for solving this problem with Eclipse Helios, the way I did it is the following: 因此,为了解决Eclipse Helios的这个问题,我的方法如下:

  • Right click on the project in package explorer and choose "Import..." 右键单击包浏览器中的项目,然后选择“导入...”
  • Accept the default selection "File System" and press "Next" 接受默认选择“文件系统”并按“下一步”
  • Press "Browse" in the From directory line, go to your tomcat installation and locate the file webapps/examples/WEB-INF/lib (I have tomcat 6, other versions of Tomcat may have the path webapps/jsp-examples/WEB-INF/lib). 在From目录行中按“Browse”,转到你的tomcat安装并找到webapps / examples / WEB-INF / lib文件(我有tomcat 6,其他版本的Tomcat可能有路径webapps / jsp-examples / WEB- INF / lib目录)。 Once in the path press OK. 进入路径后按OK。
  • Click besides jstl.jar and standard.jar to activate the check boxes 单击jstl.jar和standard.jar以激活复选框
  • On the line Into folder click on Browse and choose the library folder. 在Into行文件夹中单击Browse并选择库文件夹。 I use /lib inside the project. 我在项目中使用/ lib。
  • Click "Finish" 点击“完成”
  • Right click on the project in Package Explorer view and choose properties (or press Alt + Enter) 在Package Explorer视图中右键单击项目并选择属性(或按Alt + Enter)
  • Click on "Java Build Path" 点击“Java Build Path”
  • Click "Add Jar", click on your project, folder lib, select jstl.jar, press OK 单击“添加Jar”,单击您的项目,文件夹lib,选择jstl.jar,然后按OK
  • Click "Add Jar", click on your project, folder lib, select standard.jar, press OK 单击“添加Jar”,单击您的项目,文件夹lib,选择standard.jar,然后按OK
  • Press OK to dismiss the properties dialog 按“确定”关闭属性对话框
  • Click on the Problems view and select the message "Classpath entry .../jstl.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.". 单击Problems视图,然后选择消息“Classpath entry ... / jstl.jar将不会被导出或发布。可能会导致运行时ClassNotFoundExceptions。”。
  • Right click on it and select "Quick Fix". 右键单击它并选择“快速修复”。
  • Accept the default "Mark the associated raw classpath entry as a publish/export dependency" and press Finish. 接受默认值“将关联的原始类路径条目标记为发布/导出依赖项”,然后按“完成”。
  • Do the same for standard.jar 对standard.jar执行相同的操作

This solves the problem, but if you want to check what has happened in "Deployment Assembly", open the project properties again, select "Deployment Assembly" and you'll see that standard.jar and jstl.jar have been added to WEB-INF/lib folder. 这解决了这个问题,但如果你想检查“部署程序集”中发生了什么,再次打开项目属性,选择“部署程序集”,你会看到已将标准.jar和jstl.jar添加到WEB- INF / lib文件夹。

This was my problem and how I fixed it... 这是我的问题以及我如何解决它...

I had done everything everyone had mentioned above etc. but was still getting this error. 我做过上面提到的所有事情,但仍然遇到了这个错误。 Turns out I was using the uri's of http://java.sun.com/jsp/jstl/fmt and http://java.sun.com/jsp/jstl/core which were incorrect. 事实证明我使用的是http://java.sun.com/jsp/jstl/fmthttp://java.sun.com/jsp/jstl/core的uri,这些都不正确。

Try switching the uris from above to: 尝试将uris从上面切换到:

http://java.sun.com/jstl/fmt
http://java.sun.com/jstl/core

Also, make sure you have the correct jars referenced in your class path. 另外,请确保在类路径中引用了正确的jar。

I had the same problem with a stripes taglib uri showing as not found. 我有同样的问题,条纹taglib uri显示为未找到。 I was using Indigo and Maven and when I checked Properties->Java Build Path->Order & Export Tab I found (on a fresh project checkout) that the "Maven Dependencies" checkbox was unchecked for some reason. 我正在使用Indigo和Maven,当我检查Properties-> Java Build Path-> Order&Export选项卡时,我发现(在新项目结账时)由于某种原因未选中“Maven Dependencies”复选框。 Simply checking that box and doing a Maven clean install cleared all the errors. 只需检查该框并执行Maven clean安装即可清除所有错误。

I wonder why Eclipse doesn't assume I want my Maven dependencies in the build path... 我想知道为什么Eclipse不假设我想在构建路径中使用我的Maven依赖项...

It turns out that the cause was that this project wasn't being considered by Eclipse to actually be a Java EE project at all; 事实证明,原因是Eclipse没有考虑这个项目实际上是一个Java EE项目; it was an old project from 3.1, and the Eclipse 3.5 we are using now requires several "natures" to be set in the project configuration file. 它是3.1中的一个旧项目,我们现在使用的Eclipse 3.5需要在项目配置文件中设置几个“性质”。

<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>InCode.inCodeNature</nature>
    <nature>org.eclipse.dltk.javascript.core.nature</nature>
    <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
    <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
    <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
    <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
</natures>

I was able to find the cause by creating a new "Dynamic Web Project" which properly read its JSP files, and diffing against the config of the older project. 我能够通过创建一个新的“动态Web项目”找到原因,该项目正确读取其JSP文件,并针对旧项目的配置进行区分。

The only way I could find to add these was by editing the .project file, but after re-opening the project, everything magically worked. 我能找到添加这些内容的唯一方法是编辑.project文件,但重新打开项目后,一切都神奇地起作用。 The settings referenced by pribeiro, above, weren't necessary since the project already conformed to the default settings. 上面的pribeiro引用的设置不是必需的,因为项目已经符合默认设置。

Both pribeiro and nitind's answers gave me ideas to jumpstart my search, thanks. pribeiro和nitind的答案都给了我想要快速启动我的搜索,谢谢。

Is there a way of editing these "natures" from within the UI? 有没有办法在UI中编辑这些“性质”?

Ran into the same problem, I'm using maven so I added this to the pom in my web project: 遇到同样的问题,我正在使用maven所以我把它添加到我的web项目中的pom:

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version> <!-- just used the latest version, make sure you use the one you need -->
    <scope>provided</scope>
</dependency>

This fixed the problem and I used "provided" scope because like the OP, everything was already working in JBoss. 这解决了问题,我使用了“提供”范围,因为像OP一样,一切都已经在JBoss中运行了。

Here's where I found the solution: http://alfredjava.wordpress.com/2008/12/22/jstl-connot-resolved/ 这是我找到解决方案的地方: http//alfredjava.wordpress.com/2008/12/22/jstl-connot-resolved/

When I tried to include the JSTL Core Library in my JSP: 当我试图在我的JSP中包含JSTL核心库时:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

I got the following error in Eclipse (Indigo): 我在Eclipse(Indigo)中遇到以下错误:

Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"

I went to the Project Properties -> Targeted Runtimes, and then checked the Server I was using (Geronimo 3.0). 我转到Project Properties - > Targeted Runtimes,然后检查我正在使用的服务器(Geronimo 3.0)。 Most people would be using Tomcat. 大多数人都会使用Tomcat。 This solved my problem. 这解决了我的问题。 Hope it helps! 希望能帮助到你!

A lot depends on what kind of project it is. 很大程度上取决于它是什么类型的项目。 WTP's JSP support either expects the JSP files to be under the same folder that's the parent of the WEB-INF folder (src/web, which it will then treat as "/" to find TLDs), or to have project metadata set up to help it know where that root is (done for you in a Dynamic Web Project through Deployment Assembly). WTP的JSP支持要求JSP文件位于WEB-INF文件夹(src / web的父级)的同一文件夹下,然后将其视为“/”以查找TLD,或者将项目元数据设置为帮助它知道root的位置(通过部署程序集在动态Web项目中完成)。 How are you referring to the TLD file, and where is the JSP file located? 您是如何引用TLD文件的,以及JSP文件位于何处?

And maybe I missed the original post to the Eclipse forums; 也许我错过了Eclipse论坛的原始帖子; the one I saw was posted a full day after this one. 我看到的那个是在这一个之后整整一天发布的。

I fixed this problem today. 我今天解决了这个问题。

  • Change your output directory to your WEB-INF/classes folder. 将输出目录更改为WEB-INF / classes文件夹。 (Project/Properties/Java Build Path, Default output folder) (项目/属性/ Java构建路径,默认输出文件夹)
  • Assigne the module dependencies. Assigne模块依赖。 (Project/Properties/Java EE Module Dependencies) they will be copied to the WEB-INF/lib folder where Eclipse looks for the tag lib definitions too. (项目/属性/ Java EE模块依赖项)它们将被复制到WEB-INF / lib文件夹,在该文件夹中Eclipse也会查找标记库定义。

I hope it helps. 我希望它有所帮助。

I faced same problem. 我遇到了同样的问题。 This is what I did to resolve the issue. 这就是我为解决这个问题所做的工作。

  1. Select Project and right click. 选择Project并右键单击。
  2. Click on properties. 单击属性。
  3. Click on libraries tab. 单击库选项卡。
  4. Click on 'Add Jars'. 点击“添加罐子”。
  5. Add relevant jar for your error. 为您的错误添加相关的jar。

Check the two libraries in F:\\apache-tomcat-7.0.21\\webapps\\examples\\WEB-INF\\lib : 检查F:\\apache-tomcat-7.0.21\\webapps\\examples\\WEB-INF\\lib的两个库:

  1. jstl.jar 的jstl.jar
  2. standard.jar standard.jar

I'm using Spring STS plugin and a Spring webmvc template project. 我正在使用Spring STS插件和Spring webmvc模板项目。 I had to install the Maven m2e plugin first: http://www.eclipse.org/m2e/ 我必须首先安装Maven m2e插件: http//www.eclipse.org/m2e/

And then clean the project. 然后清理项目。 Under Project -> Clean... Project -> Clean...

If your tld's are on the classpath, typically under the WEB-INF directory, the following two tips should resolve the issue (irrespective of your environment setup): 如果您的tld位于类路径上,通常位于WEB-INF目录下,则以下两个提示应解决此问题(无论您的环境设置如何):

  1. Ensure that the <uri> in the TLD and the uri in the taglib directive of your jsp pages match. 确保tLD中的<uri>和jsp页面的taglib指令中的uri匹配。 The <uri> element of the tld is a unique name for the tag library. tld的<uri>元素是标记库的唯一名称。

  2. If the tld does not have a <uri> element, the Container will attempt to use the uri attribute in the taglib directive as a path to the actual TLD. 如果tld没有<uri>元素,Container将尝试使用taglib指令中的uri属性作为实际TLD的路径。 for eg I could have a custom tld file in my WEB-INF folder and use the path to the this tld as the uri value in my JSP. 例如,我可以在WEB-INF文件夹中有一个自定义tld文件,并使用此tld的路径作为JSP中的uri值。 However, this is a bad practice and should be avoided since the paths would then be hardcoded. 但是,这是一种不好的做法,应该避免,因为这些路径将被硬编码。

You can simply go to Build Path -> Add Libraries and for the library type to add select "Server Runtime." 您只需转到构建路径 - >添加库,并为库类型添加选择“服务器运行时”。 Click Next and select a server runtime to add to the classpath and the problem goes away if jstl.jar and standard.jar are in your server's classpath. 单击Next并选择要添加到类路径的服务器运行时,如果jstl.jar和standard.jar位于服务器的类路径中,问题就会消失。

I was having the same problem using Tomcat 6.0 and Eclipse and I tried out something which my friend suggested and it worked for me. 我使用Tomcat 6.0和Eclipse遇到了同样的问题,我尝试了一些我朋友建议的东西,它对我有用。 The link for the question I asked and my reply commented can be found here: 可以在此处找到我提出的问题和我的回复评论的链接:

JSTL Tomcat 6.0 Cannot find the taglib descriptor Error JSTL Tomcat 6.0找不到taglib描述符错误

Let me know if this solves your "Cannot find the taglibrary descriptor" problem. 如果这解决了您的“无法找到taglibrary描述符”问题,请告诉我。

well you need to understand there are always two things the API and the implementation (mind the gradle format of the following code) 您需要了解API和实现总是有两件事(请注意以下代码的gradle格式)

compile group:'javax.servlet.jsp.jstl', name:'javax.servlet.jsp.jstl-api', version:'1.2.1'

compile group:'org.glassfish.web', name:'javax.servlet.jsp.jstl',version:'1.2.1'

so If you're using a servlet container with no jstl support then of course it will not provide both of them, a mistake which I made is that I only put the first one, but if you're using full stack application server ie glassfish then glassfish will have both of them already inside. 所以,如果你使用的是一个没有jstl支持的servlet容器,那么当然它不能同时提供它们,我犯的一个错误是我只放了第一个,但如果你使用的是完整的堆栈应用服务器,即glassfish然后玻璃鱼将已经在里面。

For me, this error occurs whenever I try to use a new version of eclipse. 对我来说,只要我尝试使用新版本的eclipse,就会出现此错误。 Apparently, the new eclipse resets the M2_REPO variable and I get all the tag library error in the Marker view (sometimes with ejb validation errors). 显然,新的eclipse会重置M2_REPO变量,并且我在Marker视图中得到了所有标记库错误(有时会出现ejb验证错误)。

After updating M2_REPO variable to point to actual maven repository location, it takes 2-3 Project -> Clean iterations to get everything working. 更新M2_REPO变量以指向实际的maven存储库位置后,需要2-3个Project - > Clean迭代才能使一切正常运行。

And sometimes, there are some xml validation errors(ejb) along with this tag library errors. 有时,有一些xml验证错误(ejb)以及此标记库错误。 Manually updating the corresponding XML file, initiates a *.xsd file lookup and the xml validations errors are resolved. 手动更新相应的XML文件,启动* .xsd文件查找并解析xml验证错误。 Post this, the tag library errors also vanish. 发布这个,标签库错误也消失了。

On the other hand, if you are only working on java source and are getting these errors from stuff you don't touch in a large project that is working, you can just turn off the validations in Eclipse. 另一方面,如果您只是处理java源代码并且正在从没有触及的大型项目中获取这些错误,那么您可以在Eclipse中关闭验证。 The settings are under Preferences->Web->JSP Files->Validation 设置位于Preferences-> Web-> JSP Files-> Validation下

I had the same problem with MyEclipse and Eclipse 6.6.0. 我在MyEclipse和Eclipse 6.6.0上遇到了同样的问题。 It red lined the uri value in every 它在每一个方面都是红色的

<%@ taglib prefix="s" uri="/struts-tags"%> . <%@ taglib prefix="s" uri="/struts-tags"%> I fixed it by going to 'Project/MyEclipse/Web/Tag Libraries' and setting the Default TLD Prefix for Struts 1.2 Tiles Tags to 's'. 我通过转到'Project / MyEclipse / Web / Tag Libraries'并将Struts 1.2 Tiles Tags的默认TLD前缀设置为's'来修复它。 I also had to do the same under 'Project/MyEclipse/Web/Configure workspace settings.../Tag Libraries'. 我还必须在“Project / MyEclipse / Web /配置工作区设置... /标签库”下执行相同的操作。

This error can arise from several different sources. 此错误可能来自几个不同的来源。 One case (not mentioned in other answers to this question) occurs when Eclipse does not implement the version of the JSP specification set in the TLD document. 当Eclipse未实现TLD文档中设置的JSP规范版本时,会出现一个案例(在此问题的其他答案中未提及)。 Eclipse releases typically lag behind up to a year in implementing newer servlet and JSP specifications. Eclipse版本通常在实现较新的servlet和JSP规范方面落后长达一年。 See this Eclipse bug for example. 例如,请参阅此Eclipse错误

In this case, your web application may run fine in the latest version of Tomcat, but Eclipse may still complain about a missing TLD. 在这种情况下,您的Web应用程序可能在最新版本的Tomcat中正常运行,但Eclipse仍可能会抱怨缺少TLD。 The short term solution (short of ignoring the error in Eclipse) is to bump down the JSP version to the one that your version of Eclipse supports. 短期解决方案(忽略Eclipse中的错误)是将JSP版本降级到您的Eclipse版本支持的版本。

Also, keep in mind the TLD version you are implementing. 另外,请记住您正在实施的TLD版本。 The tag names have changed slightly from v1.1 to v2.0 (ie, info is now description on taglib and is not a valid element under tag , many of the element names now contain a hyphen). 标签名称从v1.1略微改变为v2.0(即, info现在是taglib description ,并且不是tag下的有效元素,许多元素名称现在包含连字符)。 Eclipse has no tolerance for misspelled TLD tag names. Eclipse不能容忍拼写错误的TLD标记名称。

TLD 2.0 (jsp-version 2.0) Reference TLD 2.0(jsp-version 2.0)参考

TLD 2.1 (jsp-version 2.3) Reference TLD 2.1(jsp-version 2.3)参考

I had the same problem with STS (springtool source suite). 我和STS(springtool源代码套件)有同样的问题。

Under STS, right click on the project, than "Properties", "Project Facets", than on the right of the window click on the "runtime" tab, and check "VMware vFabric tc Server (...)", and click "Apply" and it should be OK after the workspace refresh. 在STS下,右键单击项目,而不是“属性”,“项目构面”,而不是在窗口右侧单击“运行时”选项卡,并选中“VMware vFabric tc Server(...)”,然后单击“应用”,工作区刷新后应该没问题。

将jstl.jar替换为jstl1.2.jar解决了tomcat 7.0的问题

I also faced the same problem. 我也遇到了同样的问题。 Make sure you have same versions of JSTL in Eclipse and in the Tomcat work directory, ie in \\webapps\\examples\\WEB-INF\\lib and in lib folder. 确保在Eclipse和Tomcat工作目录中具有相同版本的JSTL,即在\\webapps\\examples\\WEB-INF\\liblib文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM