Programming restrictions

What to avoid in EJB if you want to guarantee your bean can be deployed on ANY EJB 2.0-compliant server

image with no caption

Note

Don’t be fooled by things that only SEEM bad, but aren’t

You’re expected to know what you can and can’t do in EJB 2.0. If you think about it too much, you can psych yourself into thinking (on the exam) that anything could be bad.

Here are a few things that you CAN do in EJB, that might trip you up on the exam:

java.net.Socket -- plain old client Sockets are fine. You just can’t listen on a ServerSocket.

Extend another class from your bean class -- normal java inheritance is OK for a bean class.

Mark a bean field static and final -- in fact, that’s the only way you’re supposed to mark a static field. (see the restriction about no read/write static fields.)

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.