CDI interceptor does not work when defined and used in a bean (jar) archive
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, the Interceptor just doesn't work. Of course, I included it in beans.xml
(different combinations with war
and ext-impl
). No errors, no warnings. Seems like it META-INF/beans.xml
doesn't even read from the jar - doesn't complain about the fake classpath I gave when enabling the interceptor or even malformed xml tags. The same CDI Bean has no problem @Inject
with 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 fine.
According to the 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 might be wrong?
source to share
For those interested: it looks like this is a Glassfish bug. I just found the following Jira question: http://java.net/jira/browse/GLASSFISH-18802
Edit: Even worse - I had to enable the interceptor in ALL bean archives that can be found in META-INF\lib
. Otherwise it just doesn't work.
source to share