Developing an EJB based on Weblogic with Eclipse and Lomboz Plug-ins

Source: Internet
Author: User
Tags client
Web 1, set the Java build path in Eclipse preferences. This step is very important. If it is not set correctly, Lomboz will not generate the package name correctly, and the auto-generated code will generate an error at compile time. 2. Set the Tools.jar used in Lomboz in Eclipse preferences. The Tools.jar is provided by the JDK and linked to the corresponding file in the JDK. 3. Set the application server option supported by Lomboz in the eclipse preferences. Lomboz support JBoss, Tomcat, WebSphere, WebLogic and many other mainstream application servers. Use the BEA Weblogic server v7.0 as an application server in the example. 4, create Lomboz Java project. Select New project from the menu and select Lomboz Java Project from the New Project Wizard. Follow the wizard into the final step. Add the application server to the project, and then join an EJB Module. If you need to create Web programs such as JSPs, servlet, and so on, you can create Web Module. Click Finish. Lomboz automatically creates the directory structure and configuration files, including a build.xml file for ant creation and deployment. 5, create the EJB class. Select menu: New/other. Select Lomboz EJB creation Wizard in the wizard. After you enter the package name, EJB name, and EJB type, click the Finish button. 6, add the business method in EJB. Select the EJB class that you just created in the Navigator view, and choose from the right-click menu: Lomboz j2ee.../add ejb method ..., from which you set the declaration and type of methods. 7, add code to the EJB business method.         public string SayHello (string yourName) {               System.out.println ("Hello" +yourname);               return "Hello" +yourname;       } 8, adding EJB classesInto the EJB module. Select the EJB class that you just created in the Navigator view, choose from the right-click menu: Lomboz j2ee.../add ejb to module ..., tick on the EJB module of this project, and OK. 9. Generate EJB interface and deployment descriptor. Select the EJB Module you just created in the Navigator view (Mylombozbean in the example) and choose from the right-click menu: Lomboz j2ee.../generate EJB Classes...,lomboz will automatically generate the home interface and deployment descriptor. 10, deploy EJB. Open the Ant view and mount the Lomboz generated deployment file Build.xml. Run the deploy target, and the packaged jar file will be deployed to the WebLogic application directory. The target path for the deployment depends on the settings for WebLogic Server in the Eclipse preferences. 11, make WebLogic in production mode under the start. Open and modify the Startweblogic.cmd file and set startmode=true (this option defaults to false). 12, deploy the EJB on the WebLogic. Open the WebLogic Management console and deploy the EJB. After successful deployment, open the Jndi View to find the EJB you just deployed on the Jndi tree. 13, using the Lomboz Wizard to develop the EJB test program. Create a new normal Java project, and in the build setting, select a Lomboz item (this is Myfirstlomboz). Click Finish. 14. Create test code with Lomboz EJB Test Client Wizard. Select menu in Project: New/Other, select Lomboz EJB Test Client Wizard in the wizard list. Test class for wizard settings like the next. 15, increase the test code. Lomboz generates the default Jndi query code and generates an instance of the EJB. You need to manually 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 initialcontext;       }        public void Testbean () {                Try {                      mysample.myejb1 Mybean = Gethome (). Create ();   &Nbsp;                  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 and choose from the right-click menu: Lomboz j2ee.../run Server ..., will start WebLogic. 17, run the test program, the console display the correct results. Author Introduction: Yu Zhang   can contact author with e-zhangyu@vip.sina.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.