-
1. Re: Interceptor from other EAR?
alesj Apr 2, 2012 6:42 AM (in response to reschifl)Is this the right @Interceptor annotation?
-
2. Re: Interceptor from other EAR?
reschifl Apr 2, 2012 8:00 AM (in response to alesj)Hello Ales,
Ales Justin schrieb:
Is this the right @Interceptor annotation?
I use "javax.interceptor.Interceptor".
If I copy the Interceptor-class into the other .EARs, then they can be deployed, but not, if the class comes from the one base .EAR.
The class itself is visible to the other EARs, I tryied to access the class and this also works fine. So it its no dependency problem.
Regards,
Lars
-
3. Re: Interceptor from other EAR?
alesj Apr 2, 2012 8:15 AM (in response to reschifl)Did you enable this interceptor in (the right) beans.xml?
-
4. Re: Interceptor from other EAR?
luksa Apr 2, 2012 8:18 AM (in response to reschifl)Lars, so your setup looks like this:
ear1:
MyInterceptor.class
beans.xml
ear2:
MyInterceptedBean.class
beans.xml (contains: <interceptor>MyInterceptor</interceptor>)
And ear2 has a dependency on ear1?
-
5. Re: Interceptor from other EAR?
alesj Apr 2, 2012 8:23 AM (in response to luksa)This is the code that throws this:
private void validateEnabledInterceptorClasses(BeanManagerImpl beanManager) {
Set<Class<?>> interceptorBeanClasses = new HashSet<Class<?>>();
for (Interceptor<?> interceptor : beanManager.getAccessibleInterceptors()) {
interceptorBeanClasses.add(interceptor.getBeanClass());
}
for (Metadata<Class<?>> enabledInterceptorClass : beanManager.getEnabled().getInterceptors()) {
if (!interceptorBeanClasses.contains(enabledInterceptorClass.getValue())) {
throw new DeploymentException(INTERCEPTOR_NOT_ANNOTATED_OR_REGISTERED, enabledInterceptorClass);
}
}
}
So, imo, it looks like class-loading issue ...
As "interceptorBeanClasses" map doesn't contain your enabled interceptor class,
which looks strange, as I would expect that accessible interceptors would be the same.
-
6. Re: Interceptor from other EAR?
reschifl Apr 2, 2012 8:42 AM (in response to alesj)Ales Justin schrieb:
Did you enable this interceptor in (the right) beans.xml?
I enabled the interceptor inside the dependent other .EARs. not in the base .EAR.
Is this the right place?
-
7. Re: Interceptor from other EAR?
reschifl Apr 2, 2012 8:47 AM (in response to luksa)Hello Marko,
yes this is how I tried it:
BASE.ear:
- BASE.ejb
-- MyInterceptor.class
OTHER.ear:
- OTHER.ejb
-- MyInterceptedBean.class
-- beans.xml (contains: <interceptor>MyInterceptor</interceptor>)
-- MANIFEST.MF (Dependencies: deployment.BASE.ear.BASE.ejb)
Regards,
Lars
-
8. Re: Interceptor from other EAR?
luksa Apr 2, 2012 10:12 AM (in response to reschifl)As Aleš said, it's probably a class-loading thing. Are you bundling weld jars with your app?
-
9. Re: Interceptor from other EAR?
alesj Apr 2, 2012 10:26 AM (in response to luksa)OK, I think I know where the problem is.
The code + msg actually tell us whatr's wrong. ;-)
The classes are all fine, it's simply that your dependant app doesn't have that interceptor as bean.
It does see the class and all, but it's not a bean, as we didn't scan it in the right app nor it was added via extension.
So, yes, you need an explicit extension, and register the interceptor there.
-
10. Re: Interceptor from other EAR?
reschifl Apr 2, 2012 10:27 AM (in response to luksa)Marko Lukša schrieb:
As Aleš said, it's probably a class-loading thing. Are you bundling weld jars with your app?
I build my files with maven and all dependencies to CDI come from the jboss-javaee-6.0 spec with scope=provided.
There are no weld libs in my artefacts.
It may be a class-loading problem, but I don't know how to solve it. As said: trying to access the interceptor class directly in the dependent .EARs code, works fine. They can reach the class. Only the CDI context can not use them.
Should this work, if I create a JBoss module containing the interceptor class? From my knowledge, this is similar than declaring a "deployment" dependency to the contents of the BASE.ear.
Regards,
Lars