-
Bug
-
Resolution: Done
-
Major
-
AS 4.2.2.GA
-
None
-
None
From the EJB 3 specification we can learn:
3.4.5.1 Stateful Session Beans
A stateful session object has a unique identity that is assigned by the container at the time the object is
created. A client of the stateful session bean business interface can determine if two business interface
references refer to the same session object by use of the equals method.
The following JUnit test fails:
@Test public void testIdentity1() throws Exception
{ Context jndiContext = new InitialContext(); CustomerManager cm = (CustomerManager) jndiContext .lookup("CustomerManagerBean/remote"); assertEquals(cm, cm); }The implementation of CustomerManager is a stateful session bean. Code sketch is:
@Stateful
@Remote(CustomerManager.class)
public class CustomerManagerBean implements CustomerManager {
// details not shown, irrelevant
}
Moreover, if a client uses the reference then it changes its identity! For example:
@Test public void testIdentity1() throws Exception
{ Context jndiContext = new InitialContext(); CustomerManager cm = (CustomerManager) jndiContext .lookup("CustomerManagerBean/remote"); System.out.println(cm + ", hash: " + cm.hashCode()); System.out.println(cm + ", hash: " + cm.hashCode()); System.out.println(cm + ", hash: " + cm.hashCode()); }prints:
[junit] ------------- Standard Output ---------------
[junit] jboss.j2ee:jar=sales.jar,name=CustomerManagerBean,service=EJB3:432f6w1d-y33mrb-fevi3epi-1-fevi3euq-4, hash: 313698436
[junit] jboss.j2ee:jar=sales.jar,name=CustomerManagerBean,service=EJB3:432f6w1d-y33mrb-fevi3epi-1-fevi3euq-6, hash: 313698438
[junit] jboss.j2ee:jar=sales.jar,name=CustomerManagerBean,service=EJB3:432f6w1d-y33mrb-fevi3epi-1-fevi3euq-8, hash: 313698440
[junit] ------------- ---------------- ---------------
(Notice the changing of the string representation of the reference as well as the hash code.)
To my understanding, the above illustrated behavior does not comply to the specification.
- relates to
-
EJBTHREE-1345 Break out "proxy" as new Component
- Resolved