Reputation: 411
I have a maven multi module project. When trying to Access a injected bean i get a Nullpointer Exception.
this is the main Function that startsthe application
public class App {
public static void main(String[] args) {
System.out.println("Startpoint");
DecisionMaker decisionMaker = new DecisionMaker();
decisionMaker.run();
}
}
this is what i do in the DecisionMaker
public class DecisionMaker {
@Inject
GameListener gm;
@Inject
BasicProductionManager basicProductionManager;
public DecisionMaker() {
System.out.println("this is the decisionmaker");
System.out.println(gm.toString());
}
so this is not an bean but a normal pojo
the gamelistener is a Applicationscoped bean which i want to inject.
@Named
@ApplicationScoped
public class GameListener extends DefaultBWListener {
@Inject
Event<OnFrameEvent> onFrameEvent;
public Mirror mirror = new Mirror();
public Game game;
public Player self;
@PostConstruct
public void init() {
System.out.println("init listener");
}
the nullpointer gets thrown in the constructor of the DecisionMaker. The @PostConscrutct init method is not called
I looked into similar question but all i found is that i needthe PostConstruct method which i already have.
Upvotes: 0
Views: 2115