OK... interesting results.  Your "muck-it-up" idea came to me while waiting for 
a response.  I changed the taglib location for JSTL to /KingKong and /GodZilla, 
and it still worked... and then removed the references to JSTL completely... 
and it still worked!!! ...suggesting for a moment we were both onto something.

> Interesting. Tomcat must be doing a "you know what I mean" resolution of
> the resource based upon the fact that the definition is being provided
> in conf/web.xml for the server instead of WEB-INF/web.xml for your
> webapp (right?).

So as I walked away utterly convinced the JSTL was magical (or built in) to 
Tomcat, I removed the jstl.jar and standard.jar.  Boom!  It stopped working.  
So, I figured I'd open up the jar files and take a look, and found their TLDs 
within a META-INF within standard.jar, which was located, of course, in 
{catalinahome}/lib.  This, then, must be the magic.  

I checked my customTags.jar and discovered I had not added the 
"META-INF/customTags.tld".  So, I put it in, removed all references to tags 
from BOTH web.xml files, and everything works!  It turns out, if you simply add 
the TLDs within the JAR, in Tomcat at least, and put the jar files in a shared 
loader location (I use /lib because it's configured already), custom tags 
become as magical as are JSTL. 

So, I have the solution... and have been over-configuring Tomcat for... well.. 
years now!  I just lucked out with JSTL the first time, putting it in "/lib" 
and the taglib references within "/conf/web.xml" .. and, since it worked that 
way, I patted myself on the back for a job well-done, and continued on that way 
till today!

Now I've got to go "un-configure" all those web.xml's!!!! &*...@!#!!


Thanks!

-----Original Message-----
From: Christopher Schultz [mailto:ch...@christopherschultz.net] 
Sent: Monday, October 26, 2009 11:33 AM
To: Tomcat Users List
Subject: Re: File "/customTagLibs" not found

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joseph,

On 10/26/2009 12:15 PM, Joseph Morgan wrote:
> Well, I'm trying to contain common tag libraries in a single, common,
> easily deployable space so I only have to deploy them once for all
> apps, and not into every app in existence (though there are arguments
> to be made for each app having its own independent stuff, even if it
> is the exact same stuff).
> 
> That path <taglib-location>/lib/tld/c.tld</taglib-location> works
> just fine with the JSTL tags, but not my custom tags.  It is easy
> enough to put my TLD declaration in the META-INF/web.xml.  It is now
> becoming a matter of "wtf"....

I suspect that Tomcat treats the JSTL declaration specially based upon
its taglib-uri: they don't want you to break the JSTL by incorrectly
specifying its location, so they ignore your taglib-location.

Try this: set the taglib-location to something that is obviously wrong
like /does-not-exist or something. If it works, you can convince
yourself that some trickery is being performed by Tomcat for the
standard libraries. This same technique is used with XML schemas for
things like webapp deployment descriptors so that Internet access is not
required to verify web.xml and other documents (not to mention avoiding
the the roundtrip time to fetch the schema or DTD, etc.).

> However, my Tomcat is not responding as you suggest.  The Tag libs
> are not relative to the JSP, but to the context root, always.  That
> is, at my context root, I have my JSP:

[snip]

> Note the taglib references are identical between the two.
> 
> The CORE jstl tags are (now) referenced in my
> {catalinahome}/conf/web.xml as:
> 
> =================================== <taglib> 
> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> 
> <taglib-location>/lib/tld/c.tld</taglib-location> </taglib> 
> ===================================
> 
> And my custom tags are in my {contextRoot}/META-INF/web.xml as:
> 
> =================================== <taglib> 
> <taglib-uri>customTags</taglib-uri> 
> <taglib-location>/../../lib/tld/custom.tld</taglib-location> 
> </taglib> ===================================
> 
> And BOTH work for BOTH the JSPs regardless of their location relative
> to the context root.

Interesting. Tomcat must be doing a "you know what I mean" resolution of
the resource based upon the fact that the definition is being provided
in conf/web.xml for the server instead of WEB-INF/web.xml for your
webapp (right?).

> However, if I simply move the custom tag
> reference from the {contextRoot}/META-INF/web.xml into the
> {catalinahome}/conf/web.xml, the custom tags stop working.

Oh, so I have it exactly wrong: it works when specified in your webapp's
web.xml but not in Tomcat's web.xml. Hmm. Try using
"/lib/tld/custom.tld" in conf/web.xml and see what happens?

> It is as
> if JSTL is built into Tomcat...  Because the JSTL stuff seems to be
> able to be referenced either way; by my ugly relative path and by the
> cleaner "/lib/tld/c.tld" version.  However, my custom tags ONLY work
> when referenced within the {contextRoot}/META-INF/web.xml with
> "/../../lib/tld/custom.tld"

Sounds like you've got your solution, even if it's non-ideal for you. I
would still highly recommend that anything not explicitly provided by
the server (such as JSTL) be included in your webapp if your webapp
needs it. Then you don't have to play games like this.

Good luck,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrlz1AACgkQ9CaO5/Lv0PCrPQCffNwVULkTdAu5GrPwcQ4fYPZ6
trAAoLLc1R4MrsI6iY/6isQymiVTb0zJ
=7MwL
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to