Create own custom tag library in Liferay 7.0Create own custom tag library in Liferay 7.0https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=769863322024-03-28T11:56:10Z2024-03-28T11:56:10ZRE: Create own custom tag library in Liferay 7.0Mithun Sealhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1193777362020-06-12T12:03:48Z2020-06-12T12:03:48ZI think I am facing similar problem here.<br /><br />As part of Liferay upgrade from 6.2 to 7.2, I am updating the code and using war file to deploy in Liferay 7.2. I am facing some issue to deploy custom taglib project in 7.2.<br /><br />If I create a liferay-plugin-packages.properties and add below entry, I am able to deploy the war but in runtime I am getting freemarker template exception. With this I am unable to access the application. Any idea what I am doing wrong?<br /><br />Provide-Capability=osgi.extender;osgi.extender=\"jsp.taglib\";uri=\"/WEB-INF/tld/my-custom.tld\"<br /><br />Error:<br />[FreeMarkerManager:216] Unable to add taglib liferay_portlet to context<br />freemarker.template.TemplateModelException: Error while loading tag library for URI "/META-INF/liferay-portlet-ext.tld" from TLD location "servletContext:/META-INF/liferay-portlet-ext.tld"; see cause exception.<br /><br />Caused by: freemarker.ext.jsp.TaglibFactory$TldParsingSAXException: In bundleresource://1113.fwk948623530:31/META-INF/liferay-portlet-ext.tld, at line 528, column 8:_Can't load class "com.liferay.taglib.portletext.RuntimeTag" for custom tag "runtime". [Sanitized]Mithun Seal2020-06-12T12:03:48ZRE: Create own custom tag library in Liferay 7.0Thomas Kellererhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=916153122017-07-10T05:41:32Z2017-07-10T05:41:32Z<div class="quote-title">David H Nebinger:</div><blockquote>Is your TLD properly registered and mapped such that FM would be able to dynamically load it when it needs it?</blockquote><br />I assume that they are, as my portlets can use the tags. But I am not sure how I would "properly" do that. There is no documentation on how to "properly register" a TLD.<br /><br />But anyhow: the error messages went away when I removed the file <span style="font-family: Courier New">taglib-mappings.properties</span> from my module.Thomas Kellerer2017-07-10T05:41:32ZRE: Create own custom tag library in Liferay 7.0David H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=915507912017-07-07T13:17:35Z2017-07-07T13:17:35ZLooks like FM is having trouble accessing the tld file using "servletcontext:/META-INF/my_tags.tld". That is likely true because "servletcontext" is likely referring to some other context.<br /><br />Is your TLD properly registered and mapped such that FM would be able to dynamically load it when it needs it?<br /><br />Looking at the relevant code, you can see that FM is trying to fetch the TLD: <a href="https://github.com/apache/incubator-freemarker/blob/2.3-gae/src/main/java/freemarker/ext/jsp/TaglibFactory.java#L178">https://github.com/apache/incubator-freemarker/blob/2.3-gae/src/main/java/freemarker/ext/jsp/TaglibFactory.java#L178</a><br /><br /><br /><br /><br /><br /><br /><a href="https://www.eventbrite.com/e/liferay-symposium-north-america-2017-registration-28398031276">Come meet me at the 2017 LSNA!</a>David H Nebinger2017-07-07T13:17:35ZRE: Create own custom tag library in Liferay 7.0Thomas Kellererhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=915435032017-07-07T09:47:20Z2017-07-07T09:47:20Z<div class="quote-title">Thomas Kellerer:</div><blockquote>But it would still be nice to know how to get rid of that exception.</blockquote><br />Actually it wouldn't just be "nice" - it is pretty important. Currently each and every page access (even pages not using my own JSP) will throw and log that exception. <br /><br />This makes it nearly impossible to find <strong>real</strong> error messages in the logfile and it would put a high burden on the production server, if I can't fix this.Thomas Kellerer2017-07-07T09:47:20ZRE: Create own custom tag library in Liferay 7.0Thomas Kellererhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=914920642017-07-06T10:30:43Z2017-07-06T10:30:43Z<html><head></head><body>I managed to get my taglib working in my JSP pages, however each time I display such a page I see the following exception in the Liferay logfile:<br><br><pre><code>12:26:45,078 ERROR [http-nio-8080-exec-12][FreeMarkerManager:208] Unable to add taglib my_tags to context
FreeMarker template error:
freemarker.template.TemplateModelException: Error while loading tag library for URI "/META-INF/my_tags.tld" from TLD location "servletContext:/META-INF/my_tags.tld"; see cause exception.
at freemarker.ext.jsp.TaglibFactory.get(TaglibFactory.java:260)
at com.liferay.portal.template.freemarker.internal.FreeMarkerManager$TaglibFactoryWrapper.get(FreeMarkerManager.java:647)
at com.liferay.portal.template.freemarker.internal.FreeMarkerManager.addTaglibSupport(FreeMarkerManager.java:205)
at com.liferay.taglib.util.ThemeUtil.doIncludeFTL(ThemeUtil.java:276)
at com.liferay.taglib.util.ThemeUtil.doDispatch(ThemeUtil.java:157)
at com.liferay.taglib.util.ThemeUtil.includeFTL(ThemeUtil.java:100)
at com.liferay.taglib.util.ThemeUtil.include(ThemeUtil.java:82)
at com.liferay.taglib.theme.WrapPortletTag.doEndTag(WrapPortletTag.java:101)
at org.apache.jsp.html.common.themes.portlet_jsp._jspService(portlet_jsp.java:1863)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)</code></pre><br><br>The error is thrown by the Freemarker engine, so it doesn't affect my JSP pages (they do work properly). <br><br>But it would still be nice to know how to get rid of that exception.</body></html>Thomas Kellerer2017-07-06T10:30:43ZRE: Create own custom tag library in Liferay 7.0zhou zhouhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=914875232017-07-06T08:27:05Z2017-07-06T08:27:05ZI solve this problem by https://github.com/liferay/liferay-portal/tree/master/modules/apps/foundation/map/map-taglib<br /> <br /><br />and portlet page view.jsp<br /><%@ taglib uri="http://liferay.com/tld/map" prefix="liferay-map" %><br /><liferay-map:map-display /><br /><br />thankszhou zhou2017-07-06T08:27:05ZRE: Create own custom tag library in Liferay 7.0David H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=772680462016-08-02T12:54:53Z2016-08-02T12:54:53ZThat's exactly what Chema was pointing you to...<br /><br /><br /><br /><br /><br /><br />Come meet us at the <strong><a href="https://web.liferay.com/web/events2016/northamerica/home">LSNA!</a></strong>David H Nebinger2016-08-02T12:54:53ZRE: Create own custom tag library in Liferay 7.0Sandip Patelhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=772683492016-08-02T12:15:12Z2016-08-02T12:15:12ZI got my answer in below link.<br /> http://stackoverflow.com/questions/38522892/creating-a-custom-taglib-in-liferay-7<br />https://github.com/liferay/liferay-portal/tree/master/modules/apps/foundation/map/map-taglib<br /><br />Thanks,Sandip Patel2016-08-02T12:15:12ZRE: Create own custom tag library in Liferay 7.0Chema Balsashttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=770084572016-07-26T09:07:56Z2016-07-26T09:07:56ZHey Sandip,<br /><br />You should be able to create and deploy simple modules with your taglibs. You can use some of the existing taglib modules as a guideline:<br /><br /><ul><li><a href="https://github.com/liferay/liferay-portal/tree/master/modules/apps/collaboration/flags/flags-taglib">flags-taglib</a></li><li><a href="https://github.com/liferay/liferay-portal/tree/master/modules/apps/foundation/frontend-taglib/frontend-taglib">frontend-taglib</a></li><li><a href="https://github.com/liferay/liferay-portal/tree/master/modules/apps/foundation/map/map-taglib">map-taglib</a></li><li><a href="https://github.com/liferay/liferay-portal/tree/master/modules/apps/web-experience/trash/trash-taglib">trash-taglib</a></li><li>...</li></ul><br /><br />Hope it helps!Chema Balsas2016-07-26T09:07:56ZRE: Create own custom tag library in Liferay 7.0David H Nebingerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=769907642016-07-25T23:06:31Z2016-07-25T23:06:31ZIt's still just a jar with your tag stuff. Instead of promoting to the portal, just bundle it with each war that uses the tag lib.David H Nebinger2016-07-25T23:06:31ZCreate own custom tag library in Liferay 7.0Sandi