cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow ID not found Android SDK exception

mcasanket
Champ on-the-rise
Champ on-the-rise
Hi All,

When I try to start workflow it gives the exception.

When I debugged the exception is thrown from the below line
       

            WorkflowService workflowService = this.session.getServiceRegistry().getWorkflowService();

            // Tried both the belwo lines one by one
            String processDefinitionIdentifier = WorkflowModel.KEY_REVIEW_ACTIVITI;
            processDefinitionIdentifier = "activiti$activitiReview";

            // Exception thrown from below line
            ProcessDefinition processDefinition = workflowService.getProcessDefinition(processDefinitionIdentifier);
       


<strong>Exception</strong>:
06-03 09:27:48.217    1111-1455/com.sign.alfdroid.app E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:299)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
            at java.util.concurrent.FutureTask.run(FutureTask.java:239)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:856)

Caused by: org.alfresco.mobile.android.api.exceptions.AlfrescoServiceException: {"error":{"statusCode":404,"briefSummary":"05030002 <strong> The entity with id: activiti$activitiReview:1:8 was not found</strong>","stackTrace":"[org.alfresco.rest.workflow.api.impl.ProcessDefinitionsImpl.getProcessDefinition(ProcessDefinitionsImpl.java:255), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), java.lang.reflect.Method.invoke(Method.java:601),
3 REPLIES 3

jm_pascal
Star Contributor
Star Contributor
Aloah,

Depending on your CMIS endpoint during session creation the process definition identifier is a little bit different. Indeed if the public API is used the prefix 'actviti$' is useless.

To summarize,

If your endpoint url is like <AlfrescoServerHostname>:<port>/alfresco/cmisatom
Process Definition Identifiers have 'actviti$' prefix like "activiti$activitiReview"

If your endpoint url is like <AlfrescoServerHostname>:<port>/alfresco/api/-default-/public/cmis/versions/1.0/atom/
Process Definition Identifiers don't have 'actviti$' prefix like "activitiReview"

If your endpoint url is like <AlfrescoServerHostname>:<port>/alfresco
and your Alfresco Server has Public API (4.2Enterprise or 4.2.e+ community If my memory is good)
Process Definition Identifiers don't use the 'actviti$' prefix like "activitiReview"

If your endpoint url is like <AlfrescoServerHostname>:<port>/alfresco
and your Alfresco Server doesn't have Public API
Process Definition Identifiers use the prefix "activiti$" like "activiti$activitiReview"


For more informations on Workflow constants :
https://github.com/Alfresco/alfresco-android-sdk/blob/e6fa20da42175e2eb72f7c2f5144a86fbb201841/alfre...

Thanks for your reply.

When I go to workflow console and fire a command "show definitions all" it shows  me the below result. In that the process id is as below.
id: activiti$activitiReview:1:8 , name: activiti$activitiReview , title: Review And Approve , version: 1

I have attached the screenshot.

I am developing using Alfresco-Android sdk 1.3.1 version.
Alfresco version is 4.2.2.

However the same code was working before with alfresco 4.1 versions…

Please help.

jm_pascal
Star Contributor
Star Contributor
As said previously 4.2 has introduced the public API. It's the official recommended REST API.
The public API has a different URL than other Alfresco REST API.

With Alfresco 4.2 when you create a RepositorySession with an url like http://myhostnameSmiley Tongueort/alfresco, we will automatically bind to http://myhostnameSmiley Tongueort/alfresco/api/-default-/public/cmis/versions/1.0/atom/
With Alfresco 4.0.x & 4.1.x when you create a RepositorySession with an url like http://myhostnameSmiley Tongueort/alfresco, we will automatically bind to http://myhostnameSmiley Tongueort/alfresco/cmisatom

If you create your RepositorySession with an url like http://myhostnameSmiley Tongueort/alfresco/cmisatom your code should works as previously.
But if you want to use the public API on 4.2, you need to rework your processDefinition and remove the activiti$ prefix which is useless.
Another approach is to use the session.getServiceRegistry().getWorkflowService().getProcessDefinitions() to list all process definition, find your requested definition by its name and then use it.

Hope it helps.