Eclipse & MyEclipse User Guide

Download as pdf or txt
Download as pdf or txt
You are on page 1of 120
At a glance
Powered by AI
The document outlines the steps to setup an enterprise project in MyEclipse IDE which includes creating and adding web and EJB project modules to the enterprise project. It also describes configuring JBoss and deploying applications to it. Finally, it provides recommendations for directory structure of enterprise projects.

The steps outlined are: 1) Create an enterprise project 2) Remove the default web module 3) Create and add a new web project module 4) Create and add an EJB project module 5) Setup the enterprise project 6) Add JAR files to the build path 7) Build the project

The steps outlined for configuring JBoss are: 1) Specify the JBoss JDK name 2) Specify the JBoss launch mode 3) Verify the JBoss configuration 4) Deploy MyEclipse projects by enabling the JBoss web loader and verifying deployment descriptors

Eclipse & MyEclipse User Guide

Victor Velazquez Santanu Roy Griselda Nunez Ritesh Kumar Alejandro Galvan Kelly Candler
Page 1 of 120

5 6

Setup Enterprise Project in MyEclipse IDE ................................................................................ 5 1.1 Create Enterprise Project........................................................................................................ 5 1.2 Remove and Delete Web Module ....................................................................................... 6 1.3 Create and Add Web Project Module in Enterprise Project..................................... 7 1.3.1 Change Web Root folder of Web Project............................................................... 7 1.3.2 Create Project Module.................................................................................................... 7 1.3.3 Add Web Project Module to Enterprise Project................................................... 8 1.4 Creation and Add EJB Project Module .............................................................................. 8 1.4.1 Create Project Module.................................................................................................... 8 1.4.2 Add EJB Project module to Enterprise Project .................................................... 9 1.5 Setup Enterprise Project.......................................................................................................... 9 1.6 Add JAR files in Build Path....................................................................................................10 1.7 Project Built.................................................................................................................................10 Configuring JBoss ..............................................................................................................................12 2.1 Specifying JBoss JDK Name ...............................................................................................12 2.2 Specifying JBoss Launch Mode .........................................................................................13 2.3 Verifying JBoss Configuration ............................................................................................14 2.3.1 Starting JBoss using MyEclipse ...............................................................................14 2.3.2 Stopping JBoss using MyEclipse .............................................................................15 2.3.3 Confirming JBoss Server Shutdown ......................................................................15 2.4 Deploying MyEclipse Projects ............................................................................................15 2.4.1 Enabling Jboss Web Loader......................................................................................15 2.4.2 Verify jboss-app.xml entries......................................................................................16 2.4.3 Verify entries of MANIFEST.MF files and application.xml file ......................16 2.4.4 Java Enterprise deployment setup........................................................................17 2.4.5 Deploy the application ................................................................................................20 2.4.6 Run jboss server..............................................................................................................23 2.4.7 Verify the deployment .................................................................................................23 Framework Sample Deployment ................................................................................................25 3.1 Creating MyEclipse Project using the Framework Sample v3.0..........................25 3.2 Importing/Copying Source files into Project................................................................26 3.2.1 Importing files into Enterprise Application Project..........................................26 3.2.2 Importing files into EJB Module Project................................................................27 3.2.3 Importing files into WEB Module Project .............................................................27 3.3 Setting the Build-path ............................................................................................................27 3.4 Building Project(s) .....................................................................................................................28 Database Explorer .............................................................................................................................29 4.1 Creating a Database Driver.................................................................................................29 4.2 Opening a Database Connection......................................................................................31 4.3 Working with the Database.................................................................................................32 Hibernate ...............................................................................................................................................33 5.1 Customizing the Hibernate Configuration File............................................................36 5.2 Create Hibernate Java Table Mapping...........................................................................36 Running and Debugging J2EE Application .............................................................................39 6.1 Debug Configuration Setup.................................................................................................39
Page 2 of 120

6.1.1 Debug Option...................................................................................................................39 6.1.2 Remote Java Application............................................................................................40 6.1.3 Create New configuration..........................................................................................40 6.1.4 Project Detail and Port .................................................................................................41 6.1.5 Display Debug in Favorites Menu...........................................................................41 6.2 Application Debugging ..........................................................................................................42 6.2.1 Set Break Points ..............................................................................................................42 6.2.2 Debug Perspective.........................................................................................................42 6.2.3 Server Launch Mode.....................................................................................................43 6.2.4 Launch the Application................................................................................................44 6.2.5 Execute Application Flow............................................................................................44 6.2.6 Move over the Brake Points.......................................................................................45 6.2.7 Check Value of variables.............................................................................................45 7 Junit..........................................................................................................................................................46 7.1 Creating the Junit directory Structure:...........................................................................46 7.2 Creating the Junit test class :..............................................................................................48 7.3 Running the test class............................................................................................................54 8 Using Visual SourceSafe with MyEclipse .................................................................................57 8.1 Share Project with VSS Repository ...................................................................................57 8.2 Latest Code from VSS Repository .....................................................................................61 8.3 How to view/edit the configuration settings or configured mappings? .........63 8.4 VSS Plugin preferences..........................................................................................................64 9 Connect an Existing Project with SVN.......................................................................................65 9.1 Checkout the Project ..............................................................................................................65 9.1.1 Checkout Enterprise Application Project .............................................................66 9.1.2 Checkout EJB Module...................................................................................................67 9.1.3 Checkout Web Module.................................................................................................68 9.1.4 Add Modules to Enterprise Application Project ................................................70 9.1.5 Add Jar Files in Build Path of EJB & Web Module ............................................70 9.2 Revert the Changes in web.xml & application.xml done by Eclipse IDE..........70 9.2.1 Revert the Changes of web.xml...............................................................................71 9.2.2 Revert the Changes of application.xml ................................................................72 9.3 Check Project Structure in Java Perspective ...............................................................74 10 Appendix ...........................................................................................................................................88 10.1 Installing and Configuring MyEclipse..............................................................................88 10.2 eRequest Process to get MyEclipse .................................................................................88 10.3 Personal Installation of Eclipse & MyEclipse................................................................89 10.3.1 Installation of Java ........................................................................................................89 10.3.2 Installation of Eclipse....................................................................................................89 10.3.3 Installation of MyEclipse .............................................................................................89 10.4 Importing/Copying Source files into Project.............................................................101 10.5 Add JAR files in Build Path of Application Module ..................................................104 10.6 Add and Remove Application Module from Enterprise Project ........................106 10.6.1 Add Application Module to Enterprise Project................................................106 10.6.2 Remove Application Module from Enterprise Project .................................107 10.7 JBoss Installation ..................................................................................................................108
Page 3 of 120

10.8 Ant Installation .......................................................................................................................109 10.9 VSS plugin prerequisites.....................................................................................................110 10.9.1 Getting access to VSS Database..........................................................................110 10.9.2 Get Installed a Microsoft VSS client.....................................................................110 10.9.3 Add VSS database to local client..........................................................................110 10.10 Installation of Subversive .............................................................................................111 10.10.1 Proxy Settings..........................................................................................................111 10.10.2 Installing Subversive .............................................................................................112 10.10.3 Update Site................................................................................................................112 10.10.4 Downloading Subversive ....................................................................................113 10.10.5 Installation.................................................................................................................114 10.10.6 SVN Repository........................................................................................................116 10.10.7 Add SVN Repository ..............................................................................................117 10.11 Set Up Project on Source Management Server ..................................................118 10.11.1 eRequest ....................................................................................................................118 10.11.2 Standard Enterprise Project Folder Structure ...........................................118 10.11.3 Rename the folders...............................................................................................118 10.11.4 Recommended Directory Contents ...............................................................119 10.11.5 Scenario I - Source code available on existing Source Code Management System....................................................................................................................119 10.11.6 Scenario II - Source code is not available on existing Source Code Management System....................................................................................................................119

Page 4 of 120

1 Setup Enterprise Project in MyEclipse IDE


If you havent installed MyEclipse, please follow MyEclipse Installation steps before the start this section.

1.1 Create Enterprise Project


Select File -> New -> Project and project type Enterprise Application Project.

Enter Project Name say myapp1, use default location, select Web Project Module and click next button.

Page 5 of 120

Check "Create Web Project Module" and create Enterprise Project with a web module.

1.2 Remove and Delete Web Module


Since there is limitation in MyEclipse 5.1 and earlier version, it does not allow creating enterprise project with any module. So we have created enterprise project with dummy web module and we will delete it. Remove the web module from enterprise project. Appendix Section 1.2. Delete myapp1Web module along with content.

Page 6 of 120

1.3 Create and Add Web Project Module in Enterprise Project


1.3.1 Change Web Root folder of Web Project Go to window preferences and change Web root folder name under MyEclipse-> J2EE Project -> Web Project from WebRoot to web.

1.3.2 Create Project Module Select File -> New -> Project and project type Web Project.

Enter Project name <Application Name>-war, uncheck "Use Default Location" and browse to web project folder. Rename "Web root folder" to web, Context root URL /<application name> and click Finish button.

Page 7 of 120

1.3.3 Add Web Project Module to Enterprise Project Add Web project module to enterprise project. Appendix Section 10.6

1.4 Creation and Add EJB Project Module


1.4.1 Create Project Module Select File -> New -> Project and project type EJB Project.

Enter Project name <Application Name>-ejb, uncheck "Use Default Location", browse to ejb project folder and click Finish button.

Page 8 of 120

1.4.2 Add EJB Project module to Enterprise Project Add EJB project module to enterprise Project. Appendix Section 1.1

1.5 Setup Enterprise Project


Take build.xml and build-properties.xml files from library location and copy into project folder e.g. myproject. Edit value of following properties in build-properties.xml :project.name application.name application.context framework.version path.eclipse.workspace path.jboss (Local machine) Go to project folder and execute local-setup task. E.g. >ant local-setup. local-setup task does following tasks: Create APP-INF/lib/framework folder in enterprise project and copy all released jar files of specified version of framework.

Page 9 of 120

Generate application.xml and copy under Meta-INF of enterprise project folder. Generate jboss-app.xml and copy under Meta-INF of enterprise project folder. Generate classes-move.xml and copy under enterprise project folder. Copy project specific third party jar file, if any, in APP-INF/lib/application and mention them as java module(s) in application.xml. Note:- Before executing ant task make sure ant is available to your machine. Please refer appendix section Ant Installation.

1.6 Add JAR files in Build Path


Add all dependent jar files in Project build files. Refer section Add JAR files in Build Path of Application Module

1.7 Project Built


Select all project module and rebuilt.

Page 10 of 120

Page 11 of 120

2 Configuring JBoss
This section explains all the steps to have Jboss running in MyEclipse IDE. If you dont have Jboss installed, follow these steps : Jboss Installation. Go to WindowsPreferencesMyEclipse Application Servers JBoss 4

Select Enable radio button Enter the Value of JBoss Home Directory: C:\jboss-4.0.3 Enter the value of server name: geam Enter Optional program arguments with your SSO id: -g 501275157

2.1 Specifying JBoss JDK Name


On this screen you select one of the previously configured JDK in MyEclipse.

Page 12 of 120

2.2 Specifying JBoss Launch Mode


On this screen, you can select whether you want to run jboss in debug/run mode. So make your selection and click Ok.

Page 13 of 120

2.3 Verifying JBoss Configuration


Once you are done with JBoss configuration, you should be able to see it in the configured application servers list (shown below).

2.3.1

Starting JBoss using MyEclipse

Clicking on the Start in the above shown screen will start the JBoss Server and we can see the messages of start-up process in the 'Console Window' of MyEclipse Message " [Server] JBoss (MX MicroKernel) [4.0.3SP1 (build: CVSTag=JBoss_4_0_3_SP1 date=200510231054)] Started in 17s:750ms in the Console window confirms we are able to run JBoss using MyEclipse IDE successfully.

Page 14 of 120

You can double-check this by opening up the JBoss console in the browser window. So you can try that by using the following URL:http://localhost:8080/jmx-console You should be able to see the JBoss console screen. If you are getting some errors and are not able to run it successfully, then please check the steps mentioned above and try again.

2.3.2

Stopping JBoss using MyEclipse

Clicking on Stop option will shutdown the JBoss server

2.3.3

Confirming JBoss Server Shutdown

To get confirmed that the server is shutdown, check the console you should be able to see Shutdown Complete message.

2.4 Deploying MyEclipse Projects


2.4.1 Enabling Jboss Web Loader

To avoid Tomcat Web Loader issues we will use the JBoss Web Loader. Go to {jboss-home}\server\geam\deploy\jbossweb-tomcat55.sar\META-INF and open file jboss-service.xml. Set UseJBossWebLoader to true <attribute name="UseJBossWebLoader">true</attribute>

Page 15 of 120

2.4.2

Verify jboss-app.xml entries

Open jboss-app.xml under framework3-sample/META-INF/ . Verify its entries. Here are the contents of the jboss-app.xml. <?xml version='1.0' encoding='UTF-8' ?> <!-- The JBoss 4.x specific elements for ears. $Id: jboss-app_4_0.dtd,v 1.4 2004/08/14 00:35:40 starksm Exp $ --> <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd"> <jboss-app> <loader-repository> com.geam:loader= framework3-sample.ear <loader-repository-config> java2ParentDelegation=true </loader-repository-config> </loader-repository> </jboss-app> Where framework3-sample.ear is the name of the application ear.

2.4.3

Verify entries of MANIFEST.MF files and application.xml file

Remove all the classpath entries from the framework3-sampleEJB/src/META-INF/ MANIFEST.MF. The file should look like Manifest-Version: 1.0 Created-By: 1.4.2_02 (Sun Microsystems Inc.) Similarly remove all the classpath entries from the framework3-sampleWeb/WebRoot/META-INF/MANIFEST.MF. The file should look like Manifest-Version: 1.0 Created-By: 1.4.2_02 (Sun Microsystems Inc.) All the jar files under the framework3-sample/APP-INF/lib /framework and framework3-sample/APP-INF/lib /application should be entered in the application.xml as java module.

Page 16 of 120

In the application.xml we should have .war extension to the Web-module (e.g. <web-uri> framework3-sampleWeb.war</web-uri>) and .jar to the EJB-module(e.g. <ejb> framework3-sampleEJB.jar</ejb>). Here are example entries for the application.xml for the framework3-sample project
<application> <display-name>Framework 3.0</display-name> <description>GEAM Framework v3.0 Test Application</description> <module> <web> <web-uri>framework3-sampleWeb.war</web-uri> <context-root>/framework3-sample</context-root> </web> </module> <module> <ejb>framework3-sampleEJB.jar</ejb> </module> <module> <java>APP-INF/lib/framework/chartfx.annotation-6.2.0000.jar</java> </module> <java> .... <module> <java>APP-INF/classes</java> </module> </application>

2.4.4

Java Enterprise deployment setup

We have to setup MyEclipse to ignore dependences in the deploy process. Go to Windows > Preferences > MyEclipse > Java Enterprise Project > WebProject > Deployment You should see a screen like this:

Page 17 of 120

Now we have to ignore dependent Java projects selecting the Ignore dependent Java projects (I will manually mange them) option and uncheck al the Library Deployment Policies checkboxes. After that we should see this configuration in the same screen.

Page 18 of 120

We have to do the same for Ear Project option:

And the EJB Project > Deployment option

Page 19 of 120

Click OK.

2.4.5

Deploy the application

Click on the 'Deploy J2EE Project to Server' icon as shown below.

We only need to deploy the application project i.e. " framework3-sample" in this case, it will deploy both the EJB Module Project and Web Module Project. From the drop down select the project framework3-sample and click on "ADD". Refer the screen below

Page 20 of 120

Select "JBoss 4" as server and Deploy Type as "Exploded Archive". Click Finish to start the deployment.

After the deployment you should verify Deployment Status as "Successfully deployed".

Page 21 of 120

Create a properties file: classes-move.properties with all these properties: <property name="jboss.home" value="D:/jboss-4.0.3"/> <property name="ear" value="xxx.ear"/> <property name="war" value="xxxWeb.war"/> <property name="jboss.config" value="geam"/> <property name="jboss.deploy" value="${jboss.home}/server/${jboss.config}/deploy"/> Run classes-move.xml Verify classes-move.xml under framework3-sample as below. <project name="classes-move" default="classes-move" basedir="."> <property file="classes-move.properties"/> <target name="classes-move" depends="clean"> <move todir="${jboss.deploy}/${ear}/APP-INF/classes"> <fileset dir="${jboss.deploy}/${ear}/${war}/WEB-INF/classes"/> </move> </target> <target name="clean"> <delete file="${jboss.deploy}/${ear}/APP-INF/lib/framework/hibernate-3.1.3.jar"/> <delete... </target> </project>

Page 22 of 120

Replace "jboss.home" property with the path of your JBoss Home Directory. Replace "ear" property with the name of your application ear. Replace "war" property with the name of your application war. Run classes-move.xml as shown below and verify "BUILD SUCCESSFUL" in the console.

2.4.6 Run jboss server Click on the Start as shown in below screen, you should be able to see the server starting message at the 'Console Window'.

2.4.7 Verify the deployment After the successful start up we can verify the deployment by accessing the application from the URL http://localhost:8080/framework3-sample, if JBoss server is running on port other then 8080, change the port in the URL. This should take us to the Home page of the application.

Page 23 of 120

This completes your application deployment in JBoss 4.0.3 using My Eclipse

Page 24 of 120

3 Framework Sample Deployment


Now we will see how to create/deploy the Framework sample version 3.0. The basic steps to setup an Enterprise Project will remain the same described earlier. Before we do this, download the framework at: http://libraries.ge.com/download?fileid=17102129101&entity_id=2325998101&sid=1 01 And extract the files at C:\framework3-sample See below the screen for downloading the Framework v3.0 sample application on you hard drive.

3.1 Creating MyEclipse Project using the Framework Sample v3.0


Lets create an Enterprise Project using the basic steps to setup an Enterprise Project, described earlier. Enter framework3-sample as Project Name, and follow all the steps to create the EJB module and WEB module described earlier. After you created the Enterprise Project with both modules, you should see a screen like this:

Page 25 of 120

Projects listed in the screen might differ on your machine, but basically you should be able to see 3 new projects created in this case. Names of those would be as below: framework3-sample: Enterprise Application Project framework3-sampleEJB: EJB Module Project framework3-sampleWeb: Web Module Project

3.2 Importing/Copying Source files into Project


Since now the project is created, we can copy/import our downloaded Framework sample application in this project and then build, deploy and verify it. 3.2.1 Importing files into Enterprise Application Project Follow these steps for importing source files into framework3-sample. In this section make sure that you check the following points: Correct folder name is selected in the From directory (source folder). Note here, since we need to import the contents of META-INF and APP-INF folders and these are under C:\framework3-sample\framework3-sample, so we have selected this path here. Select Checkboxes for APP-INF and META-INF folders in the left pane.

Page 26 of 120

Correct folder name is shown in the Into Folder textbox. By default it will be the same folder, which you selected before starting the import. So, you can change it here also, if you feel that it is not the correct one. Select folders APP-INF and META-INF from the folder list and select build.xml from the file list. Select the correct radio button option under Options section. 3.2.2 Importing files into EJB Module Project

Follow these steps for importing source files into framework3-sampleEJB. In this section make sure that you check the following points: Path selected in the From directory Select folders/files for importing. Into folder path, which comes same as the project/project-folder name, which you selected before starting this import. Since we only need source code for EJB therefore we have selected only the src folder here. You will see lot of errors in your Tasks window, but that is ok. Since the source files are referring to some .jar files, which are not in the project build path right now, so MyEclipse is showing these errors. We will take care of this, in the next steps. 3.2.3 Importing files into WEB Module Project

Follow these steps for importing source files into framework3-sampleWeb. In this section make sure that you check the following points: Path selected in the From directory Select folders/files for importing. Into folder path, which comes same as the project/project-folder name, which you selected before starting this import. Since we need source code for all java packages and everything under WebRoot folder therefore we have selected these two folders here.

3.3 Setting the Build-path


Now we will set the build-path for the project(s), so that we can build/deploy this project and test it. Follow the steps Add JAR files in Build Path of Application Module for both framework3-sampleEJB and framework3-sampleWeb.

Page 27 of 120

3.4 Building Project(s)


After the previous steps, you should be able to see the screen below, which shows that there is no error left in the project, just a warning for using a deprecated method, which is ok.

Now you are done with creating project(s) for Framework Sample version 3.0 in MyEclipse. You can deploy it on Jboss and test it. Follow the Deploying MyEclipse Projects steps to see running the Framework Sample running on Jboss.

Page 28 of 120

4 Database Explorer
This section explains how is the process for configuring and connecting the Database Explorer to an Oracle database. The first step is open the MyEclipse Database Explorer perspective.

4.1 Creating a Database Driver


Then, you should create a New Database Connection Driver for each Database Connection.

Page 29 of 120

In the DB Browser view menu, select New to create a new Database Driver.

Page 30 of 120

This will open the New Database Connection Driver wizard. Select a driver template and replace with the right configuration. The Connection URL is filled with the Database TNS: jdbc:oracle:thin:@(DESCRIPTION=(SDU=32767)(TDU=32767)(LOAD_BALANCE=ON)(FAIL OVER=ON)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=geamstunorc02t.geam. corporate.ge.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=geamstunorc03t.g eam.corporate.ge.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=GEOLDEV.GE AM.CORPORATE.GE.COM))) The Driver JAR for Oracle is ojdbc14-9.0.2.0.0.jar, you can find it at geamframework3.0\APP-INF\lib\framework. Click Finish.

4.2 Opening a Database Connection


Click the driver and select Open connection

The database connection will be opened and displayed in the Database Browser.

Now you can see something like this:

Page 31 of 120

4.3 Working with the Database


As you can see, you can browse the Database, the schemas, the tables and the data. You can create queries in the SQL Editor view and you see the results in the SQL Results view.

Page 32 of 120

5 Hibernate
This section follows the steps for getting started with Hibernate development using MyEclipse. The first thing you have to do to work with Hibernate in any project is adding Hibernate capabilities to it. Select the project you want to add Hibernate capabilities: MyEclipse > Add Hibernate Capabilities..

Now you can see the next window:

Page 33 of 120

Click Next.

Page 34 of 120

You can select an existing Hibernate config file or create a new one. With the Framework sample v3.o We can select the existing config file. Click Ok, then click Next and uncheck the Create SessionFactory Class option. Click Finish.

Page 35 of 120

5.1 Customizing the Hibernate Configuration File


Then MyEclipse shows the Hibernate config file:

You can change the Hibernate Database connection details or the properties or the Mappings files.

5.2 Create Hibernate Java Table Mapping


Step: 1 Open Database Connection

Page 36 of 120

Step: 2 Select the table in DB Browser and create Hibernate Mapping

Page 37 of 120

Sample Output

Page 38 of 120

6 Running and Debugging J2EE Application


This section explains how an enterprise application could be debug with help of Eclipse IDE.

6.1 Debug Configuration Setup


Steps to setup debug configuration. 6.1.1 Debug Option

Page 39 of 120

6.1.2

Remote Java Application

6.1.3

Create New configuration

Page 40 of 120

6.1.4 Project Detail and Port Name of new configuration, select project to debug and enter Host & Port.

6.1.5

Display Debug in Favorites Menu

Page 41 of 120

6.2 Application Debugging


6.2.1 Set Break Points

6.2.2 Debug Perspective Open Debug perspective to view application flow and value of variables at break points.

Page 42 of 120

6.2.3 Server Launch Mode Set JBoss launch mode debug mode.

Deploy the application and start the JBoss server.

Page 43 of 120

6.2.4

Launch the Application

6.2.5 Execute Application Flow Execute the application flow to be tested.

Page 44 of 120

6.2.6

Move over the Brake Points

6.2.7

Check Value of variables

Page 45 of 120

7 Junit

7.1 Creating the Junit directory Structure:


Select the Package Explorer preview from the Windows Show view package Explorer.

Now the test folder needs to be created where all required test files will be present. Right click on the project and select new source folder as shown in the screenshot. Name the folder as test this exposes the test folder to the compiler.

Page 46 of 120

Page 47 of 120

7.2 Creating the Junit test class :


Select the class for which the test case needs to be written. Right click on it select new junit TestCase as shown in the screen shot.

Page 48 of 120

Page 49 of 120

On the next window make sure Junit 3.8.1 is selected ,make sure the package structure is same as the testing class and select the checkbox setup and teardown as we are going to require that .

Click the button Browse next Source folder and select the source folder as the pre created test directory as shown in the Screen shot.

Page 50 of 120

Click ok, and so now it looks like .

Page 51 of 120

Click next and select the methods in the testing class, which we want to test. Refer screen shot below.

Page 52 of 120

And now the test class is created having the following directory structure.

Page 53 of 120

7.3

Running the test class

Write the code for testing with a sample test method for example. public void testUpdateAuthor() { System.out.println(Hello world test); } Now to run the test class, right click on the test class, select RunAs and then Junit Test as shown in the screen Shot.

Page 54 of 120

The test runs and on the left Junit pane it shows green or red depending on weather the test was Success or Failure . If it is red the Stack trace on the small window gives the cause of Failure.
Page 55 of 120

1.1 Failure stack Trace

Page 56 of 120

8 Using Visual SourceSafe with MyEclipse


Firstly, We have to follow some prerequisites-steps regarding VSS, to set out our environment, before we Can work with MyEclipse and VSS plugin.

8.1 Share Project with VSS Repository


You should set VSS databse for your project. We can do this by using the right click context menu on the MyEclipse project e.g. framework3-sampleWeb. Team -> Share Project, which brings up the select repository wizard dialog.

Page 57 of 120

Select VSS Configuration Wizard and Click Next

Page 58 of 120

Select the appropriate settings: Remote example:

Local example:

Username is the username used for authentication in the VSS database.

Page 59 of 120

Password is the corresponding password. VSS directory is the full absolute directory path to the VSS Database holding the srcsafe.ini file. Then add the first mapping. e.g. Z:\DBSoftware(for remote configuration) or \\GeamVss01\VSS\DBSoftware (for local configuration). Source dir is the MyEclipse project dir, which is the base dir for all operations. For example if you're Eclipse project uses /src as it's root directory for all source, you should select that directory for this setting. This must be a valid MyEclipse project directory path. Relative mount point is the VSS project (directory), which is the root of all operations in the VSS database. If the source code you are interested in lies in the VSS Project $/DBSoftware/WEB/Framework/Version 3.0/framework3sampleWeb use that directory as relative mount point. This must be a valid VSS project path. Click Next to see the screen below. This screen shows you the mapping between the local folders and VSS folders. Click Finish.

Page 60 of 120

8.2 Latest Code from VSS Repository


Since now you have configured the VSS with this project, once you right click that project in MyEclipse package explorer window, you will see a different options in the shortcut menu (shown below)

Page 61 of 120

Do team Refresh, always does a full Get Latest Version and then queries the VSS database for the status (checked out, existing, and so on..) for each file within the database. You use this each time you want the VSS Plugin to have the correct state for each file. It can be a time consuming since it has to query the database separately for each file. Get Latest Version, get the latest version from the VSS repository. Update Status, works like the Refresh but without the "Get Latest Version", which makes it faster lightweight operation. Check Out, checks out the file/files from the repository. If a writable copy exists of a file the user is prompted if the local copy should be replaced and any dirty open editor with the file should be reverted. Check In, checks the file/files with changes into the VSS repository. Undo Checkout, releases the file/files in the repository.

Page 62 of 120

Commit Changes - Tries to add all local files and check-in all files currently checked-out. The user is prompted for a selection of files to add. Easy to use for committing all changes made back to the VSS database. Synchronize with Repository - Brings up the platforms Synchronize view with a full diff of all local files with the files/folders in the VSS database. Add to VSS, adds a local files to the VSS database. Delete from VSS, deletes an existing file from the VSS database. It also removes the local copy. Deconfigure VSS, only available on the project root folder; remove the VSS Plug in from the project. After a configuration removal it might be necessary to close he project and reopen it for updating the view.

8.3 How to view/edit the configuration settings or configured mappings?


You have to use the properties in the context menu on the project root folder and select VSS Configuration.

Page 63 of 120

8.4 VSS Plugin preferences


You can set some preferences with the VSS plugin. Preferences are found under Window -> Preferences -> Team -> VSS.

Page 64 of 120

9 Connect an Existing Project with SVN


If project is not created in Subversion Source code Management repository, then please refer section 10.11 Set Up Project on Source Management Server.

9.1 Checkout the Project


If you havent installed Subversive follow the 10.10 Installation Subversive steps before start with this section. To Checkout a Project from the repository to your local workspace, and once opened the repository, right click on every module of and click con Find/Checkout As

Check the Check out as a project configured using the New Project Wizard radio and click on Finish

Page 65 of 120

9.1.1 Checkout Enterprise Application Project It will open the New Project Wizard, select the Enterprise Application Project and click on Next.

Write the name for your project and make sure that New web module project and New EJB module project are both uncheck and then click on Finish.

Page 66 of 120

It will share the project in your workspace, as you can see in your MyEclipse Java or Java perspective.

9.1.2 Checkout EJB Module Now we must do the same process to check out the other two modules. First, with the EJB module, Go to Find/Check Out As

Check the Check out as a project configured using the New Project Wizard radio and click on Finish.

Page 67 of 120

Select the EJB Project and click on Next.

Type the name to the EJB module and click on Finish. In this example it must be framework2.3 sampleEJB.

9.1.3 Checkout Web Module Now we do the same process to check out the Web module. Go to Find/Check Out As

Page 68 of 120

Check the Check out as a project configured using the New Project Wizard radio and click on Finish.

Select the Web Project and click on Next.

Page 69 of 120

Type the name to the Web module and click on Finish. In this example it must be framework2.3 sampleWeb.

9.1.4 Add Modules to Enterprise Application Project Now we need to add the EJB and Web modules to the application module, in order to do that please refer to Appendix Section 10.6 Add and Remove Application Module from Enterprise Project . 9.1.5 Add Jar Files in Build Path of EJB & Web Module Now, in your local copy, add the jar files in order to prevent from errors and Exceptions, please refer to Section 10.5 Add JAR files in Build Path of Application Module .

9.2 Revert the Changes in web.xml & application.xml done by Eclipse IDE
Once you have done, you should see something like this:

Page 70 of 120

9.2.1 Revert the Changes of web.xml Expand the WebRoot/WEB-INF folder inside the Web module; youll see the web.xml file. We must revert it in order to eliminate the MyEclipse changes to this file. Double click on it. You should see something like this:

Right click on it, go to Team and select Revert

Page 71 of 120

It shows you the next window, be sure that just the web.xml file is checked then click on OK.

Once done you must see how this file changes its content. 9.2.2 Revert the Changes of application.xml Expand the application project module and its META-INF folder, youll see the application.xml file, double click it and see it.

Page 72 of 120

As you saw, the application.xml file had changed to this.

You must revert the changes automatically done to the application.xml file, just like we did with the web.xml file.

Page 73 of 120

You should see how the files content come back to the last version.

9.3 Check Project Structure in Java Perspective

You will see the same project structure in both, the SVN Repository Perspective and the Java Perspective, but you can see in the Java Perspective youll see the project libraries were added.

9.4

Synchronizing the SVN Repository

When you are checking out or sharing a project and you are working in a Team, you must synchronize with the repository, in order to do this, right click on the enterprise application project of your local workspace, go to Team and select Synchronize with Repository. It will compare your local copy with the repository and show you all differences.

9.5

Adding new Packages and Classes in the Project

The way to create a new package and/or class is simple, you must mark the folder which in you want to create and right click, then new and select the package or class or whatever you want to create.

Lets create the com.commons.framework package inside the framework2.3 sampleWeb/src.


Page 74 of 120

NOTE: When you see the ? symbol in a file/folder, it means that it has changes saved only in your copy of the project, but in the repository, so you must first add it to version control and then commit. Now, in your Java Perspective right click on the new package, go to Team and select Add to Version Control.

It will show you the new files to add to version control, just click on OK.

Page 75 of 120

Now create a Testable interface inside this package with a single method, lets say String getName();.

Page 76 of 120

Once done, you must add it to version control too. And finally create two classes inside the same package, the NewTester class which implements the interface. Right click on the package, go to New and select Class.

Click on Add and it will show you and empty window, write the name of the interface you want to implement, select it and click on OK.

Page 77 of 120

Write the rest of the class code.

And add it to version control too. Now create the second class, lets say NewTester.

Page 78 of 120

With the next code:

And add it to version control too. Once you have done all your work, you can commit all your new classes with a right click on the src folder, go to Team and select Commit

The next screen will show you all the files to update in the repository, those which have been changed or added, write a comment of your changes or additions and click on OK.

Page 79 of 120

Now you can see in the SVN Repository Perspective that your new file is added in the repository.

9.6

Editing existing files in the Project

To edit an existing file just find it and double click it in your Java Perspective, it will be shown in the workbenchs center, there you can edit it. Once finished save the file and commit it, just like we did in the last section.

9.7

Deleting a File from Repository and Revert Back

NOTE: Its important to know that you must do all changes in your local copy, because if you want to revert any change before committing, you can do it, like we are going to see in this section. For this example lets delete the config.properties file under framework2.3 sampleWeb/src/resources. In order to do it select the file and right click on it, then select Delete option.

Page 80 of 120

It will prompt you to confirm the deletion. Clock on Yes

As we mentioned, this change just will happen in your personal copy until you commit. If we made a mistake and want to revert it, we must select the files parent folder and right click, go to Team and select Revert.

Page 81 of 120

It will show you all the recent deleted files, check all you want to come back and click on OK.

You will see how the previously deleted file comes back to your local copy.

9.8

If you had deleted or modified a file and you are sure the change is correct, you can then Commit, just like we did previously, and the changes will be done in the repository too.

Deleting a File from Repository and Commit

9.9

Once you have finished your work with the repository and you have saved and committed all changes, if you wont work with this project any more, then right click on the application module, go to Team and click on Disconnect

Disconnecting

Page 82 of 120

It will prompt you to confirm if you want to just disconnect or want to delete the connection files from your project. If you wont connect again to the project, you can check Also delete the SVN metainformation from the file system and click in OK.

Repeat this with every module in your project. Once you have done, you can delete the project from your workspace without risk to affect the repository.

9.10 Create and share a Project


Another common task is to create a new project in your local workspace and share it in the Repository. In order to do this we must first create the project, just like we did in the 1.1 Create Enterprise Project section. Lets suppose that we already have created the NewAppTest project in our local with some packages and classes, like we can see in the next screenshot.

Change to the SVN Repository Perspective and right click on the repository, go to New and select Folder.

Page 83 of 120

Write the folder name as your local project and click on OK. Now you can see the new folder in the repository. Go back to the Java Perspective. Right click to the application folder of your project and go to Team -> Share Project

Select the SVN repository type and click on Next.

Page 84 of 120

Check Use existing repository location: and be sure that the URL in the square below is your correct repository URL. Then click on Next.

Select the Use multiple projects layout with the specified root name: radio, make sure that in the next text field is written the name of the folder you created in the repository and uncheck the Use subversive recommended layout. Then click on Finish.

Page 85 of 120

It will show you the Commit window, look for all the MyEclipse special files, like .mymetadata or .myeclipse, and uncheck it. Then click in OK.

Repeat all this steps to share the EJB and the Web modules to the same folder in the repository. At the end, you must see in the repository something like this:

Page 86 of 120

Page 87 of 120

10 Appendix

10.1 Installing and Configuring MyEclipse


This section follow all the steps to get and install MyEclipse IDE. You do not have to install any software to run the MyEclipse 5.5 GA, for early versions, please review the requirements.

10.2 eRequest Process to get MyEclipse


THIS IS ONLY THOSE LOCATED IN GE ASSET MANAGEMENT, STAMFORD OFFICE. Raise E-Request to install Eclipse & MyEclipse to your desktop. E-Request is hosted on home page of GEAM Intranet website http://geam.home.ge.com/portal/site/corpam/.

Page 88 of 120

10.3 Personal Installation of Eclipse & MyEclipse


YOU MUST HAVE ADMINISTARTOR RIGHT OF LOCAL MACHINE. 10.3.1 Installation of Java 10.3.1.1 Check Available Java Check available JDK version on your machine. Go to command prompt and type java version.

Java version must be 1.4.2_XX, preferred 1.4.2_15. Note: - If Java version is other than 1.4.2 minor release, please uninstall available JDK and do fresh installation of Java. 10.3.1.2 Fresh Installation of Java Take available j2sdk-1_4_2_15-windows-i586-p.exe from GE Libraries and install. http://libraries.ge.com/download?fileid=19291060101&entity_id=2603839101&sid=1 01 10.3.1.3 Java Path Set bin path of installed JDK in PATH variable of System or User variable and check Java version once again. 10.3.2 Installation of Eclipse Take eclipse-SDK-3.2.2-win32.zip from GE libraries and unzipped in C: or D: drive. http://libraries.ge.com/download?fileid=19291321101&entity_id=2603839101&sid=1 01 10.3.3 Installation of MyEclipse Take MyEclipse_5.5.1GA_E3.2.2_Installer.zip from GE libraries. http://libraries.ge.com/download?fileid=19291451101&entity_id=2603839101&sid=1 01 10.3.3.1 Installation Execute Extract it in local drive. It contains MyEclipse_5.5.1GA_E3.2.2_Installer.exe and MyEclipse 5.5.1 GA Release Notes.pdf. Double click Installer Exe and follow the instruction.

Page 89 of 120

10.3.3.2 License Agreement Accept the license agreement, and click Next.

Page 90 of 120

10.3.3.3 Eclipse Folder Choose installed folder of Eclipse 3.2.2.

Page 91 of 120

10.3.3.4 MyEclipse Installed Folder By Default MyEclipse will installed under Programs Files. You could be installed any where in your local drive.

Page 92 of 120

Page 93 of 120

10.3.3.5 Shortcut Folder Choose Shortcut Folder: Select according your preferences.

Page 94 of 120

10.3.3.6 Pre-Installation Summary Review the Pre-Installation Summary before click on install button. You can get back to change some option.

Page 95 of 120

10.3.3.7 Release Note You could very well see release note.

Page 96 of 120

10.3.3.8 Installation Completion Confirmation Confirm successful completion of MyEclipse installation.

Page 97 of 120

10.3.3.9 Eclipse Workspace Set eclipse workspace. So all project created will in chosen workspace.

10.3.3.10 Entering the subscription code To have your MyEclipse installation done, you have to enter a subscription code. Go to Window > Preferences > MyEclipse > Subscription > Enter Subscription.

Page 98 of 120

10.3.3.11 Setting the standard JDK Check JDK version. So Eclipse automatically pick Java version from classpath.

10.3.3.12 Compiler Setting Select compliance level under compiler. It must be 1.4.

Page 99 of 120

Page 100 of 120

10.4 Importing/Copying Source files into Project


Follow these steps for the same: With-in Eclipse, select the Project/Project-folder in which the folders/files need to be imported. For example, if we would need to import the folders/files under our enterprise application project folder, so we will select the project name framework3sample. Select File->Import (OR right click on project name and select Import)

Click Next Depending upon the source of the files, select File System or Zip file or any other source, as shown in the next screen. In our case, it is File System, since the source files are in a directory on the hard drive. Click Next. Select the source folder for the files. After selecting the source folder, select the folders/files to be imported. On this screen, make sure of the following important points: Correct folder name is selected in the From directory (source folder). Note here, since we need to import the contents of META-INF and APP-INF folders and these are under C:\framework3-sample\framework3-sample, so we have selected this path here.

Page 101 of 120

Select Checkboxes for APP-INF and META-INF folders in the left pane. Correct folder name is shown in the Into Folder textbox. By default it will be the same folder, which you selected before starting the import. So, you can change it here also, if you feel that it is not the correct one. Select folders APP-INF and META-INF from the folder list and select build.xml from the file list. Select the correct radio button option under Options section.

Note:- Do not import any eclipse spesific file, vssver.scc and .file. Click Finish. Now it will start importing folders/files in your project and if you already have the files with the same name in your project, you will be prompted for overwriting them.

Page 102 of 120

Once you get the prompt for overwriting, make your selections accordingly. Here, we will select Yes to all. After all the selected folders/files are imported successfully; you will be able to see those folders/files into your project directory structure. See the screen below, showing the imported folders/files.

If you are not able to see the directory structure similar to this, then you need to delete the created folders/files and then try importing the files again into your project.

Page 103 of 120

10.5 Add JAR files in Build Path of Application Module


Select application module, right click and select menu option properties. Select Java Build Path and go to Libraries tab.

Click Add JARs button and navigate to APP-INF/lib/framework of current project. If there is any application specific jar files, put also in build path in same way.

Page 104 of 120

Page 105 of 120

10.6 Add and Remove Application Module from Enterprise Project


10.6.1 Add Application Module to Enterprise Project Select enterprise project folder in Package Explorer perspective and right click. Select MyEclipse -> Add and Remove Project Modules. Click Add button.

Select New Application Module and click Finish.

Page 106 of 120

10.6.2 Remove Application Module from Enterprise Project Select enterprise project folder in Package Explorer prospective and right click. Select MyEclipse -> Add and Remove Project Modules.

Select module to be removed from Current Module Projects and click remove button.

Page 107 of 120

10.7 JBoss Installation


First, make sure you have taken latest JBoss distribution: http://libraries.ge.com/foldersIndex.do?entity_id=2647616101&sid=101&ohr_id=5010 82932&sf=1&prod_id=0 Installation for JBoss is quite simple, since you just need to extract the JBoss .zip file on a hard drive folder and you are done.

Page 108 of 120

10.8 Ant Installation


Steps to install Ant. Take Ant zip from library and unzip directly C: or D: local drive. Add the bin directory to your path. Set the ANT_HOME environment variable to the directory where you installed Ant. Set the JAVA_HOME environment variable. This should be set to the directory where your JDK is installed.

Page 109 of 120

10.9 VSS plugin prerequisites


10.9.1 Getting access to VSS Database Before you can use VSS capabilities with MyEclipse you have to get access to VSS Databases, you can do this requesting access at erequest. http://erequest.geam.corporate.ge.com/erequest/eRequestHomeAction.do 10.9.2 Get Installed a Microsoft VSS client Also, you have to get installed a Microsoft VSS client. You can do this requesting access at erequest application. http://erequest.geam.corporate.ge.com/erequest/eRequestHomeAction.do 10.9.3 Add VSS database to local client

Following are the steps to add VSS database to local client. In windows explorer, click on Tools->Map Network Drive. Select some Drive: say Z and against Folder: give \\geamstvss01\vss, uncheck Reconnect at Logon box and click on Finish. A separate windows explorer screen will be opened. You can close that as we don't do anything in that window. Now launch VSS client on your machine. VSS login screen will be displayed. Provide user name and password. Click on Browse to provide the database. Another screen "Open Sourcesafe Database" will be displayed. Again click on Browse button. "Find database" screen will be displayed. Go back one level up and click on My Computer. You should see the drive Z you mapped earlier. Double click on that drive. All VSS databases will be displayed. Double click on your application folder. You should see sub-folders and files under that folder. Select srcsafe file and click on Open. Now you should be able to see that database added to your Sourcesafe Database screen. Click on the checkbox "open this database next time I run Visual sourcesafe" to check, so that next time you login into VSS client directly with out mapping geamstvss01. This is just a one time exercise.

Page 110 of 120

10.10 Installation of Subversive


The Subversive project aims to provide Subversion (SVN) integration for Eclipse. Polarion Org started the Subversive project and it became and Eclipse official project, so you can find more info about in both sites, the Polarion Official site and the Eclipse official site: http://www.polarion.org/index.php?page=overview&project=subversive http://www.eclipse.org/subversive Steps to install Subversive. 10.10.1 Proxy Settings First you need to check if your Proxy Settings are already configured, in order to do this, in you workbench, go to Window -> Preferences -> Internet ->Proxy Settings. Check the Enable Proxy checkbox and write you local Proxy Host and Proxy Port (Contact your local Network Administrator if you dont know this).

Page 111 of 120

10.10.2 Installing Subversive Once done, you can install Subversive. Go to Help -> Software Updates -> Find and Install It will show you this screen:

Check the Search for new features to install radio and click on Next. 10.10.3 Update Site

This screen will vary depending on the features you have installed already. You want to click on the New Remote Site button. Note: If you are behind a proxy and the Eclipse install mechanism does not work, then you can download a zipped version of the update site and then click the New Local Site button instead.

Page 112 of 120

10.10.4 Downloading Subversive In this screen you must write the correct NAME and URL of the site to download the installation, with Eclipse 3.2.2 and MyEclipse 5.5.1 GA you must write: NAME: Subversive 1.1.x URL: http://www.polarion.org/projects/subversive/download/1.1/update-site/

Then click en OK. It will show you the sites window, something like this:

Be sure that the only site checked is the one you have added: Subversive 1.1.x and click on Finish. In the next window expand all features and select SVN Team Provider 1.1.x.

Page 113 of 120

10.10.5 Installation Accept terms of license agreement and click on the Next > button.

Click on the Finish button in order to start the download of selected features.

Page 114 of 120

Click on the Install All button in order to confirm installation of downloaded features.

To apply installation changes and restart Eclipse click on the Yes button.

Page 115 of 120

10.10.6 SVN Repository Finally, after restarting Eclipse, the first thing you will typically want to do is open the SVN Repository perspective where you can define your repositories. Make sure that you have permissions to access it. It will show you this screen, select SVN Repository Exploring and OK.

Page 116 of 120

10.10.7

Add SVN Repository

Enter URL of your project location on SVN and click Finish button.

On the example in this guide we are using the repository: svn://geamstlxsvn01p.geam.corporate.ge.com/framework

Page 117 of 120

10.11 Set Up Project on Source Management Server


10.11.1 eRequest

Submit an eRequest for project setup on Source Code Management System. Provide following details: Asset Class Name Project Name Application Name Brief about project modules http://erequest.geam.corporate.ge.com 10.11.2 Standard Enterprise Project Folder Structure

Down load myproject.zip from library and unzip in at you local drive say under sourcecode_repository. http://libraries.ge.com/download?fileid=19531701101&entity_id=2603839101&sid=1 01

10.11.3 Rename the folders myproject: - Project Name. E.g. smart, pm-plm etc. myapp1: - Application Name. E.g. bank-recon, risk etc.

Page 118 of 120

10.11.4

Recommended Directory Contents


Directory Contents Base directory for applications. Contains the static content of the resulting WAR file. Contains the web.xml deployment descriptor and static configuration files such as struts-config.xml. May also include vendor-specific runtime deployment descriptors, such as applicationContext-hibernate.xml. The top-level test/ directory contains project-wide tests. Each individual module should also include a unit test, which should be placed in the src/test directory for each module.

Directory Name apps web web/WEB-INF test

10.11.5 Scenario I - Source code available on existing Source Code Management System. Take latest version of source code of web and/or ejb module from existing Source code management system i.e Visual Source Safe (VSS) in respective folders by using VSS client. Search "vssver.scc" file in apps folder and delete them. 10.11.6 Scenario II - Source code is not available on existing Source Code Management System. Take latest source code of web and/or ejb module from shared folder, ftp server, local machine etc and copy into respective folder.

Page 119 of 120

Map and add local folder myproject to new Source Management Management System with help of respective source management client.

Don't import following file or folder into source code management system. Class files. Eclipse specific folders and files. Enterprise project folder and files. Unwanted files. E.g. vssver.scc, test.sql etc.

Page 120 of 120

You might also like