[jboss-jira] [JBoss JIRA] (WFLY-3329) EJBs with same Java class name not intercepted by CDI interceptors

Martin Kouba (JIRA) issues at jboss.org
Fri May 30 04:57:19 EDT 2014


    [ https://issues.jboss.org/browse/WFLY-3329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12971890#comment-12971890 ] 

Martin Kouba commented on WFLY-3329:
------------------------------------

In fact, the fix for WELD-1680 (and WELD-1586 respectively) solves a different kind of issue (typesafe resolution). This interception problem cannot be fixed in the Weld code base. It's an integration issue. The {{org.jboss.weld.ejb.spi.EjbServices}} Weld SPI implementation is using ejb-name as a key in a map which stores some interception-related info.

As to "overriding", using {{@Stateless(name="...")}} works fine on WildFly. And also on EAP/AS7 if you modify the reproducer app a little bit. EAP/AS7 is shipped with Weld 1.1 (CDI 1.0) which does not parse CDI 1.1 beans.xml correctly. So if you change the {{beans}} element declaration to:
{code}
<beans xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
{code}       
interceptors are applied.

Also note that the example session beans do not explicitly declare a no-interface view, only Web Service client view (see also EJB spec "4.9.8 Session Bean’s No-Interface View") and so from the CDI point of view, their only bean type should be {{java.lang.Object}} (see [3.2.2. Bean types of a session bean|http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#session_bean_types]). And given that the CDI spec does not state whether a JAX-WS endpoint invocation is intercepted ([7.2. Container invocations and interception|http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#biz_method]) it's rather questionable whether a bean which cannot be injected should be intercepted. You should annotate the session beans with {{javax.ejb.LocalBean}} to expose a no-interface view. On the other hand a no-interface view would not help here ({{EjbServices}} problem mentioned above).


> EJBs with same Java class name not intercepted by CDI interceptors
> ------------------------------------------------------------------
>
>                 Key: WFLY-3329
>                 URL: https://issues.jboss.org/browse/WFLY-3329
>             Project: WildFly
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: CDI / Weld
>    Affects Versions: JBoss AS7 7.1.1.Final, JBoss AS7 7.2.0.Final, 8.0.0.Final
>            Reporter: Maxim Frolov
>            Assignee: Martin Kouba
>              Labels: ejb, ejb3.1, interceptor
>
> h3. Given
> Two or more EJBs with the same Java class name but from different Java deployments.
> h3. Problem
> Interceptor intercepts method calls to only one of the EJBs.
> An EJB to be intercepted seems to be chosen randomly after each redeployment.



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)



More information about the jboss-jira mailing list