This lesson leads you through the detailed steps to create an EJB
3.0 project that you will use to contain your EJB session bean.
In order for you to create an EJB 3.0 project, you need to have the WebSphere® Application
Server version 6.1 with the EJB 3.0 Feature Pack installed 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 version
7.0:
- Open the Servers view by selecting .
- Define a new WebSphere Application Server version 7.0 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 version 7.0.
- 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 Next.
- Accept the other default values and click Finish.
- On the EJB Module page, clear Create an EJB Client
JAR module to hold the client interfaces and classes:
- 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.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. This will present 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.