I would like to use activiti API in an Alfresco JAVA Webscript to query some process variables (runtime and historical). I use Spring ApplicationContextAware interface to get instanciate ActivitiUtil class like this:
You should (typically) not be calling the low-level Activiti APIs directly, instead using the Alfresco WorkflowService as an abstraction over the workflow engine. Additionally, you may be facing such issues because your web script may not be marked as requiring an authentication context and so you do not have a fully logged-in user. AuthenticationUtil.runAs should be a fix to that in most cases, but should generally be considered a dirty cludge unless you have a specific business requirement to execute code in the context of a specific user. Also note that AuthenticationUtil.runAs will not help you for any functionality that may trigger transaction-level behaviour because such "semi-asynch" logic will be run outside of the runAs-context and as a result continue to result in the same error if that async-logic needs to have a valid security context.
Webscript controllers are defined with: <authentication>user</authentication>, which should require and authentication context. Am I wrong ?
Something that's unclear for me: my webscript is calling WorkflowService which is instantiating ActivitiUtil helper class, getting actitivi API services and to call API methods , without any user context Exception.
Why instantiating ActivitiUtil directly in my WS and calling activiti API should be an issue ?