I do have a EJB ActionService which I can inject into other EJBs, that is working fine.
Now I created another EJB:
@Stateless
public class ActionsPerDateDataSet extends ScriptedDataSetEventAdapter {
@EJB
ActionService actionService;
@Override
public void open(IDataSetInstance dataSet) {
actionService.foo() // However actionService is null here!
}
}
Where the ScriptedDataSetEventAdapter comes from another framework (BIRT).
However now my actionService is always null. I can not understand why
It is possible that the class ScriptedDataSetEventAdapter can not be initialized in the EJB Container (First part of the cycle) and as the initialization is not correct, the dependency injection (@EJB and @Inject) is not made.
What you could do is change the Design of your EJB and instead it's extends "ScriptedDataSetEventAdapter" change it to a composition.
@Stateless
public class ActionsPerDateDataSet {
ScriptedDataSetEventAdapter scriptedDataSetEventAdapter;
@EJB
ActionService actionService;
@PostConstruct
public void init (){
try {
scriptedDataSetEventAdapter = new ScriptedDataSetEventAdapter();
} catch( AppException e){
}
}
@Override
public void open(IDataSetInstance dataSet) {
actionService.foo() // However actionService is null here!
}
}
You should introduce the lib as ejbModule in ear file , so that container search the jar file and deploy it and inject it whenever it needs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With