Like in the following example:
public interface CommandLineDieselEngineExhaustManipulatorService{
// command line services
}
public interface ClientDieselEngineExhaustManipulatorFacade{
// ui-client services
}
@Stateless
public class DieselEngineExhaustManipulatorImpl implements CommandLineDieselEngineExhaustManipulatorService, ClientDieselEngineExhausManipulatorFacade {
// Implementation of both interfaces
}
@Stateless
public class MyCdiManagedClass{
@Inject
private CommandLineDieselEngineExhaustManipulatorService cliService;
@Inject
private ClientDieselEngineExhausManipulatorFacade clientFacade;
// Whatever
}
I am not interested your opinion in whether or not I should favour the injection of plain Stateless EJBs (without interface) over Stateless EJBs injectable by its implementing interface.
I tried with JEE7 (CDI1) without success. I got the impression that EJB+CDI does not support that.
I wonder if it possible with JEE8?
I could not find any part in the CDI 2.0 specification, which seems to give a hint in the direction. I would highly appreciate if someone could point to the right place.
This Question did not answer the injection part either, might be outdated and the interesting link is dead: Can an EJB bean implement multiple interfaces?
Any ideas?
So, first of all, CDI is not the bad guy here - in fact, from CDI viewpoint, having a bean with two interfaces, you can inject two beans based on those interfaces without problems.
The real deal seems to be EJB. Now, I am not sure what application server are you running and what EJB version (you tagged question as
ejb-3.0
but talk about Java EE 7 which would be EJB 3.2).From EJB 3.1 specification, section 4.9.7 Session Bean’s Business Interface:
Long story's short - Multiple interfaces are not supported in EJB 3.1. That being said, some servers might support it?
However, moving on to EJB 3.2, again section 4.9.7 Session Bean’s Business Interface:
Therefore, in EJB 3.2, it is supported. Note that just below this text there is an example with exactly your case.
So I guess your problem boils down to: