Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Error "File /META-INF/tags/HelloTag.tag not found" when creating custom JSP Tag lib

Avatar

Level 2

Hi All,

I am creating a JSP custom tag using tag file but i am getting following error

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.jsp.jasper.JasperException: File "/META-INF/tags/HelloTag.tag" not found

 

tag file is located at /META-INF/tags/HelloTag.tag

Following are content of tag definition file located at //META-INF/taglibs.tld

<taglib xmlns="http://java.sun.com/xml/ns/javaee"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee        http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_1.xsd" version="2.1">    <tlib-version>1.0</tlib-version>    <short-name>Angular</short-name>    <uri>http://abc.org/Hello/Taglib</uri>    <tag-file>        <name>Hello</name>        <path>/META-INF/tags/HelloTag.tag</path>    </tag-file></taglib>

Also following is the configuration of bundle plugin

 

<plugin>    <groupId>org.apache.felix</groupId>    <artifactId>maven-bundle-plugin</artifactId>    <extensions>true</extensions>    <configuration>        <instructions>            <Bundle-SymbolicName>org.abc.angularjs-tags-aem</Bundle-SymbolicName>            <Sling-Model-Packages>org.abc.web.jsp.angularjs.tags</Sling-Model-Packages>            <Bundle-Resource>/META-INF/tags</Bundle-Resource>            <Sling-Bundle-Resource>/META-INF/tags</Sling-Bundle-Resource>        </instructions>    </configuration></plugin>

I read following blogs for creating this sample.

http://labs.6dglobal.com/blog/2013-07-02/tagfile-vs-tag-sling-or-cq5-application/

http://www.cqblueprints.com/tipsandtricks/jsp-custom-tag-lib.html

https://helpx.adobe.com/experience-manager/using/customtags.html

Also full maven artifact is attached with this form.

17 Replies

Avatar

Level 10

Can you share your JSP code?

Avatar

Level 2

I am using AEM 6.1 version.

https://helpx.adobe.com/experience-manager/using/customtags.html talks about custom tag using Java class but in my case I am using tag file (*.tag file).

Following is the jsp file

<%@page session="false" %><%@include file="/libs/foundation/global.jsp" %><%@ taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%@ taglib prefix="hello" uri="http://abc.org/Hello/Taglib" %><body data-ng-app="angularjsSample"  data-ng-controller="BaseController">    <hello:Hello target="World"/></body>

Also following is the tag file.

<%@ attribute name="target" required="true" rtexprvalue="false" type="java.lang.String" %><div> Hello <%=target%> </div>

Avatar

Level 10

Okay, so it seems you are creating .tag files not .tld.

You need to use /WEB-INF/tags as shown below

JSP, sample.jsp

<%@ page contentType="text/html" %> <%@ taglib prefix="my" tagdir="/WEB-INF/tags/myCustomTags" %> <html> <body> NAME : <my:name /> </body> </html>

TAG, name.tag

<%@ tag body-content="empty" %> <% out.println("AEM Developer"); %>

Please see these:

https://nikojava.wordpress.com/2009/01/12/jsp-custom-tags-part1-create-tag-file/

http://archive.oreilly.com/pub/a/onjava/excerpt/jserverpages3_ch11/index.html

Avatar

Level 2

Thanks Praveen for the reply.

There are two thing which need to be taken care in my case.

1. Tags will be located in separate package from content package. This separate package will be generic and can change at anytime. Thus do not want to hard code any paths.

2. My Tag library has both tag files and few java implementation of tags i.e. my tld xml will have both <tag> and <tag-file> elements. With this I am not sure if I can have single uri for tags located in /WEB_INF/tags and Java based tags.

Avatar

Level 10

AFAIK and implemented these in projects.

1. .tld will stay in OSGI bundle inside /META-INF and will be used with the help of uri.

2. .tags were places parallel to components in /apps and worked well with /WEB-INF path. and I don't thinks so it will work if you place .tags inside /META-INF as path for them has to start with  /WEB-INF.

Avatar

Level 2

Do you mean i have to place .tags in content maven artifact and not in OSGI bundle?

Avatar

Level 10

yes,

Create a simple folder under /apps/project/components/customtagfolder and place all your .tag file inside this customtagfolder 

Avatar

Level 1

Hi Praveen,

We are upgrading from 5.6.1 to 6.2.

We have placed .tld file inside /META-INF and .tag file is inside /META-INF/tags and it is working fine without giving any errors in 5.6.1.

We have installed all the bundles to 6.2 environment, now the error is"File /META-INF/tags/HelloTag.tag not found".

From AEM 5.6.1 to 6.2 any configuration has been changed ?

 From AEM 6.1 onwards is it compulsory to place the *.tag files inside apps folder /apps/project/components/customtagfolder?

Please help me on my questions

Avatar

Level 3

The same problem @sruthia75953514 described. Works fine in 5.6.1. On 6.2 a page is not loaded and in logs:

org.apache.sling.scripting.jsp.jasper.JasperException: File "/META-INF/tags/helloWorld.tagx" not found

Any solutions?

Avatar

Level 3

I've removed obsolete bundles

com.squeakysand.sling - squeakysand-sling-taglibcom.squeakysand.sling.squeakysand-sling-taglib com.squeakysand.jsp - squeakysand-jsp-taglibcom.squeakysand.jsp.squeakysand-jsp-taglib com.squeakysand.jcr - squeakysand-jcr-taglibcom.squeakysand.jcr.squeakysand-jcr-taglib com.cqblueprints.taglib - cqblueprints-taglibcom.cqblueprints.taglib.cqblueprints-taglib

and this has fixed my problem

Avatar

Level 3

Removing of the com.cqblueprints.taglib bundle has fixed the issue

Avatar

Former Community Member

We are upgrading from 6.1 to 6.3, I'm getting the same issue.

Any thoughts to fix this issue ?

Thanks

Arun

Avatar

Level 3

I am getting same issue when migrating from AEM 6.1 to AEM 6.3. We did an inplace upgrade. How do I find obsolete bundles in my instance. I dont have above bundles mentioned by Stanleyor.

Any thoughts what I need to check?

Thanks in advance!

Avatar

Level 2

Same problem I am facing with AEM 6.3 , any clue?

I have used tld generator maven plugin in my project. it successfully generating the tld file in jar file but not able to access the .tag file.

Avatar

Former Community Member

The issue was fixed in https://issues.apache.org/jira/browse/SLING-7044

Summary of the issue :

If a taglib in a bundle references a tag implemented as a script (located in /META-INF/tags) this script is not found as it is not searched within the bundle containing the tld - it's rather used as a resource on the classpath.

Please contact Adobe to get the patch fix for this issue.

Thanks

Arun

Avatar

Level 4

I'm having the exact same issue as the other folks on this issue. arunjoshh​ are you able to confirm that Adobe has a patch available?

Avatar

Former Community Member

The issue was fixed in https://issues.apache.org/jira/browse/SLING-7044

This fix will be included in AEM 6.3.1.1, you can contact Adobe to get the pacth for this issue.

Thanks

Arun