The OpenNET Project / Index page

[ новости/++ | форум | wiki | теги | ]

Поиск:  Каталог документации

Next Previous Contents

7. How to Setup Enterprise Java Bean (EJB) Support

To be written.

7.1 BEA WebLogic

To be written.

See more information.

7.2 EJBoss


EJBoss has been renamed JBoss and is well advanced with stable J2EE compliant releases at

This section was written when it was still EJBoss 0.95 and needs to be updated.


JBoss can be downloaded from the JBoss website at


I suggest installing files in the /usr/local directory. After downloading, run:

mkdir /usr/local/ejboss 
mv ejboss* /usr/local/ejboss

Unjar the file:

jar xvf ejboss095_jdk122.jar

You should see various files and directories created under /usr/local/ejboss.

The above example shows EJBoss 0.95 for JDK 1.2.2. Substitute the file names as appropriate.

Setting up Your Environment

The environment variables to set up are:

The CLASSPATH environment variable references all JARs and directories that you will need to compile and run Java programs.

Include the EJBoss JAR and the beans/generated directory in your CLASSPATH.

export CLASSPATH=/usr/local/ejboss/lib/ejboss095_jdk122.jar:/usr/local/ejboss/beans/generated:$CLASSPATH

Confiming Your Installation

You are now ready to compile and run a simple EJB application. Create the following three source files for the server.

First, the business interface.


import javax.ejb.*;
import java.rmi.RemoteException;

 interface EJBTest extends EJBObject { 
  public String greet() throws


Second, the home interface.


import javax.ejb.*;
import java.rmi.RemoteException;

 interface EJBTestHome extends EJBHome {

  public EJBTest create() throws
   CreateException, RemoteException;

Third, the bean implementation class.


import javax.ejb.*;
import java.rmi.RemoteException;

 interface EJBTestBean implements SessionBean {

  private SessionContext
 mContext = null;

  public void ejbPassivate() {

  public void ejbActivate() {

  public void ejbCreate() {

  public void ejbRemove() {

  public void setSessionContext() {
 context set.");
    mContext = context;

  public String greet()
    return "Hello, I'm an EJB!";


Compile the server source files with the Java compiler:

javac EJBTest*.java

If the compiler produces errors, double check the syntax and confirm your PATH and CLASSPATH.

Now that you have successfully written and compiled the server source files, you need to deploy your bean to EJBoss. Deploying a bean to EJBoss requires several steps that must be performed exactly.

First, create the file ejb-jar.xml.

<?xml version="1.0" encoding="Cp1252"?>
<ejb-jar ID="">
         <description>Nextgen bean</description>
     <assembly-descriptor />

The above file, which must be named ejb-jar.xml identifies the interface and class names of files that you just created as well as a name for the object.

Second, relative to the directory of the three class files you just created, create a META-INF directory.

mkdir META-INF
mv ejb-jar.xml META-INF

Third, package all four files into a jar.

jar cvf EJBTest.jar EJBTest*.class META-INF/ejb-jar.xml

You should see that it added the manifest as well as the three class files and the XML deployment descriptor file.

Fourth, put the JAR you just created in the EJBoss beans directory.

mv EJBTest.jar /usr/local/ejboss/beans

Fifth, move the class files you created to the EJBoss beans/generated directory.

mv EJBTest*.class /usr/local/ejboss/beans/generated

(This fifth step is redudant due to a bug in EJBoss 0.95. )

You are now ready to start the EJBoss server.

cd /usr/local/ejboss


You should see the proxy files compile automatically and confirmation that your EJB is deployed.

You are now ready to write, compile and test the simple client applicaiton.

7.3 Bullsoft JOnAS EJB

To be written.

See more information.

Next Previous Contents
  Закладки на сайте
  Проследить за страницей
Created 1996-2018 by Maxim Chirkov  
Hosting by Ihor