Creating a stateless session bean using wizards
You can use Create EJB 3.x Session Bean wizard to create a stateless session bean and add it to your project.
Before you begin
Procedure
- In the Java EE perspective, right-click your project, and select New > Session Bean. The Create EJB 3.x Session Bean wizard appears.
- In the Source folder field, select the source folder for the new bean.
- In the Java package field, type the package name for the new bean.
- In the Bean name field, type the name that you want
to assign to the enterprise bean. By convention, bean names begin
with an uppercase letter. Note: You can use Unicode characters for the bean name, but Unicode characters are not supported for enterprise bean packages and classes associated with enterprise beans.
- Select Remote to add a remote interface and select Local to add a local interface, and click Finish.
- Select Asynchronous.
By doing so, you are marking all the business methods of the session bean as asynchronous methods. This action adds the @Asynchronous annotation to the class.
- In the Java class
editor, underneath the package declaration, you can see the @stateless annotation.
Your class also contains reference to Local and Remote interfaces,
if you selected to create them:
package com.ibm.test; import javax.ejb.Stateless; /** * Session Bean implementation class TestBean */ @Stateless public class TestBean implements TestBeanRemote, TestBeanLocal { /** * Default constructor. */ public TestBean() { // TODO Auto-generated constructor stub } }
- Define the client views and interfaces. For EJB 3.0 or
later beans, you can include a remote client interface, a local interface,
or both. Here is an example of a simple Remote interface:
package com.ibm.websphere.ejb3sample.counter; import javax.ejb.Remote; @Remote public interface RemoteCounter { public int increment(); public int getTheValue(); }
Parent topic: Creating enterprise beans using wizards

