Skip to Content
0
Dec 13, 2018 at 11:00 AM

getting org.springframework.beans.factory.BeanNotOfRequiredTypeException even though the imported workflowService is from correct package

160 Views

Hi Experts,

We have a requirement where we need to create a workflow based on few values we receive from a web service call. In my Service class I wrote below piece of code to create the work flow from workflow template after referring a trail from hybris wiki.

if(productModel.getChannelIndicator().getCode().equalsIgnoreCase("OFFLINE")); {

        // start the dropcode workflow for the product
         final WorkflowTemplateModel workflowTemplate = this.workflowTemplateService
             .getWorkflowTemplateForCode("ProductDropCodeEnableorDisableWorkFlow");

      final WorkflowModel workflow = workflowService.createWorkflow(workflowTemplate, productModel, userService.getAdminUser());
          modelService.save(workflow);
          
     for (final WorkflowActionModel action : workflow.getActions())
     {
         modelService.save(action);
     }

     this.workflowProcessingService.startWorkflow(workflow);
    }

}

The build is successful in my local. But when I started my hybris server I am getting below exception:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultProductDropCodeWebService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'workflowService' is expected to be of type 'de.hybris.platform.workflow.WorkflowService' but was actually of type 'de.hybris.platform.workflow.services.impl.WorkflowServiceImpl'

In my service class I have added WorkflowService as a dependency along with other required services as shown below:

 @Resource
 private WorkflowService workflowService;
 @Resource
 private WorkflowTemplateService workflowTemplateService;
 @Resource
 private WorkflowProcessingService workflowProcessingService;
 @Resource
 private ModelService modelService;
 @Resource
 private UserService userService;

I have declared my Service Class in core-spring.xml as shown below:

 <bean id="defaultProductDropCodeWebService"
     class="com.bobs.furniture.core.webservice.impl.DefaultProductDropCodeWebService">
 </bean>

in my service class I have below import statement for WorkflowService:

import de.hybris.platform.workflow.WorkflowService;

Finally my build is failing even though I setup proper dependencies with proper imports.

Can you please check and suggest why this issue is coming. Your prompt reply on this would be truly appreciated.