Java Reference
In-Depth Information
Before you start creating your EJB component, you might like to have a simple EJB container for
testing purposes. For simplicity's sake, we have chosen Apache OpenEJB ( )
as the EJB container, which is very easy to install, configure, and deploy. OpenEJB is an open source EJB
container. OpenEJB was designed for the Apache Geronimo server project ( ),
but you don't need Apache Geronimo to run OpenEJB.
Note You can download OpenEJB Standalone Server (e.g., v3.1.1) from the OpenEJB web site and extract it to
a directory of your choice to complete the installation.
Creating EJB 2.x Components Without Spring's Support
First, let's create the EJB component without Spring's support. To allow remote access to this EJB
component, you expose the following remote interface to clients.
Note To compile and build your EJB component, you have to include the library that contains standard EJB
classes and interfaces in your classpath. For OpenEJB 3.1.1, it's javaee-api-5.0-2.jar (located in the lib directory
of the OpenEJB installation).
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface PostageServiceRemote extends EJBObject {
public double calculatePostage(String country, double weight)
throws RemoteException;
This calculatePostage() method has a signature similar to that in the business interface, except it
declares throwing RemoteException .
Also, you need a remote home interface for clients to retrieve a remote reference to this EJB
component, whose methods must declare throwing RemoteException and CreateException .
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
Search WWH ::

Custom Search