]
George Gastaldi closed FURNACE-145.
-----------------------------------
Fix Version/s: (was: 2.x Future)
Resolution: Duplicate
This is already requested in FURNACE-32.
The problem is that there are multiple Weld instances (one for each addon that depends on
the CDI container) and during boot, the Interceptor classes are not registered during the
Weld.initialize() call in
{{org.jboss.forge.furnace.container.cdi.lifecycle.WeldAddonLifecycleProvider}}.
CDI Interceptors are not enabled in an addon
--------------------------------------------
Key: FURNACE-145
URL:
https://issues.jboss.org/browse/FURNACE-145
Project: Forge: Furnace
Issue Type: Bug
Components: Container - CDI
Affects Versions: 2.26.1.Final
Reporter: George Gastaldi
If you create an addon and define an interceptor inside its beans.xml, like the
following:
{code:java}
@Interceptor
@MyInterceptorBinding
public class MyInterceptor
{
@AroundInvoke
public Object doIt(InvocationContext invocationContext) throws Exception
{
System.out.println("*********************************** BLAH");
return invocationContext.proceed();
}
}
@InterceptorBinding
@Inherited
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR })
@Retention(RetentionPolicy.RUNTIME)
public @interface MyInterceptorBinding
{
}
public class InfinispanExtension implements Extension
{
void registerInterceptorBindings(@Observes BeforeBeanDiscovery event)
{
event.addInterceptorBinding(MyInterceptorBinding.class);
}
}
{code}
Now, when you create another addon depending on this addon, and change its beans.xml to
contain the following:
{code:xml}
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<beans
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bean-discovery-mode="all" version="1.1"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd">
<interceptors>
<class>org.jboss.forge.addon.infinispan.MyInterceptor</class>
</interceptors>
</beans>
{code}
The following error is shown:
{code}
WELD-001417: Enabled interceptor class org.jboss.forge.addon.infinispan.MyInterceptor
(<class>org.jboss.forge.addon.infinispan.MyInterceptor</class> in
jar:file:/home/ggastald/.forge/addons/org-foo-foo-1-0-0-SNAPSHOT/foo-1.0.0-SNAPSHOT-forge-addon.jar!/META-INF/beans.xml@7)
does not match an interceptor bean: the class is not found, or not annotated with
@Interceptor and still not registered through a portable extension, or not annotated with
@Dependent inside an implicit bean archive
{code}