Exception while submitting core components based adaptive form to Rest endpoint | Community
Skip to main content
Level 2
September 18, 2025
Solved

Exception while submitting core components based adaptive form to Rest endpoint

  • September 18, 2025
  • 2 replies
  • 1399 views

Hi,

 

I created a sample AEM Forms project using archetype 54 and core components dependency. 

I am submitting form data to locally deployed servlet using 'Submit to Rest Endpoint' option.

The form submission is failing with internal server error and I can see the exception like below in the log(I added separate logger for 'com.adobe' and 'org.sling'). From the exception, it looks like issue with Model class initialization.

 

18.09.2025 12:22:11.956 *DEBUG* [qtp1218449186-2121] org.apache.sling.adapter.internal.AdapterManagerImpl Trying adapter factory org.apache.sling.models.impl.ModelAdapterFactory@7c3093ff to map JcrNodeResource, type=myform/components/adaptiveForm/textinput, superType=null, path=/content/forms/af/myform/training-form-fragment/jcr:content/guideContainer/textinput to interface com.adobe.cq.export.json.ComponentExporter
18.09.2025 12:22:11.956 *DEBUG* [qtp1218449186-2121] org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceFactory createResource: Found JCR Node Resource at path '/apps/myform/components/adaptiveForm/textinput'
18.09.2025 12:22:11.956 *DEBUG* [qtp1218449186-2121] org.apache.sling.models.impl.ModelAdapterFactory Using implementation type org.apache.sling.models.impl.model.ModelClass@11345461 for requested adapter type interface com.adobe.cq.export.json.ComponentExporter
18.09.2025 12:22:11.958 *DEBUG* [qtp1218449186-2121] org.apache.sling.adapter.internal.AdapterManagerImpl No adapter factory found to map JcrNodeResource, type=myform/components/adaptiveForm/textinput, superType=null, path=/content/forms/af/myform/training-form-fragment/jcr:content/guideContainer/textinput to interface org.apache.sling.api.SlingHttpServletRequest
18.09.2025 12:22:11.958 *DEBUG* [qtp1218449186-2121] org.apache.sling.models.impl.ModelAdapterFactory Injection into optional element protected org.apache.sling.api.SlingHttpServletRequest com.adobe.cq.forms.core.components.util.AbstractComponentImpl.request failed because of: Could not adapt from class org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource to interface org.apache.sling.api.SlingHttpServletRequest
org.apache.sling.models.factory.ModelClassException: Could not adapt from class org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource to interface org.apache.sling.api.SlingHttpServletRequest
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1064) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.adaptIfNecessary(ModelAdapterFactory.java:1034) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.setField(ModelAdapterFactory.java:977) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.access$200(ModelAdapterFactory.java:115) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory$SetFieldCallback.inject(ModelAdapterFactory.java:475) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:575) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:733) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:428) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.getAdapter(ModelAdapterFactory.java:270) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.adapter.internal.AdapterManagerImpl.getAdapter(AdapterManagerImpl.java:143) [org.apache.sling.adapter:2.1.10]
at org.apache.sling.api.adapter.SlingAdaptable.adaptTo(SlingAdaptable.java:104) [org.apache.sling.api:2.27.2]
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource.adaptTo(JcrNodeResource.java:156) [org.apache.sling.jcr.resource:3.0.18]
at com.adobe.cq.forms.core.components.util.AbstractContainerImpl.getChildrenModels(AbstractContainerImpl.java:151) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.cq.forms.core.components.internal.models.v1.form.FragmentImpl.getChildrenModels(FragmentImpl.java:116) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.cq.forms.core.components.util.AbstractContainerImpl.getItems(AbstractContainerImpl.java:117) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.cq.forms.core.components.internal.models.v2.form.FormContainerImpl.traverseChild(FormContainerImpl.java:399) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.cq.forms.core.components.internal.models.v2.form.FormContainerImpl.traverseChild(FormContainerImpl.java:403) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.cq.forms.core.components.internal.models.v2.form.FormContainerImpl.traverseChild(FormContainerImpl.java:403) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.cq.forms.core.components.internal.models.v2.form.FormContainerImpl.visit(FormContainerImpl.java:395) [com.adobe.aem.core-forms-components-af-core:1.1.66]
at com.adobe.aem.forms.af.rest.fdinternal.FormDataUpdater.getAllTermsAndConditions(FormDataUpdater.java:79) [com.adobe.aem.com.adobe.aem.forms.af.rest:0.0.118]
at com.adobe.aem.forms.af.rest.fdinternal.FormDataUpdater.updateWithTermsAndConditions(FormDataUpdater.java:49) [com.adobe.aem.com.adobe.aem.forms.af.rest:0.0.118]
at com.adobe.aem.forms.af.rest.internal.servlets.AdaptiveFormSubmitServlet.createFormSubmitInfoFromRequest(AdaptiveFormSubmitServlet.java:379) [com.adobe.aem.com.adobe.aem.forms.af.rest:0.0.118]
at com.adobe.aem.forms.af.rest.internal.servlets.AdaptiveFormSubmitServlet.doPost(AdaptiveFormSubmitServlet.java:209) [com.adobe.aem.com.adobe.aem.forms.af.rest:0.0.118]
AEM Server version - 6.5.22
AF Core Components version - 1.1.66
FT - FT_FORMS-2494, FT_FORMS-12407
I am attaching the servlet code, templates, sample form and logs.
 

 

Best answer by Pranay_M

Hi @sarikajain,

 

Please use the command below to create the project. Also as you mentioned that you are using Archetype 45, I would request you use the latest one.

 

Command: mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.3.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=54 -D appTitle="MyForm" -D appId="myform" -D groupId="com.myform" -D includeFormsenrollment="y" -D aemVersion="6.5.22"

Thanks
Pranay

2 replies

Adobe Employee
September 18, 2025

Hi @sarikajain,

 

I’ve analyzed the error logs from the failed AEM Forms submission. The failure occurs because the Sling Models used by the Forms Core Components expect a SlingHttpServletRequest, but the runtime is attempting to adapt from a JcrNodeResource. Since JcrNodeResource cannot be adapted to SlingHttpServletRequest, the model initialization fails and causes the internal server error.

Key technical points:

  1. Forms Core Components dependency

    • Confirm that the version of com.adobe.aem.core-forms-components-af-core (currently 1.1.66 per logs) matches your AEM SDK version. Version mismatches can lead to adaptation issues.

  2. Custom component inheritance

    • Ensure all components under /apps/myform/components/adaptiveForm/... declare the correct sling:resourceSuperType.

    • For example:

       
      <sling:resourceSuperType="fd/af/components/guideTextBox"/>
    • Without the proper supertype, AEM will adapt directly from a node resource, bypassing the request binding.

  3. Model adaptation in code

    • When instantiating models, use: request.adaptTo(MyModel.class); instead of adapting from the resource: resource.adaptTo(MyModel.class);

    • This ensures the request context is available for injection.

  4. Servlet registration

    • Verify that your servlet handling the form submission is correctly mapped using @SlingServletPaths or @SlingServletResourceTypes.

    • If the servlet is not matched, AEM will route to the default AdaptiveFormSubmitServlet, which traverses component models and triggers the adaptation error.

Next steps:

  • Align the Forms Core Components dependency with your SDK version.

  • Update custom components to inherit from the appropriate OOTB Forms Core Components.

  • Review servlet mappings to ensure the request is routed to your custom servlet.

This should resolve the Sling Model initialization errors and enable successful submissions.
Thanks

Level 2
September 18, 2025

Thanks for prompt reply Pranay.

Please find below check outcomes -

1. Forms Core Components dependency - 

Forms SDK version 6.0.1328

Core Components version 1.1.66

matches as per core component documentation 

2. No custom component. Only proxying core components.

3. No model extension or adaptation in code.

4. Servlet registration is working.

Please confirm if you need any other information. 

 

 

 

Level 2
September 18, 2025

Site is not letting me add templates and sample forms. I was using the OOTB templates that are generated from archetype project.

Archetype version is 45 not 54 as mentioned earlier.

mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=45 -D appTitle="My Form" -D appId="myform" -D groupId="com.myform" -D includeFormsenrollment="y" -D aemVersion="6.5.22"

It is a simple form with one form fragment containing two input fields.

 

Pranay_MAdobe EmployeeAccepted solution
Adobe Employee
September 22, 2025

Hi @sarikajain,

 

Please use the command below to create the project. Also as you mentioned that you are using Archetype 45, I would request you use the latest one.

 

Command: mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.3.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=54 -D appTitle="MyForm" -D appId="myform" -D groupId="com.myform" -D includeFormsenrollment="y" -D aemVersion="6.5.22"

Thanks
Pranay

sudhansh
Adobe Employee
Adobe Employee
September 24, 2025

@sarikajain Please confirm if the issue is resolved for you with the steps proposed above.