1. Download the software you need: J2EESDK1.4SDK
http://java.sun.com/j2ee/1.4/download.html
Download j2eesdk-1_4-windows.exe
Eclipse3.0:
http://www.eclipse.org/
Download Eclipse-sdk-3.0-win32.zip
Lomboz3.0:
http://www.objectLearn.com/index.jsp
Download Lomboz.3.zip and Emf-sdo-Runtime-2.0.0.zip
JBoss3.2.3:
http://www.jboss.org/index.html
Download jboss-3.2.3.zip
2. Configure the installation j2eesdk1.4sdk, assume that the installation is installed in the C: / Sun / Appserver directory
1 Add environment variable ClassPath:
(C: / Sun / AppServer / JDK / LIB / Tools.jar; C: / Sun / Appserver / JDK / LIB / DT.JAR;
C: /sun/appserver/lib/j2ee.jar
Add it in the environment variable PATH
C: / sun / appserver / jdk / bin; c: / sun / appserver / bin
2 Install Eclipse3.0
Unzip Eclipse-sdk-3.0-win32.zip, assume that Separate D: / Eclipse3 directory, run Eclipse.exe.
3 Install Lomboz
After extracting the file lomboz.3.zip and emf-do-runtime-2.0.0.zip, copy to D: / Eclipse3 / PLUGINS and D: / Eclipse3 / D: / Eclipse3 / Features Directory Next, run Eclipse.exe again, select File-New-Other in the menu, appear below:
figure 1
4 installation jboss
Unzip jboss-3.2.3.zip to d: /jboss-3.2.3 directory
5 Configure Eclipse3.0
Select Windows-Preferences in the menu, configure Eclipse as follows
figure 2
image 3
The basic configuration is complete, and then we will write an EJB app.
3. Develop an EJB
Do so much preparation, let's write an example helloworld, select the menu file-new-other, bring the following dialog box:
Figure 5
Choose to select Lomboz J2EE Project in Java-Lomboz J2EE Wizard, then click Next:
Figure 6
Enter a project name in Project Name, then click Next button,
Figure 7
Click the Add External Jars button in Figure 7Librarles tab, add c: /sun/appserver/lib/j2ee.jar, then click Next button,
Figure 8
Click the Add button in the EJB Modules tab, add an EJB Module: HelloWorld, then click Targeted Servers,
Figure 9
Select the JBoss 3.2.x server, click the Add button, and finally click the Finish button, then Package Explorer looks like Figure 10 looks like Figure 10.
Figure 10
At the project name HelloWorldProject, click the right mouse button. Select New in the pop-up menu, pop up the chart 11 dialog,
Figure 11
Select Lomboz EJB CREATION WIZARD, then click Next button,
Figure 12
Package Enter Com.test, Name Enter helloworldejb, EJB Type Selects Stateless Session EJB, then click the Finish button, then Package Explorer looks like Figure 13 appearance Figure 13
At HelloWorldejbbean, click the right mouse button. Select Lomboz J2EE in the pop-up menu, then select Add EJB Method, pop up Figure 14 dialog,
Figure 14
Enter public string helloworld () in Method Signture, click the Finish button, find it in the generated code:
Public string helloworld () {
Return NULL;
}
change into:
Public string helloworld () {
Return "Hello World!";
}
HelloWorldejbbean in Package Explorer Click the right mouse button, select Lomboz J2EE in the pop-up menu, then select Add EJB To Module, pop up Figure 15 dialog box.
Figure 15
Select EJB [HelloWorld] and click the OK button. Finding HelloWorld in Package Explorer as shown in Figure 16:
Figure 16
At HelloWorld, click the right button, then select Lomboz J2EE in the pop-up menu, then select Generate EJB CLASSES, if there is no error, this is automatically generated an EJBSRC folder, which is automatically generated automatically.
Right click on the HelloWorld, select Lomboz J2EE in the pop-up menu, and then select Deploy Module to deploy EJB Module.
After the EJB Module is deployed, let's make a client to call the HelloWorld () method.
Select New in the File menu, then select Other, in the pop-up dialog box as shown in Figure 11, select the Lomboz EJB Test Client Wizard, and fill in the corresponding parameters as shown in Figure 17.
Figure 17
Then click the Finish button to generate a HelloWorldClient.java file, edit this file, so that the code looks like the following:
//HelloworldClient.java
/ *
* CREATED ON 2004-7-19
*
* Todo to change the Template for this generated file go to to THERATED FILE Go TO
* WINDOW - Preferences - Java - Code Style - Code Templates
* /
Package com.test;
Import java.rmi.remoteexception;
Import java.util.hashtable;
Import javax.ejb.createException;
Import javax.naming.initialcontext;
Import javax.naming.namingexception;
/ **
* @Author administrator
*
* Todo to change the Template for this generated Type Comment Go To to
* WINDOW - Preferences - Java - Code Style - Code Templates
* /
Public class helloworldclient {
Private com.test.helloworldejbhome gethome () throws namingexception {return (com.test.helloworldejbhome getContext (). Lookup
com.test.heloworldejbhome.jndi_name);
}
Private InitialContext getContext () throws namingexception {
Hashtable props = new hashtable ();
Props.put (InitialContext.Initial_Context_Factory,
"Org.jnp.interfaces.namingContextFactory");
Props.PUT (InitialContext.Provider_URL, "JNP: //127.0.0.1: 1099");
// this Establishes the security for authorization / authentication
// Props.Put (InitialContext.security_principal, "username");
// Props.Put (InitialContext.security_credentials, "password");
InitialContext InitialContext = New InitialContext (PROPS);
Return INIALCONTEXT;
}
Public void testbean () {
Try {
com.test.helloworldejb mybean = gethome (). CREATE ();
// --------------------------------------
// this is the place you make your caver
//System.out.println (MyBean.callyourthod ());
System.out.println (MyBean.helloworld ());
} catch (remoteException E) {
E.PrintStackTrace ();
} catch (createException e) {
E.PrintStackTrace ();
} catch (namingexception e) {
E.PrintStackTrace ();
}
}
Public static void main (String [] args) {
HelloWorldClient Test = new helloworldclient ();
Test.TestBean ();
}
}
Let's run this program, enter the JBoss installation directory D: /JBoss-3.2.3/bin, run run.bat to start the server, after the server starts, find HelloWorldClient.java in Package Explorer, right-click it In the selected menu, select the RUN, then select Java Application, if the Hello World is output in the console, the call is successful. If there is an exception, then you need to look at this article or email give me JJC @ ykjt .
There is also a problem, someone will ask how to run the client in the command prompt environment?
Need to write a batch file RunhelloWorldClient.bat
Java-ClassPath "D: / Eclipse3 / Workspace / EJBPROJECT / BIN; D: / JBOSS-3.2.3 / Client / Concurrent.jar; D: /Jboss-3.2.3/client/gnu-regExp.jar; D: / JBoss-3.2.3 / client / jacorb.jar; d: /jboss-3.2.3/client/jbossall-client.jar; d: /jboss-3.2.3/client/jboss-client.jar; d: / jboss -3.2.3 / Client.jar; d: /jboss-3.2.3/client/jbossha-client.jar; d: /jboss-3.2.3/client/jboss-iiop-client.jar D: /jboss-3.2.3/client/jboss-j2ee.jar; d: /jboss-3.2.3/client/jboss-jaas.jar; d: /jboss-3.2.3/client/jbossjmx-ant. JAR; D: /JBOSS-3.2.3/client/jbossmq-client.jar; d: /boss-3.2.3/client/jbossmqha.jar; d: /jboss-3.2.3/client/Jboss-Net-Client .jar; d: /jboss-3.2.3/client/jbosssx-client.jar; d: /jboss-3.2.3/client/jboss-system-client.jar; d: /jboss-3.2.3/client/ JCERT.JAR; D: /JBOSS-3.2.3/client-factory.jar; d: /jboss-3.2.3/client/jmx-ejb-connector-client.jar; d: / jboss -3.2.3 / Client / JMX-RMI-Connector-Client.jar; D: /JBoss-3.2.3/client/JNet.jar; D: /Jboss-3.2.3/client/jnp-client.jar; D : /jboss-3.2.3/client/jsse.jar; D: /JBoss-3.2.3/clie NT / log4j.jar "com.test.helloWorldClient put it in the D: / Eclipse3 / Workspace / HelloWorldProject / bin directory (Copy of COM / TEST), then run, or add the path in the quotation number in the above batch mark to Environment variables in classpath, then run
Java com.test.helloworldClient
It is also possible.
Is it very ridiculous, "Rain, everyone will take the clothes" :)