Use Eclipse to develop J2EE applications - integrated Eclipse, Lomboz and JBoss Author: Jiang Weiwei from: IBM Eclipse is a very good integrated development environment, the open source project at IBM support after a period of development to improve, has been for the majority of Java developers It is familiar with it. The emergence of Eclipse provides Java developers with free use of powerful Java IDE, through integrated large amounts of Plugin, Eclipse's functionality can be expanded to support a variety of different applications. Lomboz is a free Eclipse Plugin, which integrates many Java application servers, J2EE components, and web applications to Eclipse, which helps Java developers build, test, deploy J2EE applications. JBoss is an open source, powerful Java application server, is also a Java application server that is most popular in Java developers, and is awarded the 2002 Best Application Server by Java World's editors. The downloaded quantity so far in 2003 has exceeded 15 million times. First, download, installation, and configuration 1. Eclipse download and installation First need to install JDK, you can download the latest version and install it up to Sun's website. Then go to http://www.eclipse.org/ to download the latest version of Eclipse, the current latest version is 2.1. After downloading, unfailed to the directory you want, such as D: / Eclipse, running Eclipse.exe directly, automatically looks for JDK when you run, and complete the appropriate configuration, then enter the main interface of Eclipse. About Eclipse's basic usage, developerWorks, Eclipse websites, and Eclipse's random documents are described in detail, which is not described in detail. 2. JBoss download, installation JBoss's current latest version is 3.2.1, but I think this version has some problems, there will be some JAR packages when the server is started, causing the happening of WARN and Error. So I recommend download 3.0.7, or I can download JBoss version 3.0.7 of Tomcat 4.1.24. After downloading, we assume that JBoss_home is the main directory of JBoss, execute jboss_home / bin / run.bat, launched the JBoss server. Generally, it will be started for about 1 minute. 3. Lomboz download, installation, and configuration Lomboz's current version is 2.1, we assume that the primary directory of Eclipse is eclipse_home, download it below the Eclipse_home / plugins folder, so there is more com.Objectlearn below this folder. .jdt.j2ee folder. Then start the Eclipse, the Customize Perspective dialog box will automatically appear. If you do not appear, you can also display this dialog by menu "Window-> Customize Perspective, as shown below: Expand File-> New, select all Lomboz Related options; Expand Window-> Show View, select Lomboz J2EE View; Expand Other, select Lomboz Actions. Confirm OK. Below you want to configure the Lomboz configuration: First, open the Properties dialog box, make sure the settings in Java-> New Project: Then in the Lomboz property, make sure the following settings: Finally, set the server properties.
Lomboz pre-defines the settings of commonly used Java servers, which are placed under the Eclipse_home / plugins / com.objectlearn.jdt.j2ee / servers folder, you can use the text editor to manually modify (unless you use the server is not in Lomboz In the default server, I don't recommend you to do this), or you can set it in the Eclipse's Properties dialog box, the process is very simple, as shown below: Remember After each modification, you must click Apply. The above figure is the setting under the Properties tag. The ClassPath label does not need to be changed under the label (Note: If you don't listen to the advice of my article, I use the version of JBoss3.2.0, which may need to manually add more JAR package. This is physical activity, some troubles. I don't know if this is a JBoss problem, and I will mention it below.). Through the above three steps, Lomboz's support and JBoss configuration are completed. You can enter the second part of the article "Using Eclipse Development Web Application". Note: a. If the server is not in the default server; in the eclipse_home / plugins / com.objectlearn.jdt.j2ee / servers folder, create a file named Server file, then edit Server with the text editor according to the existing Server file file. After establishing a new Server file, you can also make the appropriate settings in the property page of Lomboz. B. If you use the JBoss 3.2.0 version. Open Window> Preference> Lomboz> ServerDefinitions, select your server, then select the ClassPath tab, add the following JAR package to Server Library: jboss_home / lib / control.jar jboss_home /lib/boss-system.jar jboss_home / server / default / lib / jboss.jar JBOSS_HOME /server/default/lib/jpl-pattern.jar JBOSS_HOME /server/default/lib/jpl-util.jar JBOSS_HOME /server/default/lib/jnpserver.jar JBOSS_HOME / server / default / LIB / JBOSS-Transaction.jar I have all the contents in my jboss320.server file presented in the last part of this article. Second, using the Eclipse development web application First, open file-> new-> Lomboz J2EE Project, create a J2EE Project called TestJ2ee. Click Next, default various settings, click Next, go to the next dialog, add the configured server in TargeTed Server, as shown below: New web modules and EJB modules are newly created in Web Modules and EJB Modules, in this case We named myWeb and MyEJB, and then click Finish. In this way, the framework of a J2EE project is automatically generated. Below under the MyWeb module, two JSP files are automatically generated: index.jsp and error.jsp, and the configuration file below the web-INF file.
We can add your own JSP files and servlets on this basis, and then build project. On the toolbar of Eclipse, click on the button of the Lomboz J2EE Project Outline: This will appear on the Eclipse, as shown below: Since I have deployed another web server in advance: Tomcat, so on the MYWEB module The two servers that have occurred have occurred, and the red tag next to JBoss 3.0 all indicates that it is the default server. You can select the default server by right-clicking on the web module, as shown below: After selecting the server, right-click the server, select the Run server, wait until the server is started, right-click the web module, select Deploy Module, select Deploy Module, This completes the deployment of the web module on the server. Open the IE browser, type http://127.0.0.1:8080/Myweb, you can see the web application developed. Here is a point where Tomcat is used as a web server, if the web module needs to be redeployed, you must restart the Tomcat server, and JBoss doesn't do this. Note: If you encounter this problem when you start the JBoss server from Eclipse: Error Occurred During Initialization of VM Java / Lang / NoclassDefounderror: Java / Lang / Object Generally encountered this problem, maybe because JRE is not set, please In the Preference dialog box in Eclipse, expand Java-> Installed Jres, check if JRE is set; then open the developed project properties dialog, see if there is JRE SYSTEM LIBRARY in Java Build Path, no words, click Add Library, add JRE SYSTEM LIBRARY. Third, using Eclipse development EJB In the second part "Using Eclipse Development Web Application", we have added a MYEJB to the EJB module in the TestJ2ee J2EE project. Below we add a session bean to the MyEJB module through Lomboz EJB CREATION WIZARD. Click File-> New-> Lomboz EJB CREATION WIZARD, or right-click the MyEJB module, select New-> Lomboz EJB CREATION WIZARD, show the following dialog: Create a named myejb in com.dino.testj2ee.myejb STATELESS session bean. After completion, under the SRC folder of the TestJ2ee project, a file called myejbbean.java appeared, right-click this file, select New-> Lomboz EJB Method Wizard, you can add various methods to this EJB. I added a HelloWorld method and returned a string type. As shown in the figure below: Then, you need to add myejb this session bean to the MYEJB of this module: Right-click Myejb.java, select Lomboz J2EE ... -> Add EJB To Module, select MyEJB, OK.
Right-click MyEJB module, select LombozJ2EE ... -> Generate EJB Classes, thus automatically generating the next few following ejbsrc file directory: MyEJBHome.java MyEJBRome.java MyEJBLocalHome.java MyEJBLocal.java MyEJBSession.java (MyEJBSession extends MyEJBBean) MyEJBUtil. After Java Build Project, the module is automatically packaged. Then you can deploy the EJB module according to the steps of deploying the web module. Finally, we build an app to test EJB. Open a dialog box through the File-> New-> Lomboz EJB Test Client Wizard, fill in the picture below: After completion, TestMyejb.java is generated below the src directory, add the test code in these TestBean methods: system.out.println (MyBean.HelloWorld (); if the JBoss server has been started, and the MYEJB module has been deployed, the testmyejb is executed on the Console window: Hehe, I can Deploy ejb by Eclipse! IV, summarize the above introduction We learned that Lomboz makes Eclipse development J2EE applications very simple, and Eclipse, Lomboz, JBoss tools are free and open source projects, so such a combination is more attractive to Java developers. For developing complex J2EE applications, the above introduction may not be comprehensive enough, I hope everyone will experience the process of doing the project, then summarize the experience to develop it in developerWorks.
Appendix: JBoss320.server
stopClass> org.jboss.Shutdown stopClass>
$ {classpathvariablename} /lib/xercesimpl.jar jar>
Add to Favorites]
Recommend to a friend] [Font:
Big
in
small】 【
shut down】
Copyright © 2003 - 2005 Javafan.Net All Rights Reserved