Search code examples
websphere-libertyopen-libertyibm-wdtliberty-maven-plugin

Why isn't IBM Liberty Developer Tools or WebSphere Developer Tools (WDT) for Eclipse automatically creating a server to run my Maven project?


PROBLEM / EXPECTED BEHAVIOR

I started with the simple Getting Started guide sample application.

After a git clone, then cd finish, I did a mvn install, following the instructions in the doc. I then did an Import->Maven->Existing Maven Projects to import the finished WAR module into my Eclipse workspace.

Since this sample app is configured to use the liberty-maven-plugin, I was expecting a dialog like this:

Expected Liberty server creation dialog

This is the dialog I've gotten after importing other Maven WAR/EAR projects. Clicking "Yes" should then cause the tooling to generate a Liberty server (visible in the Servers view) and the tooling should then be configured to "Publish" my app to this server (by making use of the liberty-maven-plugin, but without me having to do anything special).

What am I missing?


Solution

  • TERMINOLOGY

    (I'll use "WDT/LDT" to refer to the IBM Liberty Developer Tools feature for the Eclipse IDE, and the related "WebSphere Developer Tools" or "WDT").

    BROAD EXPLANATION

    I'll start with a broad explanation of the issue so that the key idea here could maybe be applied to similar problems.

    To identify a Maven project as a Liberty project, the LDT/WDT function looks for two things:

    1. The liberty-maven-plugin configured in the POM
    2. The liberty-maven-plugin project metadata generated at path: ./target/liberty-plugin-config.xml

    By executing the liberty:run goal before importing into the Eclipse workspace, we both generate this plugin metadata and also install all the features needed for our Liberty server.

    SOLUTION FOR THIS PARTICULAR PROJECT

    Having explained the big picture, let me detail what steps you might do for the project in the original question.

    PREREQ:

    This assumes you're using liberty-maven-plugin version 3.1 or greater. (See the v3.0 release notes if you're still using version 2.x of the plugin).

    SETUP

    Though not strictly necessary for the goal of having LDT/WDT generate the Liberty server, I'd recommend first making sure the localConnector-1.0 feature is configured. This feature allows the IDE tooling to notify the Liberty server about updates. By configuring it here upfront you can ensure it will be installed by the tooling, and avoid error messages and possibly having to fix this up later.

    Add this feature if not already present to:

    src/main/liberty/config/server.xml

    <server description="Sample Liberty server">
        <featureManager>
            <feature>localConnector-1.0</feature>
            ...
    

    MAIN STEP

    1. Execute the liberty:run goal

    Before importing the project, from a separate terminal/shell session, do mvn liberty:run, and then wait for a message like:

    [INFO] [AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 21.332 seconds.

    then hit Ctrl+C to kill the server (because you want LDT/WDT to manage its server here).

    2. Now Import the Project(s)

    Do the Import->Maven->Existing Maven Projects

    3. Now you'll see the dialog from the original question so click "Yes" at the prompt.

    This will direct LDT/WDT create a Liberty runtime and server. (This might take a bit).

    (NOTE: - If you've selected the preference to always automatically create the server, then you'll just see it automatically created without the dialog.)

    Note if you don't do this initially you could do it later on by right-clicking the project, choosing the "Maven" sub-menu, and then the "Create WebSphere Liberty runtime and server" menu selection (which also works for Open Liberty), as shown in this screenshot:

    Create WebSphere Liberty runtime and server from menu

    YOU'RE DONE

    The app is deployed. Go ahead and use the app: run/debug/edit, etc. and the changes should result in an automatic update of the app.

    E.g. here's how you'd launch the app on the server in debug mode (with debugger attached):

    Launch in debug

    Click on the app endpoints from the Console view, do whatever!

    ALTERNATIVE SOLUTION

    Though it's a bit of a tangent starting from the original question, an entirely different option for some users would be to consider the next-generation Liberty Tools (note the name, in contrast to "Liberty Developer Tools") feature for Eclipse IDE.

    The newer tools simply rely on the Liberty Maven/Gradle plugins to install, configure, and run/debug Liberty, and to deploy the project app, without requiring you to create the Eclipse (WTP) Server instance. This can result in a more lightweight, Maven/Gradle-centric experience and avoid a gotcha or two sometimes seen using the LDT/WDT approach. In Liberty Tools there's no need to have Eclipse create (install, etc.) a Server because there's already a server created and managed by the Liberty Maven/Gradle plugin.