Menu

#114 TaglibFactory just read jars in WEB-INF/lib

2.3.22
closed-fixed
nobody
5
2015-02-28
2010-02-18
No

in eclipse i have a webapp project that depends on a java project in which there are some tlds and tags. when i run the app and try to render a template that references jsp taglibs, freemarker doesn't discover these tlds because it searches on WEB-INF/lib folder. i have patched the TaglibFactory to search in classpath resources (jars or folders). The patch has not been tested extensively but it's inspired to some production code of Magnolia CMS.

Discussion

  • Manuel Molaschi

    Manuel Molaschi - 2010-02-18

    TaglibFactory patch

     
  • Grégory Joseph

    Grégory Joseph - 2010-08-13

    Any plans on integrating this soon ?

     
  • Dániel Dékány

    Ticket moved from /p/freemarker/bugs/306/

     
  • Dániel Dékány

    It's not a bug, unless the JSP spec somewhere promises such behavior. None the less, it will be addressed on some other way.

     
  • Dániel Dékány

    • status: open --> open-accepted
    • Group: --> 2.3.22
     
  • Dániel Dékány

    OK, I think the problem is solved, but it's based on ClassLoader.getResources("META-INF/"), and is backward compatible. From the 2.3.22 version history:

    • RFE resolved [113] [114]: FreemarkerServlet can now discover META-INF/**/*.tld-s that are visible for the class loader but aren't in WEB-INF/lib/*.jar-s. For this feature to be active, you must setup the extra TLD lookup with the MetaInfTldSources and/or ClasspathTlds FreemarkerServlet init-params (see the Java API documentation of FreemarkerServlet for the description of these). For example, if you ran your application from Eclipse with an embedded servlet container, and thus the tag library jar-s aren't on the standard locations but are in the classpath like any other dependency, now you can just write:
      <init-param>
      <param-name>MetaInfTldSources</param-name>
      <param-value>classpath</param-value>
      </init-param>
      and then all the META-INF directories that are visible for the class loader will be searched for TLD-s.

    • MetaInfTldSources and ClasspathTlds can also be appended to or replaced by the values of Java system properties org.freemarker.jsp.metaInfTldSources and org.freemarker.jsp.classpathTlds, respectively. Thus one can adjust these in the Eclipse run configuration without modifying the web.xml. (See the Java API documentation of FreemarkerServlet for more.)

    • FreemarkerServlet now recognizes the org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern servlet context attribute, add entries to MetaInfTldSources (introduced above) from it.

    • Added protected FreemarkerServlet.createTaglibFactory() to allow fine tuning the settings of the TaglibFactory. It now have a few setters, like setObjectWrapper, setMetaInfTldSource, etc.

     

    Last edit: Dániel Dékány 2014-12-13
  • Dániel Dékány

    • Status: open-accepted --> closed-fixed
     

Log in to post a comment.