[MAGNOLIA-2608] Tag library support in freemarker does't work with expanded jars Created: 31/Jan/09  Updated: 12/Sep/11  Resolved: 09/Sep/11

Status: Closed
Project: Magnolia
Component/s: templating
Affects Version/s: 4.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Fabrizio Giustina Assignee: Fabrizio Giustina
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
duplicate
duplicates MAGNOLIA-3092 freemarker: support for loading tagli... Closed
relation
is related to MAGNOLIA-3092 freemarker: support for loading tagli... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

freemarker can't load tag libraries when magnolia (magnolia/trunk) is run inside eclipse. The magnolia webapp is run from the eclipse workspace, without copying resources to a standard webapp layout (WEB-INF/lib doesn't exists and taglib modules are not jarred).
Unfortunately freemarker looks for taglib in a WEB-INF/lib folder explicitly and dies with a NPE if the folder is missing:

Caused by: java.lang.NullPointerException
at freemarker.ext.jsp.TaglibFactory.getLocationsFromLibJars(TaglibFactory.java:290)
at freemarker.ext.jsp.TaglibFactory.getMoreTaglibLocations(TaglibFactory.java:206)
at freemarker.ext.jsp.TaglibFactory.get(TaglibFactory.java:163)

.. or simply complains about the missing taglib if an empty WEB-INF/lib directory is created:

freemarker.template.TemplateModelException: Could not find webapp resource /cms-taglib
at freemarker.ext.jsp.TaglibFactory.loadTaglib(TaglibFactory.java:432)
at freemarker.ext.jsp.TaglibFactory.access$300(TaglibFactory.java:106)
at freemarker.ext.jsp.TaglibFactory$Taglib.load(TaglibFactory.java:414)

(tried by simply adding the demo-project dependency to the empty webapp)

unfortunately really annoying during development...



 Comments   
Comment by Philipp Bracher [ 03/Feb/09 ]

The only way to make freemarker happy if the tld is not in the jar (this is the case if you develop in eclipse for instance) is to copy the tld files to WEB-INF and register the tlds in the web.xml.

  <jsp-config>
    <taglib>
        <taglib-uri>cms-taglib</taglib-uri>
        <taglib-location>cms-taglib.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>cms-util-taglib</taglib-uri>
        <taglib-location>cms-util-taglib.tld</taglib-location>
    </taglib>
  </jsp-config>
Comment by Michael Vorburger [ 04/Jan/11 ]

Hola Magnolians in Basel. FYI I've hit the same issue, in a completely different (non-Magnolia) context of FreeMarker, and just wanted to make you aware of https://sourceforge.net/tracker/?func=detail&aid=3151460&group_id=794&atid=100794. You may be interested in both watching my FreeMarker feature request, as well as my description in there how I worked around this (especially if you are using Jetty, are you?). Greetings, from Lausanne!

Comment by Philipp Bärfuss [ 11/Jan/11 ]

That is really an obstacle for Magnolia newcomers developing in eclipse. Should had opened such a ticket long before. Thanks for taking action on this.

Comment by Danilo Ghirardelli [ 07/Sep/11 ]

There is also Manuel's patch in the linked issue that could work with the current implementation of freemarker, without waiting for servlet 3.0

Comment by Fabrizio Giustina [ 09/Sep/11 ]

closing as duplicate, all the related comments have been moved to MAGNOLIA-3092

Generated at Mon Feb 12 03:38:22 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.