first of all you don't have to annotate the SLSB with
@LocalBean. For a session bean, the observer method must be either a business method (i.e. declared on the
PaymentProcessorin your case) or a static method (see also 10.4. Observer methods). Also the SLSB is still discovered even if annotated with
@LocalBeanbut if it has a no-interface view the set of bean types only contains bean class, all superclasses and
java.lang.Object(see also 3.2.2. Bean types of a session bean). So it does not contain
PaymentProcessorin your case.
But if neither options (business method or static) are possible, annotation with @LocalBean seems reasonable, even though it has/contains a PaymentProcessor interface (see example).
Also, it works on JBoss AS 7.1.1. I don't think this is spec related (CDI 1.0 vs 1.1), but I could be wrong.
If you annotate an SLSB with
@LocalBeanthe container thinks it exposes a no-interface view, i.e. the
onObserve()method becomes a business method and it's recognized by CDI as an observer. However, the set of bean types of your SLSB only contains
java.lang.Object(this is per the spec). And so
Instance<PaymentProcessor>should be an unsatisfied dependency (unless there's another bean with type PaymentProcessor).
Also, it works on JBoss AS 7.1.1.
This is odd. Let me try your cdi-test...
Duncan, I did a quick test and you're right in that it works differently on AS7/EAP with Weld 1.1.x. Most probably because there is no proper TCK test for this. In any case, I believe that the current implementation (Weld 2.2+) is correct per the spec and will likely not change.