Develop EJB using Eclipse3.0 + Lomboz3.0 + JBoss3.2.3

zhaozj2021-02-16  101

Use Eclipse3.0 LOMBOZ3.0 JBOSS

3.2.3

Development EJB

Ginger

Jjc@ykjt.cn

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

JBoss

3.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 the D: / Eclipse3 directory is solved, run Eclipse.exe

. 3 Install Lomboz

Put the file Lomboz.3.zip and EMF-SDO-Runtime-

2.0.0

After .zip decompression, copy to D: / Eclipse3 / Plugins and D: / Eclipse3 / Plugins and D: / Eclipse3 / D: / Eclipse3 / Features Directory, run Eclipse.exe again, select File-New-Other in the menu The following interface appears: Figure 1 4 Install JBoss

Will jboss-

3.2.3

.zip decompression to D: /JBoss-3.2.3 directory

5 Configure Eclipse3.0

Select Windows-Preferences in the menu, configure Eclipse Figure 2 in the interface below to configure Eclipse Figure 2 The basic configuration is completed, and then we will write an EJB application. 3. Develop an EJB to do so much preparation, let's write an example helloworld, select the menu file-new-other, bring the following dialog box:

Figure 5 Select Lomboz J2EE Project in Java-Lomboz J2EE Wizards, 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/appser/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. At this time, 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

Figure 13

Right click on the HelloWorldejbbean and select in the pop-up menu.

Lomboz J2EE

, Then choose

Add Ejb Method,

Pop map

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

Right click on HelloWorld and select in the pop-up menu.

Lomboz J2EE

, Then choose

Generate EJB CLASSES

If there is no error, this is automatically generated

EJBSRC

Folders, the files inside are also automatically generated.

Again

HelloWorld

Click the right mouse button and select in the pop-up menu.

Lomboz J2EE

, Then choose

Deploy Module

To deploy

EJB MODULE

.

EJB MODULE

After the deployment is complete, let's make a client to call

HelloWorld ()

method.

Select in the file menu

NEW,

Choose

Other,

The dialog box in the pop-up is as shown

11

Disted, choose

Lomboz EJB Test Client Wizard

, According to the picture

In one

Distance, fill in the corresponding parameters,

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 To To To To 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 on it, select Run in the pop-up menu, select Java Application, if control Output Hello World! Description calls are successful, if there is an exception, then you need to look at this article or email give me Jjc@ykjt.cn.

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.batjava -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/jboss-common-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/jbossx-client.jar; D: / JBoss-3.2.3 / client.jar; d: /jboss-3.2.3/client/jcert.jar; d: /jboss-3.2.3/client/jmx-connector-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/ Client / log4j.jar "com.test.helloworldclient

Place it in the D: / Eclipse3 / Workspace / HelloWorldProject / bin directory (Copy of COM / TEST), then run, or add the path in the quotation marks in the quotation marks in the environment variable ClassPath, then run

Java com.test.helloworldClient

It is also possible.

Is it very ridiculous, "Rain, everyone will take the clothes" :)

转载请注明原文地址:https://www.9cbs.com/read-11247.html

New Post(0)