How to call custom method from different module in **localServceiIml class?

Olaf Kock, modified 2 Years ago. New Member Posts: 11 Join Date: 8/8/16 Recent Posts

Hi All,

I have created a new SB and now I want to call a method from different module in my ***localServiceImpl. I have added a dependecy of the module in my service.When I tried as below I'm getting the nullpointer exception. Here "AutoPaymentScheduler" is there inside the other module. Please help me out to solve this issue.

public class SchedulerNewLocalServiceImpl extends SchedulerNewLocalServiceBaseImpl {
public void AutoPaymentSchedulerCall (String cronExpression){
   if(Validator.isNotNull(cronExpression)){
      _autoPayScheduler.initJob(cronExpression);
}}
@Reference
   private AutoPaymentScheduler _autoPayScheduler;
}

Thanks in Advance.

thumbnail
Razeena P, modified 2 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Is your SchedulerNewLocalServiceImpl annotated as @Component? @Reference does only work inside of @Components.

Also, don't add the other module as dependency - its API should be enough

Jamie Sammons, modified 2 Years ago. New Member Posts: 11 Join Date: 8/8/16 Recent Posts

Thank you Olaf Kock for the reply, yes I have added @Component and it's working fine now.