0
由於業務需求,我希望以編程方式創建aem工作流模型,並且我使用下面的代碼來實現它,但它會拋出異常,此問題已折磨一週。你能提供一些提示嗎?提前致謝。如何以編程方式在aem中創建工作流模型
代碼如下!
錯誤日誌在下面!
20.04.2016 17:35:24.054 *INFO* [JobHandler: /etc/workflow/instances/2016-04-20/model_27918689599044:/content/samplemms/2016/02/index] com.adobe.granite.workflow.core.WorkflowSessionImpl Workflow model deployed: /etc/workflow/models/sample_mms_topic_owner_175(Version: 1.0)
20.04.2016 17:35:36.015 *ERROR* [JobHandler: /etc/workflow/instances/2016-04-20/model_27918689599044:/content/samplemms/2016/02/index] com.day.cq.workflow.compatibility.CQWorkflowProcessRunner Process execution resulted in an error: null
java.lang.NullPointerException: null
at com.adobe.granite.workflow.core.model.WorkflowModelImpl.createTransition(WorkflowModelImpl.java:155)
at com.adobe.granite.workflow.core.model.WorkflowModelImpl.createTransition(WorkflowModelImpl.java:149)
at com.day.cq.workflow.impl.model.CQWorkflowModelWrapper.createTransition(CQWorkflowModelWrapper.java:145)
at com.sample.mms.workflow.TopicOwnerHandleProcessStep.execute(TopicOwnerHandleProcessStep.java:105)
at com.day.cq.workflow.compatibility.CQWorkflowProcessRunner.execute(CQWorkflowProcessRunner.java:93)
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:215)
at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:140)
at org.apache.sling.event.jobs.JobUtil$1.run(JobUtil.java:365)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
20.04.2016 17:35:36.015 *ERROR* [JobHandler: /etc/workflow/instances/2016-04-20/model_27918689599044:/content/samplemms/2016/02/index] com.adobe.granite.workflow.core.job.JobHandler Process execution resulted in an error
com.adobe.granite.workflow.WorkflowException: Process execution resulted in an error
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:225)
at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:140)
at org.apache.sling.event.jobs.JobUtil$1.run(JobUtil.java:365)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.adobe.granite.workflow.WorkflowException: Failed to execute process
at com.day.cq.workflow.compatibility.CQWorkflowProcessRunner.execute(CQWorkflowProcessRunner.java:108)
at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:215)
... 5 common frames omitted
Caused by: java.lang.NullPointerException: null
at com.adobe.granite.workflow.core.model.WorkflowModelImpl.createTransition(WorkflowModelImpl.java:155)
at com.adobe.granite.workflow.core.model.WorkflowModelImpl.createTransition(WorkflowModelImpl.java:149)
at com.day.cq.workflow.impl.model.CQWorkflowModelWrapper.createTransition(CQWorkflowModelWrapper.java:145)
at com.sample.mms.workflow.TopicOwnerHandleProcessStep.execute(TopicOwnerHandleProcessStep.java:105)
at com.day.cq.workflow.compatibility.CQWorkflowProcessRunner.execute(CQWorkflowProcessRunner.java:93)
... 6 common frames omitted
根據日誌'wm.createTransition();'拋出空指針異常,看起來這種方法是通過傳遞null和打破某處在內部調用'createTransition(WorkflowNode from,WorkflowNode to,String rule)'。令人驚訝的是[JavaDocs](https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/granite/workflow/model/WorkflowModel.html#createTransition())是沒有描述,它被稱爲「TODO」 –
你有沒有在[adobe forums]中提出過這個問題(http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience- manager.html)?不知道這個API'wm.createTransition()'的用途是什麼,你沒有指定轉換節點。 – Abhishek
感謝您的建議,我會在Adobe論壇上提出這個建議。我缺少指定問題中的過渡節點,我試過指定過渡節點並在我的項目中調用createTransition(WorkflowNode from,WorkflowNode to,String rule)方法,但它也會引發相同的異常,所以我沒有認爲這是原因。 –