Getting Error in calling com.adobe.icc.services.api.LetterInstanceService from AEM Workflow process step | Community
Skip to main content
debashisghosh
Level 2
February 9, 2018
Solved

Getting Error in calling com.adobe.icc.services.api.LetterInstanceService from AEM Workflow process step

  • February 9, 2018
  • 15 replies
  • 7328 views

I am trying to get all Correspondence Letters from a workflow process step (AEM Workflow on OSGi ) , I am using the below API's but getting error related to {Code}-LCC-REP-JCR-001, {Message}-Error in getting a JCR session.

@Reference

private com.adobe.icc.services.api.LetterInstanceService letterInstanceService;

@Reference

private com.adobe.icc.services.api.LetterService letterService;

public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException  {

...

List<LetterInstanceVO> letterInstances = letterInstanceService.getAllLetterInstances(null);

// List<Letter> letters = letterService.getAllLetters(query);

...

}

Error :

com.adobe.livecycle.content.query.exception.QueryException: QueryException: {Code}-LCC-REP-JCR-001, {Message}-RepositoryException: {Code}-LCC-REP-JCR-001, {Message}-Error in getting a JCR session

at com.adobe.livecycle.content.query.impl.QueryServiceImpl.query(QueryServiceImpl.java:152)

at com.adobe.icc.services.am.GenericDaoImpl.findAll(GenericDaoImpl.java:184)

at com.adobe.icc.services.am.LetterInstanceDaoImpl.findAll(LetterInstanceDaoImpl.java:61)

at com.adobe.icc.services.core.LetterInstanceServiceImpl.getAllLetterInstances(LetterInstanceServiceImpl.java:461)

at com.aem63test.core.worflow.CorrespondenceSubmitProcess.execute(CorrespondenceSubmitProcess.java:125)

at com.adobe.granite.workflow.core.job.HandlerBase.executeProcess(HandlerBase.java:193)

at com.adobe.granite.workflow.core.job.JobHandler.process(JobHandler.java:258)

at org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper.process(JobConsumerManager.java:500)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.startJob(JobQueueImpl.java:291)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl.access$100(JobQueueImpl.java:58)

at org.apache.sling.event.impl.jobs.queues.JobQueueImpl$1.run(JobQueueImpl.java:227)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

09.02.2018 16:35:40.166 *ERROR* [JobHandler: /etc/workflow/instances/server0/2018-02-09/abc-loan-application-process-model_7:/etc/fd/dashboard/payload/server0/2018-02-09/WL2QOKMWN2KG775CSYEOHTZFHA_7] com.adobe.granite.workflow.core.job.JobHandler Error executing workflow step

com.adobe.granite.workflow.WorkflowException: Process execution resulted in an error

Maven :

<dependency>

          <groupId>com.adobe.aemfd</groupId>

          <artifactId>aemfd-client-sdk</artifactId>

          <version>6.3.0</version>

</dependency>

I have tried with both LetterInstanceService  and LetterService  with both query parameter and null. Please suggest whether we can use this API or not. I am using AEM 6.3 + cfp + forms addon package

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by workflowuser

This is the sample code snippet from my jsp page which is in production at some of our customers

Statement statement = new Statement();

statement.setAttributeName("name");

statement.setAttributeValue("Ba");

statement.setOperator(Statement.Operator.STARTS_WITH);

Query query = new Query();

List<Statement> statements = new ArrayList<Statement>();

statements.add(statement);

query.setStatements(statements);

LetterService letterService = sling.getService(LetterService.class);

List<Letter> letterList =  letterService.getAllLetters(query);

15 replies

Adobe Employee
February 13, 2018

are you trying to render the letter and show it in the CM UI as part of workflow step?- if yes that is not possible

as To the session error, I think you need to get a service user session and associate the appropriate read permissions to the service user

i do’nt think you can use the workflow session to get access to the letter Assets

debashisghosh
Level 2
February 13, 2018

No I want to only send the letter through email from the workflow. For this also I do need the letter instances right? Or can this be done in some other way without having to access and render the letters through any api? Is something present OOTB?

Level 2
October 15, 2018

Hi,

Have you got any solution for the above issue, I am also facing the same one while invoking the list of letters from the workflow process step, its giving QueryExecutionException for not having valid jcr session.

Can't we use the existing workflow session and there is no way to construct the query using valid session.

Any help would be appreciated.

Thanks
Shubhankar

Adobe Employee
October 18, 2018

Hi,

You are facing the issue because resource resolver is not available to the service when executed from a workflow step. When the same code is executed from jsp it works because resource resolver for the logged-in user is available by default. To provide resource resolver to the api in workflow you can use ReourceResolverHelper's callWith method and provide a service user's resource resolver which has read permissions on the path /content/apps/cm. The api LetterInstanceService/LetterService's api invocation should be done from within the callWith method. To create a service user and obtain its resource resolver you can refer the following links.

  1. AEM6: ResourceResolver access in services - WE ARE ONE INSIDE
  2. Apache Sling :: Service Authentication

This pattern of providing the resource resolver is needed whenever resource resolver is not available by default like in a workflow execution and the api being called needs access to repository.

Will get the documentation article mentioned in this thread updated to reflect this.

Thanks.

Adobe Employee
October 18, 2018

Adobe Experience Manager Help | Developing with Service Users in AEM Forms

Here Is link to an article on creating service user

make sure you give read permissions to content node for the” data” service user