[cdi-dev] Unexplained change in behavior between Java EE 6 and Java EE 7

Steve Millidge smillidge at c2b2.co.uk
Mon Dec 8 13:24:46 EST 2014

I’ll start debugging Payara (GF) then ☹

From: arjan tijms [mailto:arjan.tijms at gmail.com]
Sent: 08 December 2014 18:21
To: Jozef Hartinger
Cc: Steve Millidge; cdi-dev at lists.jboss.org
Subject: Re: [cdi-dev] Unexplained change in behavior between Java EE 6 and Java EE 7


I agree that there should be two instances of the stateful bean, so GF3/EAP6 is correct.

It's remarkable then that seemingly GF4 and WF8 have the exact same integration regression.

At any length this would be a good case for adding an extra test to the TCK ;)

Kind regards,

On Monday, December 8, 2014, Jozef Hartinger <jharting at redhat.com<mailto:jharting at redhat.com>> wrote:
Hi Steve,

this is not caused by a change in the specification nor in Weld. It is probably a regression in GlassFish integration. The correct behavior is the former (2 instances) as that is aligned with how @Dependent instances work in general. If you need the bean instance to be shared across injection points, you can give it a scope other than @Dependent.


On 12/08/2014 06:08 PM, Steve Millidge wrote:

We are investigating a change in behaviour between Java EE 6 and Java EE 7 and were wondering if this is a bug or a specification change;

If there is a RequestScoped bean and SFSB like below, and I call invokeStatefulService() on the Request Scoped Bean the behaviour changes depending on Java EE version;

On GFv3 and JBoss EAP 6 the method returns "init" implying we have 2 separate SFSB instances.
and on GFv4 and WildFly the method returns "stateFromFirst" implying there is 1 SFSB instance.

I would’ve imagined that the second result i.e. 1 SFSB as there is 1 client bean which exists for the duration of the call is the correct behaviour. However I am not sure.

As both appservers above use JBoss Weld for CDI is this a Weld bug or did the behaviour change between Java EE 6 and Java EE 7?

public class Injection {

    StatefulService first;

    StatefulService second;

    public String invokeStatefulService(){
        return second.getState();

public class StatefulService {

    private String state;

    public void init(){
        this.state = "init";

    public void setState(String state) {
        this.state = state;

    public String getState() {
        return state;

Steve Millidge
The Leading Independent Middleware Experts.
T: 08450 539457 | M: 07920 100626 | W: www.c2b2.co.uk<http://www.c2b2.co.uk/> | E: smillidge at c2b2.co.uk<javascript:_e(%7B%7D,'cvml','smillidge at c2b2.co.uk');>
[Main                SIgnature May 14]
C2B2 Consulting Limited, Malvern Hills Science Park, Geraldine Road, Malvern, Worcestershire, WR14 3SZ
Registered in England and Wales: 4563419, Registered Office: Ardendale, Old Hollow, Malvern, Worcestershire


cdi-dev mailing list

cdi-dev at lists.jboss.org<javascript:_e(%7B%7D,'cvml','cdi-dev at lists.jboss.org');>


Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20141208/d4c21470/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 20712 bytes
Desc: image001.jpg
Url : http://lists.jboss.org/pipermail/cdi-dev/attachments/20141208/d4c21470/attachment-0001.jpg 

More information about the cdi-dev mailing list