We are in the process of moving from jboss 4 to jboss 6. Out has a ton of EJB 2.1 beans. After we deployed the application in jboss 6, beans stopped saving state when the method was called.
Is this normal? if not, what can be done to overcome this problem?
Edit: 2015.08.04
Bean: stateful
I wish I could share the src code, but the company has very strict rules.
Any guidance or direction from your experience will be sufficient.
Additional Information
Scenario: A user updates an employee record.
The system has an AbstractController that does single-entry updates to records. The controller looks at the bean and retrieves a handle to it. Then, using reflection, it extracts the method names. Then sets the "isDirty" flag to true (installer inside the bean)
The controller then repeats the method names, updating each field, invoking the EJB store method. Inside the repository method, the "isDirty" flag is checked before the update statement is run.
In jboss 4, this flag remains as βtrueβ, but when we switched to 6, this flag began to return to false.
FYI: This is an outdated source, and I really want me to be able to change the logic, but I can't.
Update: 2015.08.04: 3pm
I set a breakpoint in ejb and passivate activation methods. beans are passivated immediately after their activation. continuing my investigation. This thread will be updated.
Update: 2015.08.20 I built a sample application in accordance with the EJB specification and launched it in both jboss 5.1 and 6.3
Two copies were identical. between method calls, the bean loses its state
bean.doSomething(); bean.doSomethingElse();
results
setEntityContext(EntityContext ctx) invoked --- Flag Value-false ejbCreate() invoked --- Flag Value-false ejbPostCreate() invoked --- Flag Value-false ejbPassivate() invoked --- Flag Value-false unsetEntityContext() invoked --- Flag Value-false setEntityContext(EntityContext ctx) invoked --- Flag Value-false ejbActivate() invoked --- Flag Value-false ejbLoad() invoked --- Flag Value-false [EmailConfigBean] doSomething invoked.--- Flag Value Updated to-true ejbStore() invoked --- Flag Value-true ejbPassivate() invoked --- Flag Value-true unsetEntityContext() invoked --- Flag Value-true setEntityContext(EntityContext ctx) invoked --- Flag Value-false ejbActivate() invoked --- Flag Value-false ejbLoad() invoked --- Flag Value-false [EmailConfigBean] doSomethingElse invoked.--- int Value Updated to-10 ejbStore() invoked --- Flag Value-false ejbPassivate() invoked --- Flag Value-false unsetEntityContext() invoked --- Flag Value-false
I dug further, and I read it
"The bean provider can use instance variables to store values ββthat depend on the constant state of the entity bean, although this is not recommended. The bean provider should use the ejbLoad method to re-synchronize the values ββof any instance variables that depend on the entity bean s persistent state. In general any fake state that depends on the constant state of the bean must be recounted during the ejbLoad method. "
In other words, you are responsible for setting "isDirty" to the correct state during ejbLoad. You should not expect it to store any particular value from one call to another - if that happens, it is only because of a particular implementation or by accident.