JBoss Weld @Any Instance do not find all instances

170 views Asked by At

I have some problem with injecting dependencies to the project. In my case I have WAR file with some specialized GWT handlers, and jar with dispatcher classes (dispatcher + common: actions, handlers, results). In this jar I try scan all Handlers and automatically register them:

@Inject
private void init(@Any Instance<ActionHandler<?, ?>> handlers) {
    ...
        InstanceActionHandlerRegistry registry = new DefaultActionHandlerRegistry();
        for (ActionHandler<?, ?> handler : handlers) {
            registry.addHandler(handler);
        }
    ...
}

The problem is that all handlers from jar are registered but Handlers from WAR are not. Both jar and war file have beans.xml files. Does anyone know what I should do to force find all instances of handlers - not only listed in library jar file?

1

There are 1 answers

0
ggolebio On

The reason was that WAR file do not have deployed some library required by handlers. Project compiled successfully and deployed successfully without any error/warning. This was very simple reason but in case when Weld do not report problem - it was very hard to find the source of troubles. (I suppose that better level of problem reporting can be set somewhere for Weld)