How to inject an event in a Singleton Bean on Start up

428 Views Asked by At

Good day,

Can anyone give me an advise on how to inject an event in a Singleton bean on Start up.

Here is my code. (working OK on Weld (Glassfish 3.1.2))

@Singleton
@Startup
public class SingletonBean {

@Inject @Type private Event<Event>   Event; 

}

But this is the error when this code is deployed on WAS 8.5.5.1

The @Inject factory encountered a problem getting the object instance @Inject java.lang.reflect.Field.event binding object.  The exception message was: Api type [javax.enterprise.event.Event] is not found with the qualifiers 
Qualifiers: [@javax.enterprise.inject.Any()]
for injection into 
 Field Injection Point, field :  javax.enterprise.event.Event package.SingletonBean.event,

I guess the the Event is not injected in the singleton bean on start up.

Thanks for the help.

EDIT 1. Code for qualifier @Type added.

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({
    ElementType.METHOD, 
    ElementType.FIELD, 
    ElementType.PARAMETER, 
    ElementType.TYPE
})
public @interface Type{}
0

There are 0 best solutions below