All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
Specifaction doesn't prohibit EJB from having non-final static field. It says EJB must not use it (for writing). Read-only static fields are allowed.
21.2.2
An enterprise bean must not use read/write static fields. Using read-only static fields is allowed. Therefore, it is recommended that all static fields in the enterprise bean class be declared as final.
That's seems a little weird. In the first sentence it says "must not". In the third, it says "recommended". How can you ensure a read only field without making it final?
But you are right. This should be added to the explanation.
thank you for your feedback!
Paul.
Hi Paul,
I made a test on Glassfish and tried to write a value to non-final static field in stateles bean. Much to my surprise i didn't get any exception nor warning. My understaing is that me as a programmer have to remember that writing to non-final static field could cause errors. That's why it is recommended to mark these kind of fields as final.