JAX-RS Maven project for WAS Liberty

So the other day I wrote this, apparently not a good approach these days. This is probably the official (current) way of creating a web app project. The following instructions are specific for WebSphere Application Server Liberty Profile. Much of these information is based on the following sites/posts/answer:

Create a Maven project

This could be created manually, but Eclipse is good at this :)
  1. FileNewMaven Project
  2. Check Use default Workspace location
    Click next
  3. Select the http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository Catalog
    Select the com.ibm.tools.archetype webapp-jee7-liberty
    Click next
  4. Enter a Group Id: com.ibm.jp.myproject
    Enter a Artifact Id: myproject
    Enter Package: com.ibm.jp.myproject
    Click Finish
At this point we have created the project but it seems it is a bit broken. At written here we can get rid of the following error by modifying the pom.xml
ArtifactDescriptorException: Failed to read artifact descriptor for com.ibm.tools.target:was-liberty:pom:LATEST: VersionResolutionException: Failed to resolve version for com.ibm.tools.target:was-liberty:pom:LATEST: Could not find metadata com.ibm.tools.target:was-liberty/maven-metadata.xml in local (/Users/paulbastide/.m2/repository)

Modify the pom.xml

  1. To get rid of above error add the following to pom.xml
            <id>maven online</id>
            <name>maven repository</name>
            <id>liberty maven online</id>
            <name>liberty maven repository</name>
  2. Setup to use Dynamic Web Module 3.1 Add the following to pom.xml
    Also we need to make sure 3.1 is setup properly in web.xml (For other versions check Katsumi Kokuzawa's Blog)
    <!DOCTYPE xml>
    <web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
        <display-name>Servlet 3.1 Web Application</display-name>
  3. Setup to use Java 7 or 8 (needed for Dynamic Web Module 3.1)
    For Java 7
    For Java 8 we need to use the 3.5.1 version of the plugin

Update the project

After all the changes we just do right click in the project MavenUpdate Project ...
If we check the Project Facets we should have
  • Dynamic Web Module 3.1
  • Java 1.8
  • JAX-RS(Rest Web Services) 2.0

Here is a copy of the full pom.xml and web.xml files :)