• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Custom taglib "cannot be resolved in either web.xml or the jar files deployed with this application"

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings,

I am working on a small security project and am attempting to implement custom tags.

The tag tld can be found here:

https://github.com/mcroteau/Parakeet/blob/taglib/artifact/src/main/resources/META-INF/parakeet.tld

I am including it in my jsp like so:




Complete source can be found here: https://github.com/mcroteau/Parakeet im on my taglib branch.

I get the following error:



Any ideas what could be causing this?

I appreciate any guidance. Thank you.

 
Marshal
Posts: 26537
81
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike, welcome to the Ranch!

Like the message says, your taglib needs to be in the application's web.xml or else in one of its associated jar files. Presumably you've put it out on the web in Github. So include it with your web application instead -- it looks like the TLD declares its URI correctly and that's what your JSP container needs.

This document explains the (very common) conceptual error you're making.
 
Croteau Mike
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul! The sample project that I created to test the taglibs contains the necessary jar dependency.

https://github.com/mcroteau/Parakeet/example is the example project on branch taglib.
I manually installed the dependency in https://github.com/mcroteau/Parakeet/artifact on branch taglib so it should be there.

I don't know what is missing, probably something small.

Thank you for your time.

Mike
 
Paul Clapham
Marshal
Posts: 26537
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably something small, yeah. But I'm not comforted by knowing that it's in the project on Github. Have you checked that it's in the right place in the place you're installing the web app?
 
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A URI is not a URL. URI stands for Uniform Resource Identifier and while a URL can be a URI, the difference is that a URL is a Uniform Resource Locator and thus unlike a URI, can be expected to be usable to actually fetch a resource. Unlike a URI, which may or may not be, since it's intended to be primarily an ID. Like a UUID/GUID, but human-friendly and resolvable from unknown clients.

I would not expect a URL reference to a TLD to work, since it would require the webapp server to fetch each and every TLD referenced via URL from a network source, which is a process that's much slower than local file access, potentially corruptible (insecure) both at the remote server and along the network path, and sometimes physically not possible if the webapp server is barred from the ability to call out to the Internet.

Putting the TLD as a WAR resource pointed to by web.xml is the most ancient and honorable way to do it, but if you're making a JAR of custom tags, the TLD should be located within that JAR so that it's a self-contained, self-configuring unit. I'll leave it to you to look up the exact details, but if memory serves, the TLD file would go in the JAR's /META-INF directory and I think there's a special directive for the JAR's manifest file as well. If those conditions are met and the custom taglib has been placed in the WAR's WEB-INF/lib directory alongside whatever other library JARs there may be, then the webapp server's deployment service will scan the JAR, pick up the requisite information and make the tags accessible.
 
Croteau Mike
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! I followed the following package convention repacked my maven dependency and it worked... thanks, you're a life saver.

 
Tim Holloway
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, but the better way is to put your TLD file in /src/main/webapp/META-INF/tags/. No need to do anything special to the POM. Everything in /src/main/webapp and /src/main/resources gets copied verbatim (relative path included) into the root of the WAR. It's a good place to put your static HTML pages, image resources and so forth.

/src/main/resources actually applies to the generic JAR goal, so I recommend using /src/main/webapp. Try and avoid any sort of path reference in your POM, if possible.
 
Croteau Mike
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! Made the adjustment to the previous post, lol, forgot I implemented the convention of in my jar project. Again, thank you! Regards!
 
Tim Holloway
Saloon Keeper
Posts: 23544
161
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Er, yeah. I just realized you're building a JAR at that point. So forget about /src/main/webapp. It's for WARs. Sorry about that.
 
Croteau Mike
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem, I wasn't confused, you made it clear. Thank you.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic