0

我使用AEM 6.1withMaven作为构建管理器。我已经使用 Adob​​e 提供的未混淆的内容更新了 .m2 本地文件夹UberJar。我收到以下错误:

错误[JobHandler: /etc/workflow/instances/server0/2016-07-15/model_157685507700064:/content/myApp/testing/wf_test01] com.adobe.granite.workflow.core.job.JobHandler 找不到进程实现:com.myApp .workflow.ActivatemyAppPageProcess com.adobe.granite.workflow.WorkflowException:找不到流程实现:com.myApp.workflow.ActivatemyAppPageProcess 在 com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:197) 在com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:232) 在 org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:512) 在 org. apache.sling.event.impl.jobs.queues.JobRunner.run(JobRunner.java:205) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 在 java.util。concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 在 java.lang.Thread.run(Thread.java:745)

UberJar好像没有包com.adobe.granite.workflow.core.job。有没有办法解决这个问题?

.execute工艺步骤的方法ActivatemyAppPageProcess

public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException {
    Session participantSession = null;
    Session replicationSession = null;
    // ResourceResolver resourceResolver = null;
    try {
        log.info("Inside ActivatemyAppPageProcess ");
        Session session = workflowSession.getSession();
        if (replicateAsParticipant(args)) {
            String approverId = resolveParticipantId(workItem, workflowSession);
            if (approverId != null) {
                participantSession = getParticipantSession(approverId, workflowSession);
            }
        }
        if (participantSession != null)
            replicationSession = participantSession;
        else {
            replicationSession = session;
        }

        WorkflowData data = workItem.getWorkflowData();
        String path = null;
        String type = data.getPayloadType();
        if ((type.equals("JCR_PATH")) && (data.getPayload() != null)) {
            String payloadData = (String) data.getPayload();
            if (session.itemExists(payloadData))
                path = payloadData;
            }
            else if ((data.getPayload() != null) && (type.equals("JCR_UUID"))) {
                Node node = session.getNodeByUUID((String) data.getPayload());
                path = node.getPath();
            }
            ReplicationOptions opts = null;
            String rev = (String) data.getMetaDataMap().get("resourceVersion", String.class);
            if (rev != null) {
                opts = new ReplicationOptions();
                opts.setRevision(rev);
            }
            opts = prepareOptions(opts);

            if (path != null) {
                ResourceCollection rcCollection = 
                    ResourceCollectionUtil
                        .getResourceCollection(
                            (Node) this.admin.getItem(path), 
                                (ResourceCollectionManager) this.rcManager);
                boolean isWFPackage = isWorkflowPackage(path, resolverFactory, workflowSession);
                List<String> paths = getPaths(path, rcCollection);
                for (String aPath : paths)
                    if (canReplicate(replicationSession, aPath)) {
                        if (opts != null) {
                            if (isWFPackage) {
                                setRevisionForPage(aPath, opts, data);
                            }
                            this.replicator
                                    .replicate(replicationSession, 
                                                   getReplicationType(),
                                                       aPath,
                                                           opts);
                            } else {
                                this.replicator
                                        .replicate(replicationSession, 
                                                       getReplicationType(),
                                                           aPath);
                        }
                    } else {
                        log.debug(session.getUserID() + " is not allowed to replicate " + "this page/asset " + aPath + ". Issuing request for 'replication");

                        Dictionary properties = new Hashtable();
                        properties.put("path", aPath);
                        properties.put("replicationType", getReplicationType());
                        properties.put("userId", session.getUserID());
                        Event event = new Event("com/day/cq/wcm/workflow/req/for/activation", properties);
                        this.eventAdmin.sendEvent(event);
                    }
            } else {
                log.warn("Cannot activate page or asset because path is null for this workitem: " + workItem.toString());
            }
        } catch (RepositoryException e) {
            throw new WorkflowException(e);
        } catch (ReplicationException e) {
            throw new WorkflowException(e);
        } finally {
            if ((participantSession != null) && (participantSession.isLive())) {
                participantSession.logout();
                participantSession = null;
            }
        }
    }
4

2 回答 2

2

com.adobe.granite.workflow.core.job根本不会在 AEM 中导出。这意味着,您不能使用它,因为它对您的代码不可见。

com.adobe.granite.workflow.core捆绑包仅导出com.adobe.granite.workflow.core.event. 如果您使用 AEM 工作流程,您应该坚持使用com.adobe.granite.workflow.api捆绑包。

以下包在此捆绑包中导出,因此可用:

com.adobe.granite.workflow,version=1.0.0
com.adobe.granite.workflow.collection,version=1.1.0
com.adobe.granite.workflow.collection.util,version=1.0.0
com.adobe.granite.workflow.event,version=1.0.0
com.adobe.granite.workflow.exec,version=1.0.0
com.adobe.granite.workflow.exec.filter,version=1.0.0
com.adobe.granite.workflow.job,version=1.0.0
com.adobe.granite.workflow.launcher,version=1.0.0
com.adobe.granite.workflow.metadata,version=1.0.0
com.adobe.granite.workflow.model,version=1.0.0
com.adobe.granite.workflow.rule,version=1.0.0
com.adobe.granite.workflow.serialization,version=1.0.0
com.adobe.granite.workflow.status,version=1.0.0

即使uber.jar有包,如果您查看您的 AEM 实例/system/console/bundles并单击com.adobe.granite.workflow.core包,您将看到在“导出的包”中没有com.adobe.granite.workflow.core.job可用的包。因此,即使您的 IDE、Maven 和/或 Jenkins 可以处理它,AEM 也无法执行您的代码。

在 AEM 中,您只能使用在可用捆绑包之一中导出或包含在捆绑包中的包 - 这将是一个坏主意。然后,您将拥有相同代码的两个版本,这将导致进一步的问题。

看过代码后,我会说这里还有另一个问题。解决这个问题也将帮助您摆脱另一个问题。

您尝试为已在工作流中使用的路径启动另一个 WF(激活请求)。您必须终止当前工作流实例才能执行此操作。

一个干净的方法的例子是:

Workflow workflow = workItem.getWorkflow();
WorkflowData wfData = workflow.getWorkflowData();
workflowSession.terminateWorkflow(workflow);
Map<String, Object> paramMap = new HashMap<String, Object>();
if (!StringUtils.isEmpty(data.getNextParticipantUid())) {
    paramMap.put("nextParticipant", "admin");
}
workflowSession.startWorkflow(
    workflowSession.getModel(WORKFLOW_MODEL_PATH, wfData, paramMap);
于 2016-07-18T15:27:15.463 回答
0

错误的可能原因可能是您的工作流流程com.myApp.workflow.ActivatemyAppPageProcess服务/组件未处于活动状态,因为它未绑定到 JobHandler 的可用流程列表,从而导致此异常。

您可以检查/system/console/components您的自定义流程组件是否处于活动状态?如果没有,那么您将不得不解决导致服务/组件不可用的依赖关系。

于 2016-07-18T19:58:42.523 回答