Hello TomEE-Comunity,

could someone give me an explanation why it is possible to inject by @Inject but not by @EJB in a MBean?

@javax.management.MBean
@ApplicationScoped
class MyMBean  {
        @Inject MyService myserviceA;
        @EJB    MyService myserviceB;
        
        @ManagedOperation
        public void test() {
                System.out.println(myserviceA); // prints the proxy
                System.out.println(myserviceB); // prints null
        }
}

@Stateless class MyService {}

My background is that I can use @Inject as long as my Stateless does not implements an interface:

@Stateless class MyService implements MyInterface {}

Maybe my understanding of CDI is here not deep enough, but for now I use normally @EJB e.g. if the EJB's implements an interface because with @Inject the EJB can not be resolved anymore.

So for now I can not use the MyService with an interface in a MBean. Does someone has a tip what I am doing wrong?

Best Regards
Alexander Wagner

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to