Expand my Community achievements bar.

Adaptive Form - 'File Attachment' component leads to '500 error' on submit

Avatar

Level 2

Hi All,File attachment.PNG

I have a query regarding Adaptive Forms in AEM.

I have created an AF with some fields(text box, date picker, drop-down and file attachment).

I tried to submit the form without attaching any file, then it worked as per me. But when there is some file attachment it throws '500 error' as attached.

Please help me to resolve this.

Regards,

Lakshmi.

9 Replies

Avatar

Level 7

Hi experience-manager-forum

I suspect that the submit action on your form is the default (before installing forms add-on) of "Store Content"?

If that is correct:

The store content option is just for testing see the note at the top of this page, but perhaps it doesn't work with attachments.

Store content isn't recommended for production so I would suggest trying this by POSTing to a REST endpoint. I have done this successfully on AEM 6.3 forms:

Adobe Experience Manager Help | Configuring the Submit action

If my assumption isn't correct then let me know which submit action you are using

Thanks,

James

Avatar

Level 2

Hi James,

I have tried with the submit action "Submit to REST endpoint" and ends up with another error says:

1428062_pastedImage_0.png

.......26.02.2018 02:05:05.239 *ERROR* [0:0:0:0:0:0:0:1 [1519628705201] POST /content/forms/af/sample-form/jcr:content/guideContainer.af.submit.jsp HTTP/1.1] com.adobe.aemds.guide.service.impl.RESTSubmitActionService Couldn't post data to http://localhost:7002/content/joint-library/english/event-view.html

26.02.2018 02:05:05.291 *ERROR* [0:0:0:0:0:0:0:1 [1519628705201] POST /content/forms/af/sample-form/jcr:content/guideContainer.af.submit.jsp HTTP/1.1] com.adobe.aemds.guide.servlet.GuideSubmitServlet Could not complete Submit Action due to Error during form submission

com.adobe.aemds.guide.service.GuideException: Error during form submission..........

I went through the link: [AF] [AEM-Af-901-004] error , it didn't helped me much.

What all things should I fill in the AF dialog box? If there is any prerequisites , could you please suggest.

Regards,

Lakshmi.

Avatar

Level 7

Hi experience-manager-forum

An example of submit to REST endpoint below.

Create a new servlet and update the package name:

package com.<name of your package>;

import org.apache.sling.api.SlingHttpServletRequest;

import org.apache.sling.api.SlingHttpServletResponse;

import org.apache.sling.api.servlets.SlingAllMethodsServlet;

import org.osgi.service.component.annotations.Component;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import javax.servlet.Servlet;

import javax.servlet.ServletException;

import java.io.IOException;

@Component(

  service = Servlet.class,

  property = {

   "sling.servlet.paths=/bin/submitServlet",

   "sling.auth.requirements=-/bin/submitServlet"
   }

)

public class SubmitServlet extends SlingAllMethodsServlet {

  private final Logger logger = LoggerFactory.getLogger(this.getClass());

     @Override
     protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, ServletException {

       String dataXML = request.getParameter("dataXml");

        logger.info("Data submitted " + dataXML);

     }

}

Set the properties on your adaptive form container as follows, make sure Enable Post is ticked, and make sure the servlet path matches what you defined in your servlet.

Screen Shot 2018-02-26 at 22.31.07.png

Hit the submit button and you should see that the "dataXml" parameter contains your submitted form data and the "attachments" parameter contains your attached file:

Screen Shot 2018-02-26 at 22.43.44.png

Screen Shot 2018-02-26 at 22.45.07.png

If this doesn't work, do you have the aem forms add on packages installed? You should install that and it's dependencies via package share if not.

Avatar

Level 3

experience-manager-forum​ :

If you can tell the version of AEM & AEM Forms which you are using, we can help you better, I suppose.

To start with, it may be that one of the Forms Servlet might be missing/unsatisfied, due to which the call is being forwarded to default SlingPostServlet which is unable to handle the request format.

You can also post the request headers for the failing call.

Cheers,

Jagjeet Singh

AEM Forms Blog

Avatar

Level 2

Hi Jagjeeth,

I'm using AEM 6.3 version.

And my adaptive form works on the submit action "Store Content" without file attachment.

Regards,

Lakshmi.

Avatar

Level 2

Hi All,

We are also facing the same issue after upgrade from 6.1 to 6.3. Kindly let me know if you have any other solution apart from creating any service.

Thanks,

Swapna

Avatar

Employee Advisor

What is the submit action configured on the form? What is the result of submission with and without any attachment?

Please attach the error log snippet as well.

Avatar

Level 2

Hi Mayank,

Issue is fixed after installing cumulative fix (AEM-CFP-6.3.2.2-2.0.zip) and adaptive form package (adobe-aemfd-linux-pkg-4.1.50.zip) in publish instance. There is an issue while trying to hit from dispatcher which currently we are looking into.

Thanks,

Swapna

Avatar

Level 1

Was this issue resolved in dispatcher? We are having the same issue, getting [AF] [AEM-AF-901-004]: Encountered an internal error while submitting the form.