Expand my Community achievements bar.

AEM Forms 6.3 - Serverside validation failure

Avatar

Level 7

Hi,

I am using the revalidate on server functionality on my form.

The JS I am using on the frontend passes validation and submits, but the serverside revalidation fails.

This is happening on my publish instance running locally.

I can see from the log below that the error is in GuideSubmitServlet, but I cannot get any more information about what is failing, I assume there is something that the GuideSubmitServlet doesn't like in my JS (?).

* Is there anyway to debug this further/ get extra information about what exactly failed e.g. increasing the log level (if so which setting would help with this?)?

* How can I trouble shoot this without the GuideSubmitServlet code?

==> error.log <==

04.12.2018 16:16:35.589 *ERROR* [0:0:0:0:0:0:0:1 [1543940194735] POST   <FORM_NAME>/jcr:content/guideContainer.af.submit.jsp HTTP/1.1] com.adobe.aemds.guide.servlet.GuideSubmitServlet Could not complete Submit Action due to Server validation failed.

com.adobe.aemds.guide.service.GuideException: Server validation failed.

  at com.adobe.aemds.guide.servlet.GuideSubmitServlet.doPostPrerequisites(GuideSubmitServlet.java:192)

  at com.adobe.aemds.guide.servlet.GuideSubmitServlet.doSubmit(GuideSubmitServlet.java:313)

  at com.adobe.aemds.guide.servlet.GuideSubmitServlet.doPost(GuideSubmitServlet.java:561)

  at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:149)

  at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:346)

  at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:378)

  at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:552)

  at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44)

  at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)

04.12.2018 16:16:35.591 *ERROR* [0:0:0:0:0:0:0:1 [1543940194735] POST <FORM_NAME>/jcr:content/guideContainer.af.submit.jsp HTTP/1.1] com.adobe.aemds.guide.servlet.GuideSubmitServlet Exception in post request. Server validation failed.

com.adobe.aemds.guide.service.GuideException: Server validation failed.

  at com.adobe.aemds.guide.servlet.GuideSubmitServlet.doPostPrerequisites(GuideSubmitServlet.java:274)

  at com.adobe.aemds.guide.servlet.GuideSubmitServlet.doSubmit(GuideSubmitServlet.java:313)

  at com.adobe.aemds.guide.servlet.GuideSubmitServlet.doPost(GuideSubmitServlet.java:561)

  at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:149)

  at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:346)

Thanks,

Jim

9 Replies

Avatar

Level 7

Also note that there appears to be no guideError or guideErrorList passed back on the request.

Avatar

Level 7

Hi,

I will start with my questions as there is a lot of information below.

Questions:

1) Is it possible to re-validate on the server when the validation routine uses the guideBridge?

If so:

2) Is af.customwidgets included in the JS scripts used for server side validation?

3) Is guideRuntime included in the JS scripts used for server side validation?

4) Please can some documentation for the backend validation be made public (or preferably the code)? I might have to re-implement this otherwise which will be a huge task. It is a complete blackbox and I don't think security through obscurity is the way to go.

Reason for the questions:

It does produce more information in the log with that setting.

One of the errors is:

05.12.2018 14:31:51.303 *ERROR* [0:0:0:0:0:0:0:1 [1544020308973] POST /content/forms/af/<FORM_NAME>/jcr:content/guideContainer.af.submit.jsp HTTP/1.1] com.adobe.aemds.guide.internal.impl.utils.RulesCompiler Error compiling scripts for /content/forms/af/fragments/industry-sector/jcr:content/guideContainer/rootPanel/items/select

java.lang.ClassCastException: org.mozilla.javascript.UniqueTag cannot be cast to org.mozilla.javascript.ScriptableObject

  at com.adobe.aemds.guide.internal.impl.utils.RulesCompiler$1.call(RulesCompiler.java:71)

  at com.adobe.aemds.guide.internal.impl.utils.RulesCompiler$1.call(RulesCompiler.java:68)

These rules work in the browser.

I have been testing the front end validation by including my code in the "af.customwidgets" clientlib.

The reason for using this clientlibrary is I want the code to load after the guideRuntime and other OOTB forms related libraries so I can use the guidebridge.

If I add the client lib to the form using the "Client Library Category" on the form container (clientlibref), I can see from

/libs/fd/af/components/guideContainer/guideContainer.jsp that it will be added before guideRuntime:

This is no good for my validation routine as it uses the guideBridge to vary the validation rules depending on the form I am on e.g.

guideBridge.on("bridgeInitializeComplete", function (event, payload) {

  const gb = payload.target;

   gb.connect(function () {

   switch (gb.getGuidePath()) {

   case '<form-path-to-override>':

          myForms.formValidation  = new ValidationOverride();

   break;

  }

  

  });

});

Thanks,

Jim

Avatar

Level 10

James - seems to be a lot of questions on guideBridge. Do you find the docs weak here. Do they need to be improved in yoru view. Also -- do you think an Ask the AEM Commuity Experts session on this will help.

Avatar

Level 7

smacdonald2008

Guidebridge documentation is actually really good and works just fine on the front end. The documentation for the server side re-validation on the other hand is something I haven't been able to find

Avatar

Level 7

Hi,

FYI I have re-implemented the revalidation of the JS in my own service instead so that we can debug it.

I think that the documentation would be useful for others looking to use the server side validation feature, it is too much of a black box at the moment.

Thanks,

Jim