CDI Interceptor does not work when defined and used in the bean archive (jar)

advertisements

I have the following project structure (Maven):

- war with `WEB-INF/beans.xml`, `WEB-INF/web.xml` and REST service configuration
- ext-spi (packaged as jar, not bean archive) which provides some simple SPI, finally goes to `war/WEB-INF/lib`
- ext - parent project (pom)
-- ext-impl (jar, bean archive - META-INF/beans.xml exists) - contains CDI Interceptor (both binding and implementation) + some REST service (RequestScoped CDI Bean) which is annotated with mentioned Interceptor Binding finally goes to `war/WEB-INF/lib`
-- ext-model (jar) - contains REST service API and data model, finally goes to `war/WEB-INF/lib`

And the problem is that Interceptor simply does not work. Of course I have enabled it in beans.xml (different combinations with war and ext-impl). No errors, no warnings. It looks like META-INF/beans.xml is not even read from jar - no complains about fake classpath which I gave when enabling interceptor or even malformed xml tags. The same CDI Bean has no issues when @Injecting another CDI Bean from the same bean archive.

If I try to use the same Interceptor on some CDI Bean created directly in war - everything works perfectly.

According to spec it should work.

Application Server: Glassfish 3.1.2.2

Interceptor:

@Inherited
@InterceptorBinding
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface ResourceInterceptorBinding {
}

Do you have any idea what may be wrong?


Just for kicks and giggles try adding it the war beans.xml and see what happens.