I've got the service and it's implementation annotated with @Service
. It works well in one-threaded app, but now I should do some logic from another thread using this service. This is my code:
import org.springframework.beans.factory.annotation.Autowired;
import ru.tenet.smsc.form.MassSMSForm;
import ru.tenet.smsc.service.SaveBatchService;
public class MassSmsRunnable implements Runnable {
private MassSMSForm massSMSForm;
private String userName;
@Autowired
SaveBatchService saveBatchService;
public MassSmsRunnable(MassSMSForm massSMSForm, String userName) {
this.massSMSForm = massSMSForm;
this.userName = userName;
}
@Override
public void run() {
saveBatchService.sendMass(massSMSForm, userName); //here it is
saveBatchService.save();
}
}
But NullPointerException
is all that I've got:
Exception in thread "Thread-3" java.lang.NullPointerException
at ru.tenet.smsc.thread.MassSmsRunnable.run(MassSmsRunnable.java:31)
at java.lang.Thread.run(Thread.java:744)
So, how can I solve this?