The Liberty app accelerator generates a basic application that you can build and deploy to a Liberty server using Maven.

In this short tutorial, we’ll use the Liberty app accelerator to project containing a simple Java servlet.

Generating a project using the Liberty app accelerator

  1. Head to the Liberty app accelerator.

  2. The app we’re creating will be a simple Java servlet, so click Servlet:


  3. Accept the default options and download the project ZIP file:


  4. Extract the ZIP file into a directory. Now you’re ready to go:

Building and running from the command line

  1. Ensure you have the Maven command line client installed.

  2. From the command line, change to the directory that contains your extracted application files.

  3. Run the following command to build and run the application:

    mvn install liberty:run-server
  4. Access your application at the URL shown on the Liberty app accelerator page (e.g. http://localhost:9080/myLibertyApp/). Your application should look something like this:


    Appcelerator-result

  5. To edit the application, make changes to the LibertyServlet.java file.

Building and running from Eclipse

  1. Download and start Eclipse.

  2. Import the project into Eclipse:

    1. In the Java EE perspective of Eclipse, click File > Import… then click Projects from Folder or Archive.
    2. Browse to the directory into which you extracted the ZIP file, then click Finish. The project is displayed in the Project Explorer view:


  3. Right-click the project and click Maven build….

  4. In the Goals field, type install liberty:run-server, then click Run. This builds the application and deploys it to a Liberty server:


  5. Access your application at the URL shown on the Liberty app accelerator page (e.g. http://localhost:9080/myLibertyApp/). Your application should look something like this:


    Appcelerator-result

  6. To edit the application, make changes to the LibertyServlet.java file.

What next?

Try generating other types of Liberty applications from the Liberty app accelerator. The Liberty app accelerator is a project in GitHub.

2 comments on"Getting started using the Liberty app accelerator"

  1. On my first attempt using ‘Liberty App Accelerator’ encountered error in POM file generated for a sample Servlet. Please advice.

    Failure to transfer org.apache.maven.plugins:maven-failsafe-plugin:pom:2.18.1 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-failsafe-plugin:pom:2.18.1 from/to central (https://repo.maven.apache.org/maven2): connect timed out

    Project build error: Unresolveable build extension: Plugin net.wasdev.wlp.maven.plugins:liberty-maven-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for net.wasdev.wlp.maven.plugins:liberty-maven-plugin:jar:1.2

    Maven Built errors …
    [INFO] Scanning for projects…
    [INFO] Downloading: https://repo.maven.apache.org/maven2/net/wasdev/wlp/maven/plugins/liberty-maven-plugin/1.2/liberty-maven-plugin-1.2.pom
    [ERROR] [ERROR] Some problems were encountered while processing the POMs:
    [ERROR] Unresolveable build extension: Plugin net.wasdev.wlp.maven.plugins:liberty-maven-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for net.wasdev.wlp.maven.plugins:liberty-maven-plugin:jar:1.2 @
    @
    [ERROR] The build could not read 1 project -> [Help 1]
    [ERROR]
    [ERROR] The project liberty.maven:test:1.0-SNAPSHOT (C:\Users\ual\Downloads\LibertyProject\pom.xml) has 1 error
    [ERROR] Unresolveable build extension: Plugin net.wasdev.wlp.maven.plugins:liberty-maven-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for net.wasdev.wlp.maven.plugins:liberty-maven-plugin:jar:1.2: Could not transfer artifact net.wasdev.wlp.maven.plugins:liberty-maven-plugin:pom:1.2 from/to central (https://repo.maven.apache.org/maven2): connect timed out -> [Help 2]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
    [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

    • BillyDawson May 25, 2017

      Hey Ulises, having ran through this again to replicate the issue I’ve found that the accelerator has generated a pom.xml with an outdated cxf-rt-rs-client dependency. In the meantime if you change the following:


      org.apache.cxf
      cxf-rt-rs-client
      3.1.1
      test

      to:


      org.apache.cxf
      cxf-rt-rs-client
      3.1.11
      test

      the application will then work. Apologies for the inconvenience!

Join The Discussion

Your email address will not be published. Required fields are marked *