Eclipse "cannot find the tag library descriptor" for custom tags (not JSTL!)
Asked Answered
W

22

61

I have a Java EE project which build fine with Ant, deploys perfectly to JBoss, and runs without any trouble. This project includes a few custom tag libraries (which is not JSTL!), which are also working without any difficulties.

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:

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.

Our perfectly-working JSP files are a sea of red errors, and my eyes are beginning to burn.

How can I simply tell Eclipse, "The tag library descriptor you are looking for is "src/web/WEB-INF/(example)-taglib/(example).tld"?

I've already asked this question on the Eclipse support forums, with no helpful results.

Wampum answered 12/8, 2009 at 10:5 Comment(1)
This question is full of nonsense answers. The question is NOT about JSTL, but about real homegrown custom JSP tags in an user-defined foo.tld file. The real question and answer about how to install JSTL can be found here: Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”Torry
W
10

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

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

The only way I could find to add these was by editing the .project file, but after re-opening the project, everything magically worked. The settings referenced by pribeiro, above, weren't necessary since the project already conformed to the default settings.

Both pribeiro and nitind's answers gave me ideas to jumpstart my search, thanks.

Is there a way of editing these "natures" from within the UI?

Wampum answered 19/10, 2009 at 8:28 Comment(1)
The 'Project Facets' in the project properties may be the way. I faced a similar "cannot find tag library descriptor" problem which got fixed when I checked the correct project type under Project Facets.Kindergarten
H
28

In Eclipse Helios "Java EE Module Dependencies" in the project properties has been replaced with "Deployment Assembly".

So for solving this problem with Eclipse Helios, the way I did it is the following:

  • 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). Once in the path press OK.
  • Click besides jstl.jar and standard.jar to activate the check boxes
  • On the line Into folder click on Browse and choose the library folder. I use /lib inside the project.
  • Click "Finish"
  • Right click on the project in Package Explorer view and choose properties (or press Alt + Enter)
  • Click on "Java Build Path"
  • Click "Add Jar", click on your project, folder lib, select jstl.jar, press OK
  • Click "Add Jar", click on your project, folder lib, select standard.jar, press 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.".
  • 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

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.

Hellfire answered 20/1, 2011 at 6:34 Comment(3)
also Works with Eclipse 4.4.0 (Luna)Drews
Works great with Mars tooGraeco
This answer only describes how to install JSTL (in a devious way) and does therefore not answer OP's concrete problem with custom taglibs. The real answer to OP's problem is below. How to actually install JSTL the right way is answered here: Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”.Torry
D
19

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.

Try switching the uris from above to:

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.

Dotterel answered 1/11, 2010 at 21:33 Comment(2)
If you want JSTL 1.2 then use http://java.sun.com/jsp/jstl/* for JSTL 1.0 use http://java.sun.com/jstl/*.Hoe
Thanks, that worked. At the same time I could run project without errors in NetBeans with the http://java.sun.com/jsp/jstl/core which confuses me a little.Lalise
G
15

I had the same problem with a stripes taglib uri showing as not found. 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. Simply checking that box and doing a Maven clean install cleared all the errors.

I wonder why Eclipse doesn't assume I want my Maven dependencies in the build path...

Gonion answered 23/11, 2011 at 10:57 Comment(2)
What do you mean my Maven Clean install? I mean, I don't see anything looking like that in options provided by "Right Click on project" >> Maven. Doing a mvn clean install at the command line seems completely unrelated. FYI: my project runs fine if I deploy it on Tomcat "alone" but when running in Eclipse it throws "The absolute uri: java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application". Maybe I should simply use Eclipse as a fancy editor & stop expecting much more from it.Paramagnetic
When I changed the Nexus repository I was pointing to in my organisation, the result was the OP's original error. I found then found that the Maven dependencies checkbox was unchecked (after reading your answer). So I checked it and it rebuilt the project but the error was still there. I then ran right-click->Maven->Update Maven project with the "force update of snapshots/releases" checked and the error disappeared. However when I looked in the Order & Export tab again, the "Maven Dependencies" was unchecked! This is repeatable. However at least the error is gone.Boche
W
10

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

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

The only way I could find to add these was by editing the .project file, but after re-opening the project, everything magically worked. The settings referenced by pribeiro, above, weren't necessary since the project already conformed to the default settings.

Both pribeiro and nitind's answers gave me ideas to jumpstart my search, thanks.

Is there a way of editing these "natures" from within the UI?

Wampum answered 19/10, 2009 at 8:28 Comment(1)
The 'Project Facets' in the project properties may be the way. I faced a similar "cannot find tag library descriptor" problem which got fixed when I checked the correct project type under Project Facets.Kindergarten
E
8

Ran into the same problem, I'm using maven so I added this to the pom in my web project:

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

Here's where I found the solution: http://alfredjava.wordpress.com/2008/12/22/jstl-connot-resolved/

Ento answered 21/11, 2011 at 18:46 Comment(0)
E
4

When I tried to include the JSTL Core Library in my JSP:

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

I got the following error in 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). Most people would be using Tomcat. This solved my problem. Hope it helps!

Experimental answered 21/3, 2013 at 14:45 Comment(0)
P
3

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). How are you referring to the TLD file, and where is the JSP file located?

And maybe I missed the original post to the Eclipse forums; the one I saw was posted a full day after this one.

Plosion answered 18/8, 2009 at 16:43 Comment(0)
T
3

I fixed this problem today.

  • Change your output directory to your WEB-INF/classes folder. (Project/Properties/Java Build Path, Default output folder)
  • Assigne the module dependencies. (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.

I hope it helps.

Tetrapterous answered 25/9, 2009 at 15:8 Comment(2)
Thanks, I didn't know about the module dependencies settings.Wampum
My project doesn't have a "Java EE Module Dependencies" in its properties list. Java-related properties are only: BeanInfo Path Java Build Path Java Code Style Java Compiler Java Editor Javadoc Location Is there some other option which must be enabled?Wampum
N
2

Check the two libraries in F:\apache-tomcat-7.0.21\webapps\examples\WEB-INF\lib:

  1. jstl.jar
  2. standard.jar
Ningsia answered 3/9, 2011 at 15:25 Comment(1)
this would be a better answer with a more general path and with explaining what those libs are and where they can be found for other projects....Ev
I
2

I faced same problem. This is what I did to resolve the issue.

  1. Select Project and right click.
  2. Click on properties.
  3. Click on libraries tab.
  4. Click on 'Add Jars'.
  5. Add relevant jar for your error.
Iraq answered 14/6, 2013 at 21:49 Comment(1)
The same for me, I don't know why maven didn't put it in the referenced librariesSpirt
D
1

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.

Delitescence answered 11/11, 2011 at 5:24 Comment(1)
This question was asked and answered in 2009, answering now is less relevant.Combination
P
1

I'm using Spring STS plugin and a Spring webmvc template project. I had to install the Maven m2e plugin first: http://www.eclipse.org/m2e/

And then clean the project. Under Project -> Clean...

Patiencepatient answered 10/2, 2013 at 23:51 Comment(0)
D
1

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

  1. Ensure that the <uri> in the TLD and the uri in the taglib directive of your jsp pages match. The <uri> element of the tld is a unique name for the tag library.

  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. for e.g. 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. However, this is a bad practice and should be avoided since the paths would then be hardcoded.

Derby answered 17/9, 2013 at 7:21 Comment(1)
That's what fixed my JSP taglib resolution. Thanks.Aquileia
L
0

I had the same problem with MyEclipse and Eclipse 6.6.0. It red lined the uri value in every

<%@ 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'. I also had to do the same under 'Project/MyEclipse/Web/Configure workspace settings.../Tag Libraries'.

Lesbian answered 7/5, 2010 at 17:31 Comment(0)
S
0

I had the same problem with STS (springtool source suite).

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.

Suisse answered 29/2, 2012 at 19:0 Comment(0)
C
0

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

Let me know if this solves your "Cannot find the taglibrary descriptor" problem.

Caretaker answered 4/4, 2012 at 20:8 Comment(0)
C
0

well you need to understand there are always two things the API and the implementation (mind the gradle format of the following code)

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 i.e glassfish then glassfish will have both of them already inside.

Civilized answered 29/1, 2014 at 5:39 Comment(0)
D
0

For me, this error occurs whenever I try to use a new version of 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).

After updating M2_REPO variable to point to actual maven repository location, it takes 2-3 Project -> Clean iterations to get everything working.

And sometimes, there are some xml validation errors(ejb) along with this tag library errors. Manually updating the corresponding XML file, initiates a *.xsd file lookup and the xml validations errors are resolved. Post this, the tag library errors also vanish.

Dacy answered 12/8, 2014 at 6:24 Comment(0)
A
0

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. The settings are under Preferences->Web->JSP Files->Validation

Antineutrino answered 13/10, 2014 at 21:6 Comment(0)
A
0

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 releases typically lag behind up to a year in implementing newer servlet and JSP specifications. See this Eclipse bug for example.

In this case, your web application may run fine in the latest version of Tomcat, but Eclipse may still complain about a missing 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.

Also, keep in mind the TLD version you are implementing. The tag names have changed slightly from v1.1 to v2.0 (i.e., info is now description on taglib and is not a valid element under tag, many of the element names now contain a hyphen). Eclipse has no tolerance for misspelled TLD tag names.

TLD 2.0 (jsp-version 2.0) Reference

TLD 2.1 (jsp-version 2.3) Reference

Arak answered 16/11, 2016 at 21:17 Comment(0)
P
-1

replace jstl.jar to jstl1.2.jar resolved the issue for tomcat 7.0

Phebephedra answered 18/10, 2015 at 14:6 Comment(0)
G
-4

I also faced the same problem. Make sure you have same versions of JSTL in Eclipse and in the Tomcat work directory, i.e in \webapps\examples\WEB-INF\lib and in lib folder.

Gitlow answered 27/3, 2014 at 12:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.