I am migrating my Liferay portlets from 6.0 to Liferay 7.0 and one of the many roadblocks that I am hitting is the inclusion of my custom taglib.
I followed the advice from: Creating a custom taglib in Liferay 7 but my portlet fails to load the taglib, the following error is logged:
09:50:48,566 ERROR [http-nio-8080-exec-10][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)
However, my bundle JAR does contain META-INF/my_tags.tld
What strikes me, is that the error does not happen when my JSP is loaded but somewhere inside the theme's FreeMarker template. Apparently my JSP isn't even loaded at that point.
The error is thrown on each page in my portal, not only those that contain my portlet(s) (which is to be expected if the theme is already failing to access the taglib)
The structure of the bundle JAR is:
com/
content/
META-INF/
+--- resources/
MANIFEST.MF
taglib-mappings.properties
my_tags.tld
OSGI-INF/
WEB-INF/
The MANIFEST.MF that is generated by the bnd task contains the following dependency:
Require-Capability: osgi.extender;osgi.extender="jsp.taglib";uri="/META-INF/my_tags.tld"
The file taglib-mappings.properties
contains:
my_tags=/META-INF/my_tags.tld
I also tried putting the .tld files into WEB-INF/tld
where it would be with a plain, simple, standard portlet or web application, but to no avail either.
Do I need to add a mapping in the web.xml
(I am not sure if the new OSGi portlets even use web.xml) or add some other configuration option?