Workflow service.getworkflow throws null pointer exception | Community
Skip to main content
December 15, 2023
Solved

Workflow service.getworkflow throws null pointer exception

  • December 15, 2023
  • 3 replies
  • 1807 views

Hello Team

 

 

Related to workflow access facing some issue.

I have imported workflow nodes (var folder nodes) from higher environment to my local.

 

In my local im trying to access these workflow in servlet but I keep getting null pointer exception.

 

/Var folder server0 and server1 folder. Since I installed them using package manager. It shows created by admin.

 

Servlet code

 

ResourceResolver resResolver = resolverFactory.getAdministrativeResourceResolver(null);

session=resourceResolver.adaptTo(session.class);

WorkflowSession wfsession = workflowServixe.getworkflowsession(session);

Workflow workflow= wfsession.getworkflow("<workflow path>")

 

This code throws null pointer exception. Why is it??

Any issues with importer content? Or permissions?

 

 

Any inputs would help. Thank you

 

 

 

 

 

 

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 girishb83316758

I do have related models in my local instance.

However, the workflow model version number were different.

Imported workflow nodes had model version which were not present in my instance. Hence during getWorkflow - version error was occurring.

 

Then I checked the versions of workflows models in my local and updated to the imported content to match it. Then it worked.

 

Thanks!!

3 replies

arunpatidar
Community Advisor
Community Advisor
December 15, 2023

Hi @girishb83316758 
You have to use subservice session not the getAdministrativeResourceResolver.

e.g. https://github.com/arunpatidar02/aem63app-repo/blob/master/java/SeesionInServletWithSubservice.java 

Arun Patidar
December 16, 2023

I did try this approach as well. But same results.

Turns out the workflow model version no. in my local and other instance were different. Keeping version number in sync worked.

Thank you!!

kautuk_sahni
Community Manager
Community Manager
June 7, 2024

@girishb83316758 I hope you found the AEM community helpful. We look forward to seeing you return as either a learner or a contributor. The community flourishes with SMEs like you. Be an ambassober and ask your AEM peers to also contribute here. Happy AEM learning!

Kautuk Sahni
aanchal-sikka
Community Advisor
Community Advisor
December 15, 2023

@girishb83316758 

 

Just curious, why would you import Workflow instanced from an another system?

I hope you have the model and payloads on local as well

 

Aanchal Sikka
December 15, 2023

Imported data to replicate some issue in local instance.

fmateen
December 15, 2023

Hi @girishb83316758  Beside the var folder you also need the nodes related to that workflow under /conf/global/settings/workflow/models/YOURWORKFLOW

Can you confirm do you have  models nodes also in your workflow package?

girishb83316758AuthorAccepted solution
December 16, 2023

I do have related models in my local instance.

However, the workflow model version number were different.

Imported workflow nodes had model version which were not present in my instance. Hence during getWorkflow - version error was occurring.

 

Then I checked the versions of workflows models in my local and updated to the imported content to match it. Then it worked.

 

Thanks!!

kautuk_sahni
Community Manager
Community Manager
June 7, 2024

@girishb83316758 I trust you found the AEM community useful. We look forward to seeing you return as either a learner or a contributor. The community is enriched by SMEs like you. Encourage your AEM peers to contribute here as well. Happy AEM learning!

Kautuk Sahni