8 Replies Latest reply on Dec 7, 2018 2:26 AM by James R Green

    AEM Forms 6.3 - Serverside validation failure

    James R Green Level 3

      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.j ava: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.ja va:149)

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

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

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

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

        at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilter Chain.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.j ava: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.ja va:149)

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

       

       

       

       

      Thanks,

      Jim

       

       

        • 1. Re: AEM Forms 6.3 - Serverside validation failure
          James R Green Level 3

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

          • 2. Re: AEM Forms 6.3 - Serverside validation failure
            James R Green Level 3

            Just found this which might help, I will try it out tomorrow:

             

            Debugging Server Side JavaScript

            • 3. Re: AEM Forms 6.3 - Serverside validation failure
              smacdonald2008 Adobe Employee

              Let us know if that works.

              • 4. Re: AEM Forms 6.3 - Serverside validation failure
                James R Green Level 3

                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/se lect

                 

                 

                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:

                 

                 

                <c:set var="guideClientLibRef" value="${guideContainer.clientLibRef}" />

                <%-- This ensures that all customer templates with height:100% set at body tag

                  works OOTB in touch. This is done since there is height calculation at iframe tag in touch. Refer to CQ-70350 for more info --%>

                ....

                        <%--- Including the js present in the client library mentioned in the guide container dialog  --%>

                        <%--- Please Note: Only the js is included, we dont include the css present in the client library  --%>

                        <%--- Do not load the JS again as only form tag is being replaced for AJAX call (target mode) --%>

                        <c:if test="${!targetMode}">

                            <c:if test="${not empty guideClientLibRef}">

                                <cq:includeClientLib js="${guideClientLibRef}"/>

                            </c:if>

                            <c:if test="${hasXDP}">

                                <cq:includeClientLib categories="guideRuntimeWithXFA"/>

                            </c:if>

                            <c:if test="${not hasXDP}">

                                <cq:includeClientLib categories="guideRuntime"/>

                            </c:if>

                            <cq:includeClientLib categories="af.customwidgets"/>

                        </c:if>

                 

                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

                • 5. Re: AEM Forms 6.3 - Serverside validation failure
                  smacdonald2008 Adobe Employee

                  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.

                  • 6. Re: AEM Forms 6.3 - Serverside validation failure
                    smacdonald2008 Adobe Employee

                    I also asked the Form team to look here.

                    • 7. Re: AEM Forms 6.3 - Serverside validation failure
                      James R Green Level 3

                      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

                      • 8. Re: AEM Forms 6.3 - Serverside validation failure
                        James R Green Level 3

                        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