I, Environment construction
First, the required environment
1. JDK (1.6 and later)
2. Eclipse (I use Juno version)
3. JBoss 7.1.1 Download Address: http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.final/jboss-
As-7.1.1.final.zip
Ii. installation of JBoss
1, extract the downloaded compressed files to the local directory, note: Unzip the directory do not include Chinese and spaces and other characters.
2. Configure the JBOSS environment variable. Variable name: jboss_home, Variable value: The decompression directory in the first step. (This
The step is not required, but it is recommended to configure, or you will not be able to find JBoss after you open Eclipse
environment variable).
3.
Third, install JBoss Tools
Version Juno: Install JBoss Tools using Eclipse Marketplace. Specific operation: Help->eclipse
Marketplace-> Search for JBoss Tools, click Install and follow the prompts.
Indigo version:
1. Download JBoss Tools: Download Address:
http://sourceforge.net/projects/jboss/files/JBossTools/JBossTools3.3.x/jbosstools-3.3.1. Final.aggregate-update-2012-07-14_23-57-15-h211.zip
2, specific operation: Help->install New software->add->archive Select the. zip file you just downloaded. Root
Be prompted to install it.
Iv. Configuring JBoss
1. Go to the Server tab:
4. Right click New->server
5. Select the default JBoss as 7.1 and click Finish.
6. Right click on the new JBoss server->start and start the server.
7, using the browser to access the http://127.0.0.1:8080/, if the following image appears, the configuration is successful.
II, Hello World Implementation
1. New Project:
Note: In the EJB Module version column, select version 3.0.
Click Next to Generate Ejb-jar.xml deployment descriptor a bar to be automatically created by Eclipse
XML deployment file.
Click Done. Complete the creation of the EJB project.
2. Add the Jar package required by the client. Configure the build path, click Add External Jar on the Libraries tab, select
The Jboss-client.jar file under JBoss installation directory jboss-as-7.1.1.final\bin\client, complete the jar file
Add to.
3. Create Session Bean. Under the EjbModule root directory, create session Bean 3.x.
The package name is com.jerrylab.business, the class name is Helloworldbean, the type is stateless, and Remote is selected.
Complete the Session Bean creation.
The IDE automatically completes the creation of two Java files. Where Helloworldbeanremote.java is a remote connection
Port, Helloworldbean is the implementation of the interface.
Add the following code to the Helloworldbeanremote.java: Package com.jerrylab.business;
import Javax.ejb.Remote;
@Remote Public interface Helloworldbeanremote { public String SayHello ();
}
Add the following code to the Helloworldbean.java: Package com.jerrylab.business;
import javax.ejb.Stateless;
/**
* Session Bean Implementation class Helloworldbean
*/
@Stateless public class Helloworldbean implements Helloworldbeanremote {
/**
* Default constructor.
* /Public Helloworldbean () {
TODO auto-generated Constructor stub
}
@Override
Public String SayHello ()
{
TODO auto-generated Method Stub
return "Hello world!!!";
}
}
4. Deploy the EJB to the JBoss server. Select JBoss Server, right click on Add and Remove ...
Add HELLOWORLDEJB. Click Done.
The following text appears in the console to indicate that the EJB deployment was successful.
5, set up the Client tool class.
All naming services are done on the implementation of the Javax.naming.Context interface.
Create a new class called Clientutility, with the package name Com.jerry.clientutility.