1. Set the Java build path in the Eclipse preferences. This step is very important. If it is not set correctly, Lomboz will not correctly generate the package name, and the auto-generated code will generate an error when compiling.
2, set the Tools.jar used by Lomboz in the Eclipse preferences. Tools.jar is provided by JDK, linking to the corresponding file of JDK.
3. Set the application server options supported by Lomboz in the Eclipse preferences. Lomboz built-in supports jboss, tomcat, websphere, WebLogic, etc. a wide range of mainstream application servers. Use the BEA WebLogic Server V7.0 as the application server in the example.
4. Create a Lomboz J2EE project.
Select New Project from the menu, select Lomboz J2EE Project from the New Project Wizard.
Follow the wizard to enter the last step. Add the application server to the project and join an EJB Module. If you need to create a web program such as JSP, Servlet, you can create web modules.
Click to complete. Lomboz automatically creates a directory structure and profile, including a build.xml file for Ant creation and deployment.
5. Create an EJB class. Select menu: New / Other. Select Lomboz EJB CREATION WIZARD in the wizard.
Enter the package name, EJB name, and EJB type, click the completion button.
6. Add business methods in EJB. Select the EJB class just created in the Navigator view, select: Lomboz J2EE ... / Add EJB Method ..., set the declaration and type of the method from it.
7, add code to the EJB business method.
Public String Sayhello (String Yourname) {
System.out.println ("Hello" Yourname;
Return "Hello" YourName;
}
8, add the EJB class to the EJB Module. Select the EJB class just created in the Navigator view, select: Lomboz J2EE ... / add ejb to module, tab on the EJB module of this project and determined.
9. Generate an EJB interface and deployment descriptor. In the Navigator view, select the EJB module that just created (MYLOMBOZBEAN), select: Lomboz J2EE ... / Generate EJB Classes ..., Lomboz will automatically generate the Home interface and deployment descriptor.
10, deploy EJB. Open an Ant view, load the Lomboz's deployment file build.xml. Run the deploy target, packaged JAR files will be deployed under the Application directory of WebLogic. The deployed target path depends on the settings for WebLogic Server in the Eclipse preferences.
11, make WebLogic launched under the Production Mode. Open and modify the StartWebLogic.cmd file, set startmode = true (this option is default to false).
12, deploy EJB on WebLogic. Open the WebLogic Management Console and deploy EJB.
After the deployment is successful, open JNDI View, which can find the EJB that is just deployed on the JNDI tree.
13. Develop EJB test procedures with the Lomboz wizard.
Create a new normal Java project, in the build settings, select a Lomboz project (here is MyFirstlomboz). Click to complete.
14, create test code with Lomboz EJB Test Client Wizard. Select menu in the project: New / Other, select Lomboz EJB Test Client Wizard in the Will List. The Wizard settings for the test class samples are as follows. 15, increase the test code. Lomboz generates the default JNDI query code and generates an instance of EJB. You need to add test code for the EJB method.
Public class testejb1 {
Private mysample.myejb1home gethome () throws namingexception {
Return (mysample.myejb1home getContext (). Lookup (
mysample.myejb1home.jndi_name);
}
Private InitialContext getContext () throws namingexception {
Hashtable props = new hashtable ();
Props.put (InitialContext.Initial_Context_Factory,
"WebLogic.jndi.wlinitialContextFactory");
Props.Put (InitialContext.Provider_URL, "T3: //127.0.0.1: 7001");
// this Establishes the security for authorization / authentication
Props.put (InitialContext.security_principal, "system");
Props.Put (InitialContext.security_credentials, "weblogic");
InitialContext InitialContext = New InitialContext (PROPS);
Return INIALCONTEXT;
}
Public void testbean () {
Try {
MySample.myejb1 mybean = gethome (). CREATE ();
MyBean.SAYHELLO ("Zhangyu!");
} catch (remoteException E) {
E.PrintStackTrace ();
} catch (createException e) {
E.PrintStackTrace ();
} catch (namingexception e) {
E.PrintStackTrace ();
}
}
Public static void main (String [] args) {
TESTEJB1 TEST = New TESTEJB1 ();
Test.TestBean ();
}
}
16, start WebLogic Server. Select the just EJB class in the Navigator view, select: Lomboz J2EE ... / Run Server ... will start WebLogic.
17. Run the test program and the console displays the correct result.
About the author: Zhang Wei can be used
e-zhangyu@vip.sina.com Contact the author