views:

5515

answers:

5

I have a JEE project which build fine with Ant, deploys perfectly to JBoss, and runs without any trouble. This project includes a few custom tag libraries, 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 an 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.

+1  A: 

A lot depends on what kind of project is it? 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). 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.

nitind
+2  A: 

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.

pribeiro
Thanks, I didn't know about the module dependencies settings.
ryandenki
My project doesn't have a "Java EE Module Dependencies" in its properties list. Java-related properties are only:BeanInfo PathJava Build PathJava Code StyleJava CompilerJava EditorJavadoc LocationIs there some other option which must be enabled?
ryandenki
+1  A: 

It turns out that the cause was that this project wasn't being considered by Eclipse to actually be a JEE 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?

ryandenki
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.
hexium
A: 

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