-
1. Re: Custom interceptor not being invoked
lehvolk Oct 18, 2012 6:41 AM (in response to vladcrc)Interceptors invoked by CDI. Switch on CDI on each deployment subsystem or just on parent one (this means that beans.xml file should be added to META-INF folder, also you have to specify all interceptiors inside beans.xml) . You should check out Weld documentation where placed correct way for declaring Interceptors http://docs.jboss.org/weld/reference/latest/en-US/html/interceptors.html
-
2. Re: Custom interceptor not being invoked
vladcrc Oct 25, 2012 7:32 AM (in response to lehvolk)OK, I changed to CDI-style interceptor bindings and I have this:
- a custom subsystem;
- the subsystem has dependencies to "org.jboss.as.ejb3" and "javax.interceptor.api" modules declared in module.xml.
- an interceptor binding called "AppStatus".
- an interceptor. the class is called "AppStatusInterceptor", annotated with "@Interceptor", "@AppStatus" and a method with "@AroundInvoke".
- an application (a simple EJB) with a method annotated with "@AppStatus".
- the application has a dependency to my custom subsystem declared in MANIFEST.MF.
- the application has "META-INF\beans.xml" where the "AppStatusInterceptor" is enabled.
When I deploy the application I get the following error:
------------------------
org.jboss.weld.exceptions.DeploymentException: WELD-001417 Enabled interceptor class <class>com.xxx.AppStatusInterceptor</class>
in vfs:/xxx/jboss-as-7.2.0.Alpha1-SNAPSHOT/bin/content/xxx.jar/META-INF/beans.xml@6
is neither annotated @Interceptor nor registered through a portable extension
------------------------
which is not true, because the @Interceptor is present.
I found this
http://java.net/jira/browse/GLASSFISH-15936
but it's for Glassfish...
-
3. Re: Custom interceptor not being invoked
lehvolk Oct 25, 2012 8:23 AM (in response to vladcrc)I think it is bad exception message. This example works for me:
binding (placed in module):
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.interceptor.InterceptorBinding;
@InterceptorBinding
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface GuiceInjection {
}
here is interceptor (placed in deployment):
import javax.annotation.PostConstruct;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
@Interceptor
@GuiceInjection
public class BeanInterceptor {
.....
}
here is EJB (in deployment too):
@Stateless
@GuiceInjection
public class EJBBean{
}
-
4. Re: Custom interceptor not being invoked
luksa Oct 25, 2012 8:25 AM (in response to vladcrc)Vlad, this looks like a classloading/visibility issue. In Weld 1.1.10.Final there was a major fix in this area. Are you using it?