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!).
- improved Maven integration for web projects starting with WDT 17.0.0.2 including support for loose applications.
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.async.websockets [master]" repo should appear in the view
- In the Git Repository view, expand the websocket repo to see the "Working Tree" 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 3 pom.xml files)
- This will create 3 projects in Eclipse: sample.async-websockets, async-websocket-application, and async-websocket-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.async.websocket/pom.xml
- Run As > Maven build...
- In the Goals section enter "install"
- Click Run
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 async-websocket-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_websocket_server
- Select the installation created at
sample.async.websocket/async-websocket-wlpcfg/target/wlp/
- Follow the prompts until you Finish creating the Runtime Environment. (Needed features were installed during
mvn install
)
- From the Runtime Explorer, right-click wlp-websocket-server -> Servers -> websocketSample, and select Server
- Look in the Servers view for your new server!
- Navigate to the Servers view
- Right-click websocketSample -> Start
- Confirm web browser opens on "http://localhost:9082/websocket/" with 5 hyperlinks to run samples
⭐ Note: You can also right-click async-websocket-application -> Run As -> Run on Server to start the application. Some versions of WDT incorrectly map the cdi-1.2 dependency to the CDI 1.0 Facet, which prevents the Run As ... operation in step 2 from succeeding. If this happens, Right-click on the async-websocket-application
project, and select Properties, then select Project Facets in the left-hand pane. Change the the "Context and dependency injection (CDI)" facet to use version 1.2.
- 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.