GAMEON

Hands-on experiment building microservices and cloud native applications

Eclipse and WDT

We are using Liberty as the server runtime and Eclipse as the IDE with WebSphere development tools (WDT) to enable iterative development with incremental publish. We are big fans of these tools because they’re very efficient: no build, repackage, or restart steps are required before your changes are live in the server.

Getting this setup to work with our Docker images does require some first-time set up, but after that, it’s smooth sailing for development.

This approach requires the mounted volumes provided by docker-compose.override.yml.

Getting Eclipse and WDT

The easiest way to get both Eclipse and WDT is via wasdev.net.

  • Step 1 contains the link for the latest Eclipse for Java EE developers
  • Step 2 contains a drag-and-drop link to install the latest copy of WDT.

Build and import Eclipse projects

Begin by building the eclipse projects in the submodules:

./eclipse.sh

Fire up eclipse, and use FileImport, and in the resulting dialog, start typing the word Existing and select Existing Projects into Workspace as soon as it appears.

Select the gameon directory created by the git clone operation. Tick the Search for nested projects box and press Finish.

This should result in a collection of projects being imported to the workspace as shown in Figure 1.

Eclipse projects
Figure 1. Example of the projects created by the import action

Integration with Liberty and WDT

For the full 'run in eclipse' support we need to have eclipse believe that our applications are being deployed to servers it manages. On it’s own, Liberty will monitor applications and server configuration files for changes, and will push configuration updates and/or re-start applications as necessary.

Full integration with WDT does bring some additional benefits, but there is currently a disconnect between how WDT would control a server in a docker container (as a remote server) when the file system is local to the host and no file transfer is required.

So, until we get that sorted, we’ll do the following:

  1. Download Liberty from wasdev.net, and extract it to a well-known but nearby location. This copy will be used for compilation, rather than for running the application.
  2. Use the installUtility command to update the installation to include the features our servers need. The liberty-features.sh script will take care of this for you, iterating through each project with a *-wlpcfg directory to make sure we have all of the referenced feautures for defined servers.

You now have WDT installed and ready (per earlier steps), and a runtime installed that has all of the features our servers need. We now need to tell them about each other.

Create the Runtime Environment

  1. 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).
  2. Right-click in the view, and select New → Runtime Environment
  3. Give the Runtime environment a name, e.g. wlp-2015.11.0.0 if you’re using the November 2015 beta.
  4. Select the existing Liberty installation
  5. Add project-specific user directories:
    1. Click the Advanced Options…​ link
    2. For each -wlpcfg project (e.g. player-wlpcfg): Click *New, and select it
    3. Click OK when all *-wlpcfg projects are shown in the list of user directories
  6. Click Finish to create the Runtime Environment. The Runtime Environment view should look something like Figure 2.
Runtime Explorer for Liberty in WDT
Figure 2. Example of the Runtime Explorer for Liberty in WDT with associated user directories

Create WDT Servers

WDT has its own representation of the server, which show up in the Servers view: * Window → Show View → Other * type server in the filter box to find the view (it’s under the Server heading).

  1. In the Runtime Explorer view, Right-click on the newly created Runtime Environment, e.g. wlp-2015.11.0.0, and select New → Server.
    • The resulting dialog should be pre-populated. The "Liberty profile server" drop-down box will contain an entry for every configured server for that runtime environment.
  2. For each gameon- entry in the drop-down, select it, and click *Finish to create an Eclipse/WDT Server.
Liberty Servers in WDT
Figure 3. The Servers view listing Liberty servers in WDT
Renamed Liberty Servers in WDT
Figure 4. Servers can be renamed for clarity (right click)

Deploy the application to the server

WDT defines a very handy stand-in for the packaged war: a loose configuration file. We’re going to deploy our applications to the liberty servers, and WDT will replace our built wars with xml files that act like wars, but that serve the contents directly from our eclipse project.

For each server:

  1. Right-click on the server in the Servers view, and select Add and Remove…​
  2. In the dialog that opens, you will see an application with the same name in both the left and right-hand side of the dialog. Select the application in the left-hand panel as shown in Figure 5, and click Add > to add it to the application as shown in Figure 6.
  3. Click Finish.
  4. Right-click on the server again, and select Publish.
    • You may see warnings that the publish failed. These can be ignored.
  5. Open the corresponding -wlpcfg project. Verify that the servers/gameon-/apps folder now contains a *-app.war.xml file as shown in Figure 7.
    • You may need to refresh the view to see the updated application
    • If the *.war file created by the build.sh step is still present, you may remove it to avoid problems later.
  6. Discard any server.xml changes made by WDT for the project.
Add and Remove... with a warning for the existing application
Figure 5. A warning appears when selecting the application in the left pane
Add and Remove... replacing the application
Figure 6. Add the application to the server to replace the built war file
The mediator's loose config file
Figure 7. The loose config file in the mediator-wlpcfg project

All done!

Congratulations!

  • The Docker Compose configuration mapped your local filesystem into the Docker container
  • You now have Eclipse projects that reference the same source and Liberty configuration
  • WDT has created a loose configuration file to replace the built/packaged war

You can now make application updates within your Eclipse projects, and see the results running live in your local development server without having to build/package/redeploy/etc.