AnsweredAssumed Answered

How to get Alfresco services in workflow service task

Question asked by pnature on Feb 6, 2017
Latest reply on Aug 21, 2019 by afaust


I am new on Alfresco community version 5.2 

I need use Alfresco services (NodeService, ContentService, ServiceRegistry) inside class used for workflow service task.

I created class but I cannot use Alfresco Services. All methods returns null. What I do wrong?


Thanks in advance.

My class and reference are here:


public class myClass implements JavaDelegate {

    private NodeService nodeService;

    private ServiceRegistry serviceRegistry;

    private ContentService contentService;
    private ApplicationContext applicationContext;


      public void execute(DelegateExecution execution) throws Exception {

        System.out.println("getContentService() " + getContentService());
        System.out.println("getServiceRegistry() " + getServiceRegistry());



    public ContentReader getContentReader(NodeRef docref) {
        ContentReader reader = contentService.getReader(docref, ContentModel.PROP_CONTENT);
        return reader;


    public void setContentService(ContentService contentService)  {
        this.contentService = contentService;
    public ContentService getContentService() {
        return this.contentService;


    public void setNodeService(NodeService nodeService) {
        this.nodeService = nodeService;
    public void setServiceRegistry(ServiceRegistry serviceRegistry) {
        //this.serviceRegistry=(ServiceRegistry)applicationContext.getBean("serviceRegistry");   //this line cause error on deploy
        this.serviceRegistry = serviceRegistry;
    public ServiceRegistry getServiceRegistry() {
        return this.serviceRegistry;




I created file my-class-context.xml on path /myProject/src/main/amp/config/alfresco/extension

I have tried tu put referencies to service-context.xml too.

<?xml version='1.0' encoding='UTF-8'?>
<bean id="myClass" class="com.demo.myProject.task.myClass">
      <property name="contentService">
          <ref bean="ContentService" />
      <property name="nodeService">
          <ref bean="NodeService" />
        <property name="serviceRegistry">
            <ref bean="ServiceRegistry"></ref>