Expand my Community achievements bar.

SOLVED

Adaptive form throwing error on trying to edit the form

Avatar

Level 2

Hi Community,

 

I new to Adaptive forms. We have a requirement to create Adaptive forms on AEM 6.5.21. 

 

We have both custom template and form ready on local AEM 6.5.21, but on installing it on higher env, we can this error:

SmrithiGo_0-1739787227924.png

Errorlog:

org.apache.sling.scripting.sightly.SightlyException: Identifier body.js cannot be correctly instantiated by the Use API
at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:76) [org.apache.sling.scripting.sightly:1.4.22.140]
at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:72) [org.apache.sling.scripting.sightly:1.4.22.140]
at org.apache.sling.scripting.sightly.libs.fd.af.components.page2.aftemplatedpage.afpagecontent__002e__html.render(afpagecontent__002e__html.java:89)
at org.apache.sling.scripting.sightly.render.RenderUnit.render(RenderUnit.java:53) [org.apache.sling.scripting.sightly.runtime:1.2.6.140]
at org.apache.sling.scripting.sightly.impl.engine.SightlyCompiledScript.eval(SightlyCompiledScript.java:61) [org.apache.sling.scripting.sightly:1.4.22.140]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:393) [org.apache.sling.scripting.core:2.4.8]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:191) [org.apache.sling.scripting.core:2.4.8]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:500) [org.apache.sling.scripting.core:2.4.8]
at com.day.cq.wcm.tags.IncludeTag.includeScript(IncludeTag.java:178) [com.day.cq.wcm.cq-wcm-taglib:5.13.8]
at com.day.cq.wcm.tags.IncludeTag.doEndTag(IncludeTag.java:95) [com.day.cq.wcm.cq-wcm-taglib:5.13.8]
at org.apache.jsp.libs.fd.af.components.page2.aftemplatedpage.aftemplatedpage__002e__jsp._jspx_meth_cq_include_2(aftemplatedpage__002e__jsp.java:512)
at org.apache.jsp.libs.fd.af.components.page2.aftemplatedpage.aftemplatedpage__002e__jsp._jspService(aftemplatedpage__002e__jsp.java:408)
at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) [org.apache.sling.scripting.jsp:2.6.0]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) [org.apache.felix.http.servlet-api:1.2.0]
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:521) [org.apache.sling.scripting.jsp:2.6.0]
at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:464) [org.apache.sling.scripting.jsp:2.6.0]
at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.callJsp(JspScriptEngineFactory.java:500) [org.apache.sling.scripting.jsp:2.6.0]
at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:582) [org.apache.sling.scripting.jsp:2.6.0]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:395) [org.apache.sling.scripting.core:2.4.8]
at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:191) [org.apache.sling.scripting.core:2.4.8]

 

........

Caused by: org.apache.sling.scripting.sightly.SightlyException: Unable to load script dependency body.js.
at org.apache.sling.scripting.sightly.js.impl.use.DependencyResolver.resolve(DependencyResolver.java:108) [org.apache.sling.scripting.sightly.js.provider:1.2.8]
at org.apache.sling.scripting.sightly.js.impl.JsUseProvider.provide(JsUseProvider.java:95) [org.apache.sling.scripting.sightly.js.provider:1.2.8]
at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:71) [org.apache.sling.scripting.sightly:1.4.22.140]
... 202 common frames omitted

.......

 

We can see the same error on both our higher environments. Trying to figure out if there is anything missing from our end. Appreciate any assistance.

 

Thank you.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 1

HI @Pranay_M ,

 

Thanks for sharing the information.

The issue was because of two config files:

1. org.apache.sling.servlets.resolver.SlingServletResolver.config

2. org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.config

 

We had overridden these files for business requirements, but it was preventing from Adaptive forms to be opened properly.

On removing these two files, and recreating the instances, it is working fine now.

 

As a workaround, we are directly applying the config changes in /configMgr.

 

Regards

View solution in original post

6 Replies

Avatar

Employee

Hi @SmrithiGo,

The error you're encountering with Adaptive Forms in AEM 6.5.21 seems to be related to a Sightly (HTL) issue where a JavaScript file, specifically body.js, cannot be loaded or instantiated by the Use API. This is a common issue when migrating or deploying AEM projects across different environments. 

The error Identifier body.js cannot be correctly instantiated by the Use API indicates that the HTL script is trying to use a JavaScript file that it cannot find or load properly. The org.apache.sling.scripting.sightly.js.impl.use.DependencyResolver.resolve line in the stack trace shows that the system is attempting to resolve the JavaScript file but fails.

To resolve the issue, e
nsure that the body.js file is located in the correct directory within your AEM project structure. Typically, these files should be located in the /apps or /libs directory, depending on your project setup. Also verify that the body.js file is included in your deployment package (e.g., a content package or JAR). Sometimes, files might be missing from the package due to incorrect build configurations. Finally, please make sure that the necessary permissions are set for accessing the JavaScript file in the higher environments. Sometimes, permission issues can prevent scripts from being loaded.

Thanks
Pranay

Avatar

Level 2

Hi @Pranay_M ,

 

We have used the local AEM 6.5.21 for creating the adaptive forms and custom adaptive form template, but we have not made any changes in body.js

 

Also the higher envs are using the same version which is 6.5.21. Could you please let me know where the body.js is located.

 

Regarding the permission, we are using admin on higher envs for creating the adaptive forms. Thank you.

 

Regards,

Smrithi

Avatar

Level 2

I can see that, when I create a custom template, there is an error:

 

SmrithiGo_0-1739788586945.png

I am not sure why there is an error when creating a custom template on all the instances.

Avatar

Level 1

I have identified the issue, posting the root cause:

 

I could see that, the Adaptive form template is loading fine on plain vanilla instance 6.5.21, but once the custom maven project is deployed, its breaking.

 

I could see that /apps/<project>/osgiconfig/config/org.apache.sling.servlets.resolver.SlingServletResolver.xml, is causing the problem, as soon as I delete this file, the AF templates are loading fine.

 

Thank you. 

 

Avatar

Employee

Hi @SmrithiG1,

Just to provide you with additional content, The SlingServletResolver configuration file may be overriding or conflicting with existing configurations in AEM. This could be due to properties defined in your configuration that do not align with what the Adaptive Form templates expect.

 

Please ensure that the properties configured in SlingServletResolver.xml are correct and do not inadvertently disable or override necessary servlet paths or resource types needed by Adaptive Forms and also check if the XML is inadvertently affecting the servlet resolution paths or namespaces that Adaptive Forms rely on. It might be causing the resolution to fail for certain paths.

https://sling.apache.org/documentation/the-sling-engine/servlets.html

 

Thanks
Pranay

Avatar

Correct answer by
Level 1

HI @Pranay_M ,

 

Thanks for sharing the information.

The issue was because of two config files:

1. org.apache.sling.servlets.resolver.SlingServletResolver.config

2. org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.config

 

We had overridden these files for business requirements, but it was preventing from Adaptive forms to be opened properly.

On removing these two files, and recreating the instances, it is working fine now.

 

As a workaround, we are directly applying the config changes in /configMgr.

 

Regards