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

You must have a Java™ project, an EJB project, or a web project created in your workspace.

Procedure

  1. In the Java EE perspective, right-click your project, and select New > Session Bean. The Create EJB 3.x Session Bean wizard appears.
  2. In the Source folder field, select the source folder for the new bean.
  3. In the Java package field, type the package name for the new bean.
  4. 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.
  5. Select Remote to add a remote interface and select Local to add a local interface, and click Finish.
  6. 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.

  7. 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
        }
    
    }
  8. 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();
    }
Icon that indicates the type of topic Task topic
Timestamp icon Last updated: July 17, 2017 21:58

File name: tcreatesessbeanswiz.html