Topic: Eclipse IDE for J2EE 1.3 Development(Tomcat 4.x, JBoss 3.x, MySQL 3.x) |
Print this page |
1.Eclipse IDE for J2EE 1.3 Development(Tomcat 4.x, JBoss 3.x, MySQL 3.x) | Copy to clipboard |
Posted by: dany Posted on: 2003-02-01 08:59 Eclipse IDE for J2EE 1.3 Development (Tomcat 4.x, JBoss 3.x, MySQL 3.x) by Hao Wu Last modified: 04/18/2002 Purpose This article covers setting up the following Open Source tools for J2EE 1.3 development. - Tomcat 4.x for Servlet 2.3 and JSP 1.2 - JBoss 3.x for EJB 2.0, JMS 1.1, JCA 1.0, and JAXP 1.1 - MySQL 3.x for RDBMS Persistence - Eclipse for Java IDE * These instructions assume Windows platform. Linux needs slightly different URLs & similar steps. * Following the order herein is recommended. Coming Soon... This documentation will get diligent update, catching up with latest builds of the tools. So please come back for updates. - ANT integration with Eclipse. - Code examples. - XDoclet integration into Eclipse for EJB development. Revision History - 4/18, added "Upgrade" entry for each section. JBoss 3.0.0, Release Candidate 1. Eclipse Milestone 5 (build 20020416). Sysdeo version 0.96 and Genuitec version 1.0EA4 (for Eclipse M5). - 4/02, (minor) Tomcat, version 4.0.4 beta 2. Sysdeo plugin, version 095. - 3/23, (minor) Eclipse, updated with build 20020321. - 3/20, JBoss 3.0.0, added Beta2 self-build notes - 3/15, (minor) Eclipse, build 20020214 notes for working with EJB. - 3/15, MySQL added, and its integration with JBoss. - 3/13, (minor) JBoss, disabling clustering. - 3/11, J2EE 1.3 with Eclipse (JBoss added). - 2/20, JSP/Servlet with Eclipse and Tomcat. Quick Reference Software (Click for details) Current Version Vendor J2EE Installation JDK 1.4.0 Sun J2SE 1.4 Install Tomcat (Open Source) 4.0.4 Beta 2 Apache J2EE 1.3 (Servlet 2.3, JSP 1.2, etc.) Unzip JBoss (Oepn Source) 3.0.0 Release Candidate 1 JBoss Group J2EE 1.3 (EJB 2.0, JMS 1.1, JCA 1.0, JAXP 1.1, etc.) Unzip or Build MySQL (Open Source) 3.23.49 MySQL AB RDBMS Install Eclipse (Open Source) 2.0, pre-release build 20020321 Eclipse Java IDE Unzip Eclipse Tomcat Plugin 0.96 Sysdeo (France) IDE Plugin Unzip Eclipse JBoss Plugin 1.0EA4 Genuitec IDE Plugin Unzip Installing JDK Version 1.4.0 Download Get binary j2sdk-1_4_0-win.exe at http://java.sun.com/j2se/1.4/download.html * Be sure to download the SDK, not just the JRE. Documentation - Online - http://java.sun.com/j2se/1.4/docs/index.html - Downloadable - http://java.sun.com/j2se/1.4/download.html Install Run the executable which will install the following: * Java 2 SDK, SE v1.4.0 * Java 2 Runtime Environment, SE v1.4.0 * Java Plug-in 1.4.0 * Java Web Start (1.0.1) Environment Set variable JAVA_HOME to <install dir> (e.g. C:\jdk1.4). Make sure <install dir>\bin is in your PATH (e.g. C:\jdk1.4\bin). Test Open a DOS windows, try java -version and you should get: java version "1.4.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92) Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode) Installing Tomcat Version 4.0.4 Beta 2 Download Get zip binary at http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v4.0.4-b2/bin/jakarta-tomcat-4.0.4-b2-01.zip (General download at http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release .) * Also available is an Install version, which can run as Windows service. Not recommeded for development. Documentation - Online - http://jakarta.apache.org/tomcat/tomcat-4.0-doc/index.html - Local - (after installation) at %TOMCAT_HOME%\webapps\tomcat-docs\index.html (Also accessible at http://localhost:8080/tomcat-docs/index.html, if Tomcat is started on port 8080) Upgrade from Previous Version - Rename your previous installation (say C:\jakarta-tomcat-4.0.2 to C:\jakarta-tomcat-4.0.2_old). And remove it after you get the new version up for a while. - After the installation, copy the old server.xml (or preferrably, just the context you added) to the new. - After the installation, go over other Tomcat related sections and check for applicable changes. Install Unzip to destination (say C:\, which makes <install dir> to be C:\jakarta-tomcat-4.0.4-b2-01). Environment Set variable TOMCAT_HOME to <install dir> (e.g. C:\jakarta-tomcat-4.0.4-b2-01). Test "cd %TOMCAT_HOME%\bin" and "startup" (startup.bat), you should see --- Starting service Tomcat-Standalone Apache Tomcat/4.0.4-b2 Starting service Tomcat-Apache Apache Tomcat/4.0.4-b2 Now that Tomcat is up, access http://localhost:8080 from your browser. Other o Installing Sysdeo Eclipse Tomcat Launcher Plugin (refer to the later section) o Integrating Tomcat with JBoss (refer to the later section) Installing JBoss Version 3.0.0 Release Candidate 1 (soon will add a seperate section on building 3.1.0 Alpha by yourself) Download Get zip binary from SourceForge at http://prdownloads.sourceforge.net/jboss/jboss-3.0.0RC1.zip (General download at http://sourceforge.net/project/showfiles.php?group_id=22866.) * Also available is a Tomcat-integrated version at http://prdownloads.sourceforge.net/jboss/jboss-3.0.0RC1_tomcat-4.0.3.zip. We prefer having seperated Tomcat instead of the integrated version, especially for development, for the following reasons: 1. Debugging web application is harder - need to do build into .ear instead of using Tomcat server.xml to point to code. 2. Encountered class loader problem from Tomcat to integrate with JBoss. Documentation - Free online manual (somewhat outdated): http://www.jboss.org/online-manual/HTML/index.html - JBoss documentation site: http://www.jboss.org/doco.jsp. Upgrade from Previous Version - Rename your previous installation (say C:\jboss-3.0.0beta2 to C:\jboss-3.0.0beta2_old). And remove it after you get the new version up for a while. - After the installation, go over other JBoss related sections and check for applicable changes. Install Unzip to destination (say C:\, which makes <install dir> to be C:\jboss-3.0.0RC1). Environment Set variable JBOSS_DIST to <install dir> (e.g. C:\jboss-3.0.0RC1). Test Make sure you don't have TOMCAT running, as it would conflict with JBoss over port 8080. (Integration is covered in a later section.) "cd %JBOSS_DIST%\bin" and "run" (run.bat), you should see console output and eventually --- 14:44:35,075 INFO [Server] JBoss (MX MicroKernel) [3.0.0RC1 Date:200204150356] Started in 0m:22s:383ms Check console or logfile (%JBOSS_DIST%\server\default\log\server.log), you should only see "INFO", "WARN" or "DEBUG" outputs. Try http://localhost:8080, you should see Tomcat document and example - this is served through the embedded Jetty JSP/Servlet container (not Tomcat). Also, try http://localhost:8082, you should see the JMX management console. Other o Disable clustering: If you might ever run JBoss on your machine without a network, you want to do this. - Create a subfolder %JBOSS_DIST\server\default\deployBackup. - Move file %JBOSS_DIST%\server\default\deploy\cluster-service.xml away into %JBOSS_DIST%\server\default\deployBackup. Installing Genuitec Eclipse JBoss Plugin (see below) Integrating Tomcat with JBoss (see below) Integrating JBoss with MySQL (see below) Version 3.1.0 Alpha, self-build (or see a previous section for downloading 3.0.0 RC1) Coming soon... Installing MySQL Version 3.23.49 Download Get zip binary at http://mirror.sit.wisc.edu/mysql/Downloads/MySQL-3.23/mysql-3.23.49-win.zip (General download at http://www.mysql.com/downloads/mysql.html.) * 4.0 is still in Alpha as of 3/14/2002, so 3.23 is recommended for the time being. Documentation - Local: (after installation) <install dir>\Docs\manual_toc.html - Online documentation: http://www.mysql.com/documentation/index.html Upgrade from Previous Version Coming soon... Install - Unzip to a temp dir (e.g., C:\Temp\mysql_install) - Run setup.exe to install. (e.g., into C:\mysql3.23) * The installation does not create Program Folder. Following recommend: (1) Create a Program Folder "MySQL 3.23" (2) Create shortcut for: <install dir>\bin\winmysqladmin.exe <install dir>\bin\MySqlManager.exe Environment Add <install dir> to PATH (e.g. C:\mysql3.23). Setup (Also to enable InnoDB) - Run winmysqladmin.exe (under bin subfolder): 1. First time (when my.ini does not exist under Windows directory, e.g. C:\WinNT), you will be prompted for username/password. Enter your choice (e.g. mysqladmin/mysqladmin). 2. Its window will come up and then minimize into System Tray. Bring it up by: Right click on System Tray icon -> Option "Show me". 3. By default, "mysqld" is used which has only ISAM, which does NOT support transaction. To use "mysqld-max" with InnoDB or BDB enabled (supporting transactions), configure my.ini as following: Select tab "my.ini Setup" -> Select "mysqld-max" -> In editor for my.ini: [mysqld] ... [WinMySQLadmin] ... Add the following before line "[WinMySQLadmin]", be sure to customize at least the underlined fields: innodb_data_home_dir = C:\mysql3.23\ibdata innodb_data_file_path = ibdata1:500M;ibdata2:500M set-variable = innodb_buffer_pool_size=70M set-variable = innodb_additional_mem_pool_size=10M innodb_log_group_home_dir = C:\mysql3.23\iblogs innodb_log_arch_dir = C:\mysql3.23\iblogs innodb_log_archive=0 set-variable = innodb_log_files_in_group=3 set-variable = innodb_log_file_size=10M set-variable = innodb_log_buffer_size=8M innodb_flush_log_at_trx_commit=1 set-variable = innodb_file_io_threads=4 set-variable = innodb_lock_wait_timeout=50 * The above specifies that two 500MB database files be created at C:\mysql3.23\ibdata, and three 10MB log files created at C:\mysql3.23\iblogs. Then click "Save Modification" to save the changes into my.ini (under e.g. C:\WinNT). 4. Manually create the folder <ibdata location> and <iblogs location> (in the above example, it's C:\mysql3.23\ibdata and C:\mysql3.23\iblogs). 5. Start the server ("mysql" service): Right click on the window -> Option "Win NT" -> item "Install the service" Then Right click again -> Option "Win NT" -> item "Start the service". It will take a moment to create the database files and log files as configured. Test 1. Make sure service "Mysql" is started. 2. Try to login. - Open a Command window, try "mysql -u <username> -p". You'll be prompted for password (use the one you specified in my.ini, e.g. mysqladmin/mysqladmin). - You are in mysql console. Try SQL "SELECT user();" or "SELECT 1+1;". (Be sure to end your SQL with semicolon.) 3. Add a user - username "developer", and password "mysql". (Will use for EJB development.) In mysql console, enter SQL - GRANT ALL PRIVILEGES ON test.* TO developer@localhost IDENTIFIED BY 'mysql'; 4. Login to database "test" as user "developer": - In DOS, enter "mysql -u developer -p test" (Note: test here is the database name, NOT the password. Password will be prompted.) - After giving password, you should be in test as developer: - Try "SELECT user();" and you should get "developer@localhost". - Try creating a table and put some data: CREATE TABLE table1 (id INTEGER NOT NULL, data VARCHAR(100),PRIMARY KEY (id)) type=InnoDB; INSERT INTO table1 (id, data) VALUES (1, 'one'); INSERT INTO table1 (id, data) VALUES (2, 'two'); INSERT INTO table1 (id, data) VALUES (3, 'three'); SELECT * FROM table1; Note: * The default CREATE TABLE creates table as type ISAM, which does not support transaction. Include clause "type=InnoDB" in your CREATE TABLE statement as the above, then your table will have transaction support. * By default, AUTOCOMMIT is on. To turn it off, do "SET AUTOCOMMIT=0;". Other Integrating JBoss with MySQL (see below) Installing Eclipse Version 2.0, Milestone 5 (pre-release, build 20020416). Download Get zip binary at http://64.38.198.171/downloads/drops/S-M5-200204161340/download.php?dropFile=eclipse-SDK-20020416-win32.zip (General download at http://www.eclipse.org/downloads/index.php) Documentation - Eclipse FAQ: http://www.eclipse.org/eclipse/faq/eclipse-faq.html - Documentation site: http://www.eclipse.org/eclipse/index.html (Currently only 1.0 docs) - Searching News/Mailing archive: http://www.eclipse.org/search/search.cgi Upgrade from Previous Version - Rename your previous installation (say C:\eclipse to C:\eclipse_old). And remove it after you get the new version up for a while. - After the installation, copy your workspace over (from C:\eclipse_old\workspace\ to C:\eclipse\workspace). - After the installation, go over other Eclipse related sections and check for applicable changes. Install Unzip to destination (say C:\, which makes <install dir> to be C:\eclipse). Test - You should have a JDK installed (if you use Sun JDK, 1.4.0 is recommended for hot code replacement support). - Start Eclipse and it would detect the JDK (through %JAVA_HOME%) - You can also manually specify VM (option -vm <javaw.exe location>) - Specify workspace location if don't want the default (option -data <workspace location) - Recommended settings on Perspective: Menu "Workbench" -> Item "Preferences" -> Option Workbench -> "Open a new perspective" -> Select "In the same window" -> uncheck "Reuse Perspective with same input" Other Tomcat Plugin for Eclipse (see below) JBoss Plugin for Eclipse (see below) Installing Sysdeo Eclipse Tomcat Launcher Plugin Version 0.96 Download Get binary tomcatPluginV096.zip at http://www.sysdeo.com/eclipse/tomcatPluginV096.zip (General page at http://www.sysdeo.com/eclipse/tomcatPlugin.html .) Documentation Online instruction: http://www.sysdeo.com/eclipse/tomcatPlugin.html Upgrade from Previous Version - If you did NOT just install a new version of Eclipse, remove the old plugin directory (for example, C:\eclipse\plugins\com.sysdeo.eclipse.tomcat\) Install Unzip to <Eclipse install dir>\plugins (the plugin will reside under <Eclipse install dir>\plugins\com.sysdeo.eclipse.tomcat). Configure Eclipse 1. Start Eclipse. 2. Configure Tomcat plugin. Menu "Workbench" -> Item "Preferences" -> Option "Tomcat" -> "Tomcat version", select "4.x" -> "Tomcat home", specify <Tomcat install dir> -> Under Option "Tomcat", suboption "JVM Settings" -> "Classpath", add the Jar/Zip for tools.jar. (If you use JDK 1.4 at C:\jdk1.4, it is "C:\jdk1.4\lib\tools.jar"). This is for compiling JSP. 3. Set classpath variable TOMCAT_HOME for project classpath reference. Menu "Workbench" -> Item "Preferences" -> option "Java" -> option "Classpath Variables" -> New variable, name "TOMCAT_HOME", value <TOMCAT install dir> (Then in .classpath of your project, you use TOMCAT_HOME for variable references.) 4. Make sure Tomcat menu accessible. Set to "Java" perspective, and make sure Tomcat menu and its 3 toolbar buttons are available. (If not, Menu Perspective -> Item "Customize" -> option "Other" -> option "Tomcat", check it.) 5. Use menu or toolbar to Start/Stop Tomcat (The plugin will start/stop Tomcat as a debugging mode VM inside Eclipse, so debugging into Servlets and JSP-generated-Servlets becomes possible.) Note: For your Eclipse project, .classpath needs this to compile Servlets: <classpathentry kind="var" path="TOMCAT_HOME/lib/jasper-runtime.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/common/lib/servlet.jar"/> Installing Genuitec Eclipse JBoss Plugin Version 1.0EA4 Download Get zip binary http://www.genuitec.com/products/EASIEJBoss1.0ea4.zip (General page at http://www.genuitec.com/products.htm#easie.) Documentation Online instruction (PDF): http://www.genuitec.com/products/Eclipse_JBoss.pdf Upgrade from Previous Version - If you did NOT just install a new version of Eclipse, remove the old plugin directory (for example, C:\eclipse\plugins\com.genuitec.eclipse.easie.core\ and C:\eclipse\plugins\com.genuitec.eclipse.easie.jboss\) Install Unzip to <Eclipse install dir> (the plugin will reside under <Eclipse install dir>\plugins as subfolder com.genuitec.eclipse.easie.core and com.genuitec.eclipse.easie.jboss. Configure Eclipse 1. Start Eclipse. 2. Configure JBoss plugin. Menu "Workbench" -> Item "Preferences" -> Option "JBoss": * "JBoss Home Directory": <JBOSS install dir> (e.g. C:\jboss-3.0.0RC1) * "XML Document Builder Factory Class": org.apache.crimson.jaxp.DocumentBuilderFactoryImpl * "SAX Parser Factory Class": "org.apache.crimson.jaxp.SAXParserFactoryImpl" * "Optional Java VM Arguments": "-Djboss.boot.loader.name=run.bat" * "Optional Program Arguments": "-c default" 3. Make sure JBoss menu accessible. Set to "Java" perspective, and make sure JBoss menu and its 2 toolbar buttons are available. If not, Menu "Perspective" -> Item "Customize" -> option "Other" -> option "EASIE JBoss", check it. 4. Use menu or toolbar to Start/Stop JBoss (The plugin will start/stop JBoss as a debugging mode VM inside Eclipse, so debugging into EJBs becomes possible.) Integrating Tomcat with JBoss Version Tomcat 4.x and JBoss 3.x Configure JBoss JBoss 3.0.0 comes with Jetty Servlet Engine enabled running at port 8080 as default. If you want Tomcat to run on port 8080, they will conflict. To disable Jetty in JBoss: 1. Create a backup folder next to subfolder deploy\ (e.g. %JBOSS_DIST%\server\default\deployBackup.) 2. Move file jetty-plugin.sar from deploy\ into deployBackup\ (making it absent from the deploy\ folder) Configure Tomcat 1. Add JBoss client library to Tomcat: Copy the following from %JBOSS_DIST%\client into %TOMCAT_HOME%\common\lib: jboss-j2ee.jar, jboss-client.jar, jbosssx-client.jar, jnp-client.jar, jboss-common-client.jar and log4j.jar. When Tomcat starts up, these .jar would be added to its classpath. If you ever run into others that you need, just copy from %JBOSS_DIST%\client folder. 2. Specify JNDI properties to Tomcat JVM (you probably want to do both). o Tomcat in OS (outside Eclipse): Change %TOMCAT_HOME%\bin\setclasspath.bat (backing up the original is recommended), the line with JAVA_OPTS (following is one line): set JAVA_OPTS=-Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=localhost:1099 -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces o Tomcat inside Eclipse: Menu "Workbench" -> Item "Preference" -> option "Tomcat" -> suboption "JVM Settings" -> "Append to JVM Parameters", add the following three JVM parameters (each line is a seperate parameter): -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=localhost:1099 -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces Note: 1. Your application EJB's client classes need to be accessible to the Web application, at preferrably WEB-INF\lib (or WEB-INF\classes). 2. For your Eclipse application, project .classpath need to include the following to compile EJB client calls: <classpathentry kind="var" path="TOMCAT_HOME/common/lib/jboss-j2ee.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/common/lib/jboss-client.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/common/lib/jbosssx-client.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/common/lib/jnp-client.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/common/lib/jboss-common-client.jar"/> <classpathentry kind="var" path="TOMCAT_HOME/common/lib/log4j.jar"/> Integrating JBoss with MySQL Version JBoss 3.x and MySQL 3.x Configure MySQL 1. Be sure your MySQL is using mysqld-max which supports InnoDB (or BDB) for transaction. You tables also need to have "type=InnoDB" (or BDB). - To check, do "SHOW TABLE STATUS LIKE '<table name>';". - To modify, do "ALTER TABLE <table name> TYPE=InnoDB;". 2. Download MySQL JDBC driver (2.0.4) at http://mirror.sit.wisc.edu/mysql/Downloads/Contrib/mm.mysql-2.0.4-bin.jar Download page: http://www.mysql.com/downloads/api-jdbc.html. Configure JBoss 1. Put the JDBC driver into JBoss library: Copy downloaded mm.mysql-2.0.4-bin.jar to folder %JBOSS_DIST%\lib\. 2. Deploy MySQL into JBoss, by adding file mysql-service.xml into folder %JBOSS_DIST%\server\default\deploy\. A template could be found at http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/jbosscx/src/etc/example-config/mysql-service.xml?rev=1.4&content-type=text/vnd.viewcvs-markup. Customization (example, use whatever values applies to you): 1. "MySqlDB" (if you don't change it) is your data source name and the JNDI name. 2. Change "jdbc:mysql://dell:3306/jbossdb" into the URL or your database (for example, database "test" on local host should be jdbc:mysql://localhost:3306/test.) 3. Read the comments toward the end of the file and follow the instruction to copy the following section into login-config.xml (under %JBOSS_DIST%\server\default\conf\): <application-policy name = "MySqlDbRealm"> <authentication> <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required"> <module-option name = "principal">yourprincipaldule-option> <module-option name = "userName">yourusernamedule-option> <module-option name = "password">yourpassworddule-option> <module-option name = "managedConnectionFactoryName"> jboss.jca:service=LocalTxCM,name=MySqlDSdule-option> gin-module> thentication> plication-policy> 4. In login-config.xml, modify the section you pasted from the above step. Change "yourprincipal" into "developer" (value of Principle), "yourusername" into "developer" (value of Username), "yourpassword" into "mysql" (value of Password). Make sure "MySqlDS" is your data source name or change it accordingly. Copyright © 2002 Purpose Solutions, Inc. All Rights Reserved |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |