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
  • 7313 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

smacdonald2008
Level 10
February 9, 2018

Letter Service seems to be an add on. Do you have the OSGi bundle that exposes that Service in an Active State.

smacdonald2008
Level 10
February 9, 2018

Also - i am assuming you are following some sort of online AEM Docs. Can you please point the community to that doc.

debashisghosh
Level 2
February 9, 2018
Adobe Employee
February 9, 2018

I will send you a sample code snippet that I have used in jsp page

never used it as part of a workflow step

what is the use case for doing it as part of aem workflow step?

workflowuserAdobe EmployeeAccepted solution
Adobe Employee
February 9, 2018

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);

debashisghosh
Level 2
February 12, 2018

workflowuser

I want to access the letter instances and generate the correspondence from the Workflow Step process. This workflow step is a part of a workflow process generated from submission of an adaptive form. Here with form data I want to generate the correspondence (Send through mail) to the customer.

Can you please suggest if this like can be done from the workflow step ?  Or correspondence letter needs to be opened from publish instance from user and then only it can be submitted ?

debashisghosh
Level 2
February 13, 2018

Can we not render and email the correspondence letters through an AEM OSGi Worflow process step ? If yes then which API's need to be used, as com.adobe.icc.services.api.LetterService is throwing JCR session error when called from a workflow process. It works if called from a jsp.

debashisghosh
Level 2
February 13, 2018

Hello Scott,

Can we not render and email the correspondence letters through an AEM OSGi Worflow process step ? If yes then which API's need to be used, as com.adobe.icc.services.api.LetterService is throwing JCR session error when called from a workflow process. It works if called from a jsp.

smacdonald2008
Level 10
February 13, 2018

If its a running AEM Service - try @Reference to get a reference to the Service. Like how we use @Reference to the MailServiceGateway Service here:

Adobe Experience Manager Help | Creating custom AEM workflow steps that send email messages

debashisghosh
Level 2
February 13, 2018

I am using @Reference to get the LetterService, but the service is throwing exception related to JCR session from the workflow process. The same exception that I mentioned in my earlier post.

It works when called from jsp.

public class TestLetterGenerationProcess  implements WorkflowProcess{

@Reference

private LetterInstanceService letterInstanceService;

@Reference

private LetterRenderService renderService;

@Reference

private LetterService letterService;

...

}