[jboss-jira] [JBoss JIRA] (WFLY-11833) Stateful Session Bean affinity URI instead of cluster

Richard Achmatowicz (Jira) issues at jboss.org
Wed May 22 11:45:00 EDT 2019


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

Richard Achmatowicz commented on WFLY-11833:
--------------------------------------------

There are a couple of problems with this code. 
Remember that this case involves a client invoking a method on a SLSB which creates a SFSB on the server (using an injected @EJB instance on in the SLSB) and then returns the proxy to the client. This involves three EJB client proxies: 
* the proxy used by the remote client to make the invocation on the SLSB (remote client proxy)
* a proxy  created for the @EJB injected instance to allow invocations on the Home interface (for creating the SFSB instance) (home instance proxy)
* a proxy created for the new SFSB instance, and which is returned to the client (SFSB proxy)

The first problem is that the  SFSB proxy is being assigned Affinity.LOCAL when it is created, which assumes that the proxy will only be used locally. THis does not take into account the fact that the proxy will be returned as a result to the remote client.

The second problem is that when an EJB client in a deployment makes an in-container invocation on an EJB in another deployment (or even the same deployment), the results and the exceptions of that invocation are cloned before being returned (I assume so that they can be moved from the EJB's classloading environment to the caller's classloading environment). In particular, if the result of the invocation is a proxy, the proxy gets cloned. A proxy is basically a wrapped instance of EJBInvocationHandler. JBoss Marshalling is used to do this and has a class called SerializedEJBInvocationHandler which is responsible for marshalling and unmarshalling an EJBInvocationHandler. This class normally carries a strong affinity (it its Locator) and a weak affinity. When marshalled, SerializedEJBInvocationHandler only includes the Locator and does not include the weak affinity in the serialised state. When unmarshalled, it uses readReplace() to take the Locator, create an EJBInvocationHandler instance and incorrectly sets the weak affinity based on the strong affinity. The real weak affinity is getting lost. Consequently, during the EJB client Home interface invocation to create the SFSB, where a proxy for the new bean is created and returned as a result, the proxy affinities get whacked from (strong, weak) = (Cluster("ejb"), Node("node-1") to  (strong, weak) = (Cluster("ejb"), Cluster("ejb")), which is not correct. This is the proxy that gets sent back to the remote client.



> Stateful Session Bean affinity URI instead of cluster
> -----------------------------------------------------
>
>                 Key: WFLY-11833
>                 URL: https://issues.jboss.org/browse/WFLY-11833
>             Project: WildFly
>          Issue Type: Bug
>          Components: Clustering, EJB
>    Affects Versions: 16.0.0.Final
>         Environment: WildFly cluster having SFSB deployed.
>            Reporter: Joerg Baesner
>            Assignee: Richard Achmatowicz
>            Priority: Major
>              Labels: downstream_dependency
>         Attachments: stateful-timeout.zip
>
>
> Deployed is an application with the following setup:
> * Containing a SFSB (_with passivationCapable="true"_)
> * A SLSB exposing a _remote_ method to a standalone client returning an instance of the SFSB
> Scenario:
> A standalone client is invoking the _remote_ method on the Stateless Session Bean and a new instance of the Stateful Session Bean is returned.
> The issue is that the affinity of the returned Stateful Session Bean is URI instead of Cluster.
> See the attached Gradle reproducer application



--
This message was sent by Atlassian Jira
(v7.12.1#712002)



More information about the jboss-jira mailing list