ClassCast Exception during PDF processing

Issue

While using components like Assembler or Reader Extension in AEM Forms, processing of certain PDFs fail with the below exception in server logs whereas the same PDFs work fine till LiveCycle ES4.

java.lang.ClassCastException: com.adobe.xfa.TextNode cannot be cast to com.adobe.xfa.Element
	at com.adobe.xfa.Delta.restore(Delta.java:241)
	at com.adobe.xfa.form.FormField.getDeltas(FormField.java:398)
	at com.adobe.xfa.Element.getDeltas(Element.java:2366)
	at com.adobe.xfa.form.FormSubform.getDeltas(FormSubform.java:91)
	at com.adobe.xfa.Element.getDeltas(Element.java:2366)
	at com.adobe.xfa.form.FormSubform.getDeltas(FormSubform.java:91)
	at com.adobe.xfa.Element.getDeltas(Element.java:2366)
	at com.adobe.xfa.form.FormSubform.getDeltas(FormSubform.java:91)
	at com.adobe.xfa.Element.getDeltas(Element.java:2366)
	at com.adobe.xfa.form.FormSubform.getDeltas(FormSubform.java:91)
	at com.adobe.xfa.form.FormModel.merge(FormModel.java:6021)
	at com.adobe.xfa.form.FormModel.merge(FormModel.java:5901)
	at com.adobe.xfa.form.FormModel.merge(FormModel.java:5863)
	at com.adobe.internal.pdftoolkit.services.xfa.form.DocumentContext.doMerge(DocumentContext.java:1049)
	at com.adobe.internal.pdftoolkit.services.xfa.form.DocumentContext.postLoad(DocumentContext.java:2290)
	at com.adobe.internal.pdftoolkit.services.xfa.form.XFAPlugin.loadXFA(XFAPlugin.java:110)
	at com.adobe.internal.pdftoolkit.services.xfa.form.XFAPlugin.processXFA(XFAPlugin.java:246)
	at com.adobe.internal.pdftoolkit.services.xfa.XFADOMService.createXFADocumentContext(XFADOMService.java:275)
	at com.adobe.internal.pdftoolkit.services.xfa.XFADOMService.getXFADOM(XFADOMService.java:131)
	at com.adobe.internal.pdftoolkit.services.xfa.XFADOMService.getXFADOM(XFADOMService.java:179)
	at com.adobe.internal.pdftoolkit.services.xfa.XFADOMService.getXFADOM(XFADOMService.java:218)

Environment

AEM Forms

Cause

These exceptions are seen in newer versions of AEM forms, in which, certain new features that require processing have been enabled. The exceptions are seen when all of the following scenarios occur:

  • You use dynamic/static PDFs generated from an XDP.
  • In the XDP, at least one text field is assigned no default value, that is, it contains an empty <value> tag or an empty <exData> tag, which is contained in the <value> tag.
  • During PDF rendition/processing, the empty <value> tag found in step 2 is replaced with a rich text value. 

Resolution

  1. Open your XDP in AEM Forms Designer.

  2. Switch to XML source view and search for blank <value> tag or <exData> tag contained in a text field tag.

  3. If you find any such empty tag, switch back to the Design View and assign a space as the default value in the text field properties.

  4. Repeat step 3 for every text field identified in step 2.

  5. Save the XDP file.