AEM 6.1 Uber Jar Maven 依赖项

AEM 6.1 Uber Jar Maven Dependency

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

ERROR [JobHandler: /etc/workflow/instances/server0/2016-07-15/model_157685507700064:/content/myApp/testing/wf_test01] com.adobe.granite.workflow.core.job.JobHandler Process implementation not found: com.myApp.workflow.ActivatemyAppPageProcess com.adobe.granite.workflow.WorkflowException: Process implementation not found: com.myApp.workflow.ActivatemyAppPageProcess at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:197) at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:232) at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:512) at org.apache.sling.event.impl.jobs.queues.JobRunner.run(JobRunner.java:205) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at 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;
            }
        }
    }

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 有包,如果您在 /system/console/bundles 上查看您的 AEM 实例并单击 com.adobe.granite.workflow.core 包,您将在 "exported packages" 没有com.adobe.granite.workflow.core.job可用。所以即使你的IDE、Mavenand/orJenkins可以处理,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);

错误的可能原因可能是您的工作流程进程 com.myApp.workflow.ActivatemyAppPageProcess service/component 未激活,因为它未绑定到 JobHandler 的可用进程列表,从而导致此异常。

您能否检查 /system/console/components 您的自定义流程组件是否处于活动状态?如果不是,那么您将必须解决导致 service/component 不可用的依赖关系。