This lesson leads you through the detailed steps to create
an EJB 3.0 project used to contain your EJB session bean.
In order for you to create an EJB 3.0 project, you need to
have WebSphere® Application
Server V7.0, V8.0, or V8.5., and to have a profile created for this
server.
To create an EJB 3.0 counter project:
- Create a server configuration for the WebSphere Application Server V7.0, V8.0,
or V8.5:
- Open the Servers view by selecting .
- Define a new WebSphere Application Server by right clicking the Servers view
and selecting . Follow the instructions in the New Server wizard, ensuring that you select the WebSphere Application Server V7.0, V8.0,
or V8.5.
- Create an EJB 3.0 project:
- If the Java™ EE
icon,
, does not appear in the top right tab of the workspace, you
need to switch to the Java EE
perspective. From the menu bar, select Window > Open Perspective
> Other. The Select Perspective window opens. Select Java EE. Click OK. The Java EE perspective opens.
- In the Java EE
perspective, select .
- In the Project name field, type EJBCounterSample. Select Add project to EAR, and click Next. On the Java page, accept the defaults and click Next.
- On the EJB Module page, clear Create an EJB
Client JAR module to hold the client interfaces and classes and select Generate ejb-jar.xml deployment descriptor:, and click Finish.
- Add a Java class,
@Stateless annotation:
- In the Enterprise explorer view, right click the EJBCounterSample
project and select .
- Accept the default Source folder (EJBCounterSample/ejbModule). In the Package field, type com.ibm.example.websphere.ejb3sample.counter, and in the Name field, type StatelessCounterBean.
- Click Finish.
- Your StatelessCounterBean class opens
in the Java Editor. Add the
EJB 3.0 annotation to generate a session bean by adding @Stateless:
- When you press CTRL+S to save, you can see a quick-fix
icon
beside the @Stateless line.
- Right click the quick-fix icon and select Quick Fix:
- Select Import 'Stateless' (javax.ejb) and press CTRL+S to save: The required dependencies are automatically added to the source
code.
Tip: A shortcut to using the Quick Fix
is to type
@Sta, and press CTRL+Spacebar, which
presents you with two options, and you simply select
@Stateless
- javax.ejb.
The required dependencies are automatically added to the source
code.
You now are ready to move on to Exercise 1.2, Create required
classes and interfaces for the StatelessCounterBean.