Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Exception while submitting core components based adaptive form to Rest endpoint

Avatar

Level 2

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.
 

 

3 Replies

Avatar

Employee

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

Avatar

Level 2

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 

sarikajain_0-1758182553412.png

2. No custom component. Only proxying core components.

sarikajain_1-1758182675665.png

3. No model extension or adaptation in code.

4. Servlet registration is working.

sarikajain_2-1758182830237.png

Please confirm if you need any other information. 

 

 

 

Avatar

Level 2

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.

sarikajain_0-1758182132060.png