Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM Forms watch folder through Workflow

punit-khatri
Level 2
Level 2

Hello,

I am new to AEM forms and sites.

My requirment is that read xml from a folder and copy the same file into CRX at locaiton /content/xml-files.

Hence i followed below steps

1.created a workflow which can read the file and copy to destionation folder. in this workflow, i have used process task between start and end.

2. I gave my java class name under process task. and same attached here named WatchFolderTestWW.java

3. I have configured the watched folder from AEM->tools->forms->watched folder configuraiton

4. in this confiuration, i used same workflow which i have created for execution.

5. but able to execute the java

Test Case :

1. copy one Address.xml into WatchFolderTestWW/input folder

2. document will go to failure folder with error.

WatchFolderTestWW.java

package wkint.core;

import com.adobe.aemfd.docmanager.Document;

import com.adobe.aemfd.watchfolder.service.api.ContentProcessor;

import com.adobe.aemfd.watchfolder.service.api.ProcessorContext;

import com.adobe.aemfd.watchfolder.workflow.api.WorkflowContext;

import com.adobe.aemfd.watchfolder.workflow.api.WorkflowContextProcessor;

import com.day.cq.workflow.WorkflowException;

import com.day.cq.workflow.WorkflowSession;

import com.day.cq.workflow.exec.WorkItem;

import com.day.cq.workflow.exec.WorkflowProcess;

import com.day.cq.workflow.metadata.MetaDataMap;

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

import org.osgi.framework.Constants;

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

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

import java.io.File;

import java.util.Map;

@Component(service= WorkflowProcess.class,

  property={

  Constants.SERVICE_DESCRIPTION + "=Watch Folder Test with Workflow",

  "sling.servlet.methods=" + HttpConstants.METHOD_GET,

  "sling.servlet.resourceTypes="+ "wkint/components/structure/page",

  "sling.servlet.extensions=" + "txt",

  "process.label" + "=Watch Folder Test Using Workflow"

  })

public class WatchFolderTestWW implements WorkflowProcess {

  private static final Logger log = LoggerFactory.getLogger(WatchFolderTest.class);

  @Override

  public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {

  log.info("Execute method starts");

  }

}

ERROR in error.log

21.11.2019 12:21:39.814 *ERROR* [JobHandler: /var/workflow/instances/server0/2019-11-20_1/WatchFolderAccess_8:/etc/fd/watchfolder/staging/MyWatchFolderWW/Px5c673c5c78d80ec4164368a8] com.adobe.fd.forms.internal.exception.FormsServiceException AEM_FRM_001_004:Unexpected Exception: Error creating ByteReader for given document
com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException: Error creating ByteReader for given document
at com.adobe.aemfd.pdfdocmanager.SharedPdfDocumentContext.newByteReader(SharedPdfDocumentContext.java:109) [adobe-aemds-core-pdfdocmanager:3.0.36]
at com.adobe.aemfd.pdfdocmanager.SharedPdfDocumentContext.toPDFDocument(SharedPdfDocumentContext.java:146) [adobe-aemds-core-pdfdocmanager:3.0.36]
at com.adobe.aemfd.pdfdocmanager.SharedPdfDocumentContext.toPDFDocument(SharedPdfDocumentContext.java:126) [adobe-aemds-core-pdfdocmanager:3.0.36]
at com.adobe.fd.forms.internal.utils.Utils.createPDFDocument(Utils.java:138) [com.adobe.livecycle.adobe-lc-forms-bedrock-connector:8.0.74]
at com.adobe.fd.forms.internal.ImportDataService.importData(ImportDataService.java:52) [com.adobe.livecycle.adobe-lc-forms-bedrock-connector:8.0.74]
at com.adobe.fd.forms.impl.FormsServiceImpl.importData(FormsServiceImpl.java:196) [com.adobe.livecycle.adobe-lc-forms-bedrock-connector:8.0.74]
at com.adobe.fd.workflow.forms.impl.ImportData.internal_execute(ImportData.java:84) [com.adobe.aemfd.adobe-aemfd-workflow-process:5.0.70]
at com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess$1.call(AEMFDWorkflowProcess.java:71) [com.adobe.aemfd.adobe-aemfd-workflow-process:5.0.70]
at com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess$1.call(AEMFDWorkflowProcess.java:68) [com.adobe.aemfd.adobe-aemfd-workflow-process:5.0.70]
at com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl.callWith(ResourceResolverHelperImpl.java:65) [com.adobe.granite.resourceresolverhelper:1.0.4]
at com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess.execute(AEMFDWorkflowProcess.java:68) [com.adobe.aemfd.adobe-aemfd-workflow-process:5.0.70]
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:195) [com.adobe.granite.workflow.core:2.0.240]
at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:260) [com.adobe.granite.workflow.core:2.0.240]
at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:502) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:293) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:60) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:229) [org.apache.sling.event:4.2.12]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.MalformedURLException: For input string: "\Punit\Adobe Experience Manager\MyWatchFolder\input\Address.pdf"
at java.net.URL.<init>(Unknown Source)
at com.adobe.aemds.datamanager.impl.UrlUtil.toURL(UrlUtil.java:91) [adobe-aemds-core-bmc:3.0.36]
at com.adobe.aemds.bedrock.internal.Utilities.toURL(Utilities.java:202) [adobe-aemds-core-bmc:3.0.36]
at com.adobe.aemfd.docmanager.internal.passivation.jcr.JcrURLPassivationHandler.getURL(JcrURLPassivationHandler.java:38) [adobe-aemds-core-docmanager:3.0.36]
at com.adobe.aemfd.docmanager.internal.passivation.url.AbstractURLPassivationHandler.openConnectionForPassivation(AbstractURLPassivationHandler.java:70) [adobe-aemds-core-docmanager:3.0.36]
at com.adobe.aemfd.docmanager.Document.doPassivate(Document.java:241) [adobe-aemds-core-docmanager:3.0.36]
at com.adobe.aemfd.docmanager.Document.passivate(Document.java:320) [adobe-aemds-core-docmanager:3.0.36]
at com.adobe.aemfd.docmanager.Document.getInlineData(Document.java:345) [adobe-aemds-core-docmanager:3.0.36]
at com.adobe.aemfd.pdfdocmanager.SharedPdfDocumentContext.newByteReader(SharedPdfDocumentContext.java:62) [adobe-aemds-core-pdfdocmanager:3.0.36]
... 19 common frames omitted
Caused by: java.lang.NumberFormatException: For input string: "\Punit\Adobe Experience Manager\MyWatchFolder\input\Address.pdf"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.net.URLStreamHandler.parseURL(Unknown Source)
... 28 common frames omitted
21.11.2019 12:21:39.814 *ERROR* [JobHandler: /var/workflow/instances/server0/2019-11-20_1/WatchFolderAccess_8:/etc/fd/watchfolder/staging/MyWatchFolderWW/Px5c673c5c78d80ec4164368a8] com.adobe.granite.workflow.core.job.JobHandler Error executing workflow step
com.adobe.granite.workflow.WorkflowException: Process execution resulted in an error
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:201) [com.adobe.granite.workflow.core:2.0.240]
at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:260) [com.adobe.granite.workflow.core:2.0.240]
at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:502) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:293) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:60) [org.apache.sling.event:4.2.12]
at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:229) [org.apache.sling.event:4.2.12]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.adobe.granite.workflow.WorkflowException: Exception while importing data
at com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess.execute(AEMFDWorkflowProcess.java:81) [com.adobe.aemfd.adobe-aemfd-workflow-process:5.0.70]
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:195) [com.adobe.granite.workflow.core:2.0.240]
... 8 common frames omitted

0 Replies