I am autowiring an object in a component. I was able to access it in one component and I am unable to access it in another component.
Why is that?
@Component
public class AcListenerPublisherImpl implements MessageListener {
private static final Logger log = Logger.getLogger(AcListenerSubscriber.class);
@Value("${ac.templates.actual}")
private String actual;
@Value("${ac.templates.curve}")
private String curve;
@Autowired
private AcImpl ac;
public AcListenerPublisherImpl(){
}
@Override
public void onMessage(Message message) {
try {
......
} catch (JMSException | ClassNotFoundException | IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
private void executeevent(AcTransactionRecord record) {
AcEvent acEvent;
LINE 100 log.info("Got port" +ac.getServer().getHttpPort() + "got actual"+ actual);
acEvent = new AcEventPublisherImpl(ac, actual.split(","), curve.split(","), record);
}
I cant access ac object, it is throwing a null pointer exception at that line 100. Important thing is, same object is autowired in another already existing class and it works perfectly fine. It is in the new class that I created here where I am not able to access any of those autowired objects. I cant access the values with $ sign too. These all worked perfectly in other classes. Could this be due to the package structure? or I am doing anything wrong?