A "Hello World" Session Bean

The structure of Enterprise JavaBeans can be a little awkward to work with at first, but after you get a feel for the structure, EJBs aren't too bad. Fortunately, you can become familiar with the basic EJB structure without worrying about database connections or transactions. To do this, start with a good old-fashioned "Hello World" bean.

When you design EJB applications, you might wonder whether you should start with the bean and then create the interfaces, or start with the interfaces and then create the bean. Your best bet here is to start with the interfaces. If you can't describe how a client is going to use the bean, you aren't ready to write it.

Creating the Remote Interface

Listing 6.1 shows the HelloWorldSession ...

Get Special Edition Using Java™ 2 Enterprise Edition 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.