maven dependencies import Developer Jahia 8

The class specified in TLD for the function cannot be found

Question

When using a view, I have the following error:

2022-12-20 08:07:58,919: ERROR [http-nio-80-exec-20] org.jahia.modules.tools.JspPrecompileServlet: The class [org.jahia.modules.forms.taglib.Functions] specified in TLD for the function [formfactory:addFormFactoryModulePath] cannot be found: [org.jahia.modules.forms.taglib.Functions not found by my-custom-bundle [146]]
org.apache.jasper.JasperException: The class [org.jahia.modules.forms.taglib.Functions] specified in TLD for the function [formfactory:addFormFactoryModulePath] cannot be found: [org.jahia.modules.forms.taglib.Functions not found by my-custom-bundle [146]]
	at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55) ~[jasper.jar:9.0.54]
	at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:294) ~[jasper.jar:9.0.54]
	at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:81) ~[jasper.jar:9.0.54]
	at org.apache.jasper.compiler.Validator$ValidateVisitor$1MapperELVisitor.visit(Validator.java:1736) ~[jasper.jar:9.0.54]

 

Answer

Setting a dependency to forms-core is not enough. You also need to add the referred packages to the host bundle Import-Package list:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Jahia-Depends>default,forms-core</Jahia-Depends>
                    <Import-Package>
                        org.jahia.modules.forms.taglib,
                        ${jahia.plugin.projectPackageImport},
                        *
                    </Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>