The WebSphere Development Tools (WDT) for Eclipse can be used to control the server (start/stop/dump/etc.), it also supports incremental publishing with minimal restarts, working with a debugger to step through your applications, etc.
WDT also provides:
- content-assist for server configuration (a nice to have: server configuration is minimal, but the tools can help you find what you need and identify finger-checks, etc.)
- automatic incremental publish of applications so that you can write and test your changes locally without having to go through a build/publish cycle or restart the server (which is not that big a deal given the server restarts lickety-split, but less is more!).
Installing WDT on Eclipse is as simple as a drag-and-drop, but the process is explained [on wasdev.net] wasdev-wdt.
If the sample git repository hasn't been cloned yet, WDT has git tools integrated into the IDE:
- Open the Git repositories view
- Window -> Show View -> Other
- Type "git" in the filter box, and select Git Repositories
- Copy Git repo url by finding the textbox under "HTTPS clone URL" at the top of this page, and select Copy to clipboard
- In the Git repositories view, select the hyperlink
Clone a Git repository
- The git repo url should already be filled in. Select Next -> Next -> Finish
- The "sample.daytrader7 [master]" repo should appear in the view
This sample can be built using either Gradle or Maven.
#building-with-gradle
Building with Gradle
This assumes you have the Gradle Buildship tools installed into Eclipse Mars.
- In the Git Repository view, expand the daytrader7 repo to see the "Working Directory" folder
- Right-click on this folder, and select Copy path to Clipboard
- Select menu File -> Import -> Gradle -> Gradle Project
- In the Project root directory folder textbox, Paste in the repository directory.
- Click Next twice
- Five projects should be listed in the Gradle project structure click Finish
- This will create 5 projects in Eclipse: sample.daytrader7, daytrader-ee7, daytrader-ee7-ejb, daytrader-ee7-web, daytrader-ee7-wlpcfg
- Go to the Gradle Tasks view in Eclipse and navigate to the sample.daytrader7 project
- Double click on the eclipse task to generate all the Eclipse files
- In the Enterprise Explorer view in Eclipse right click on the five projects mentioned in step 7 and click refresh
⭐ Note: If you did not use Eclipse/WDT to clone the git repository, follow from step 3, but navigate to the cloned repository directory rather than pasting its name in step 4.
- Go to the Gradle Tasks view in Eclipse and navigate to the sample.daytrader7 project
- Double click: build
#building-with-maven
Building with Maven
- In the Git Repository view, expand the daytrader7 repo to see the "Working Directory" folder
- Right-click on this folder, and select Copy path to Clipboard
- Select menu File -> Import -> Maven -> Existing Maven Projects
- In the Root Directory textbox, Paste in the repository directory.
- Select Browse... button and select Finish (confirm it finds 5 pom.xml files)
- This will create 5 projects in Eclipse: sample.daytrader7, daytrader-ee7, daytrader-ee7-ejb, daytrader-ee7-web, daytrader-ee7-wlpcfg
⭐ Note: If you did not use Eclipse/WDT to clone the git repository, follow from step 3, but navigate to the cloned repository directory rather than pasting its name in step 4.
- Right-click on sample.daytrader7/pom.xml
- Run As > Maven build...
- In the Goals section enter "install"
- Click Run
Pre-requisite: Download WAS Liberty
For the purposes of this sample, we will create the Liberty server (step 3 in the wasdev.net instructions) a little differently to create and customize a Runtime Environment that will allow the server to directly use the configuration in the daytrader-ee7-wlpcfg
project.
- Open the 'Runtime Explorer' view:
- Window -> Show View -> Other
- type
runtime
in the filter box to find the view (it's under the Server heading).
- Right-click in the view, and select New -> Runtime Environment
- Give the Runtime environment a name, e.g.
wlp-2015.6.0.0
if you're using the June 2015 beta. - Either:
- Select an existing installation (perhaps what you downloaded earlier, if you followed those instructions), or
- select Install from an archive or a repository to download a new Liberty archive.
- Choose an option with Java EE7 Full Platform.
- Follow the prompts (and possibly choose additional features to install) until you Finish creating the Runtime Environment
- Right-click on the Runtime Environment created above in the 'Runtime Explorer' view, and select Edit
- Click the
Advanced Options...
link - If the
daytrader-ee7-wlpcfg
directory is not listed as a User Directory, we need to add it:- Click New
- Select the
daytrader-ee7-wlpcfg
project - Select Finish, OK, Finish
- Right-click on the
daytrader-ee7-wlpcfg
user directory listed under the target Runtime Environment in the Runtime Explorer view, and select New Server. - The resulting dialog should be pre-populated with the
daytrader7Sample
Liberty profile server. The default name for this server can vary, you might also opt to rename it from the Right-click menu in the Servers view to make it easier to identify. - Click Finish
The built ear file is copied into the apps directory of the server configuration located in the daytrader-ee7-wlpcfg directory:
daytrader-ee7-wlpcfg
+- servers
+- daytrader-ee7-wlpcfg <-- specific server configuration
+- server.xml <-- server configuration
+- apps <- directory for applications
+- daytrader-ee7.ear <- sample application
+- logs <- created by running the server locally
+- workarea <- created by running the server locally
- Select the Servers tab
- Right-click on the appropriate server (as created above) and select Start (For now, ignore any EJB errors)
- Confirm web browser opens on "http://localhost:9082/daytrader/" or "http://localhost:9082/daytrader/index.faces"
- In the web browser, Click on the configuration tab.
- Click on '(Re)-create DayTrader Database Tables and Indexes' to create the database.
- Click on '(Re)-populate DayTrader Database' to populate the database.
- Back on the Servers tab, Right-click on the appropriate server (as created above) and select Restart-> . Now the application will be ready for use.
- When importing the existing maven project into Eclipse, Eclipse will (by default) "helpfully" add this project to an (extraneous) ear. To turn this off, go to Preferences -> Java EE -> Project, and uncheck "Add project to an EAR" before you import the project. If you forgot to do this, just delete the ear project; no harm.