Topic
11 replies Latest Post - ‏2013-12-17T07:19:24Z by bwa
bwa
bwa
47 Posts
ACCEPTED ANSWER

Pinned topic Guide for using Liberty Profile and Maven

‏2013-12-10T12:49:52Z |

Hello all.

I'm trying to understand the whole lifecycle of Liberty Profile and Maven ... 

The only information used is http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.wlp.nd.doc%2Fae%2Ftwlp_dev_maven.html and this describes several steps, but still a lot of questions arises...

My project layout is like this

HelloWorldProject
--HelloWorldEAR
--HelloWorldWeb

One parent project and two or more child projects

 

1) Which maven module is supposed to have the liberty profile configuration ? The EAR project ?

2) Whats the difference between install-apps and deploy and package-server ?

My goal is to have a complete setup in the EAR projects pom.xml, så by just check out the whole project from SCM, it's possible to just run mvn install and then the liberty profile server is downloaded from nexus, installed, configured, deployed and started ready to run, in just one command.

Is this possible or am I misunderstanding the whole idea ?

I'm missing a real guide-article on this topic...

Regards Bjørn-Willy Arntzen

  • bwa
    bwa
    47 Posts
    ACCEPTED ANSWER

    Re: Guide for using Liberty Profile and Maven

    ‏2013-12-10T14:10:05Z  in response to bwa

    Getting this on mvn liberty:deploy

     

    [ERROR] Failed to execute goal com.ibm.websphere.wlp.maven.plugins:liberty-maven-plugin:1.0:deploy (default-cli) on project autostart-ear: CWWKM2155E:
     There is no application to be deployed as specified by the appArchive attribute. -> [Help 1]
    [ERROR]

     

    The file is in place for shure ....

    with this in my pom

                <!-- Enable liberty-maven-plugin -->
                <plugin>
                    <groupId>com.ibm.websphere.wlp.maven.plugins</groupId>
                    <artifactId>liberty-maven-plugin</artifactId> 
                    <version>1.0</version>
                    <executions>
                        <execution>
                            <id>install-apps</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>install-apps</goal>
                            </goals>
                        </execution>
                    <execution>
                        <id>deploy-app</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <configuration>
                                <appArchive>c:/RAD9/workspace/autostart/autostart-web/target/autostart-web-4.4.0-SNAPSHOT.war</appArchive>  
                        </configuration>
                    </execution>
                    </executions>                
                    <configuration>
                        <serverHome>c:/dev/wlp855</serverHome>
                    </configuration> 
                </plugin>           
     

     

    /bwa

  • bwa
    bwa
    47 Posts
    ACCEPTED ANSWER

    Re: Guide for using Liberty Profile and Maven

    ‏2013-12-11T09:25:33Z  in response to bwa

    I treally want to install an EAR , så I tried that instead... 

     

    But got this unexpected message : 

     

    Now it finds the file, but ???? This is an EAR, so why complaining ???

     

    [INFO]
    [INFO] --- liberty-maven-plugin:1.0:deploy (deploy-apps) @ autostart-ear ---
    [INFO] CWWKM2102I: Using pre-installed assembly : C:\dev\wlp855.
    [INFO] CWWKM2102I: Using serverName : defaultServer.
    [INFO] CWWKM2156I: Deploying app C:\RAD9\workspace\autostart\autostart-ear\target\autostart-ear-4.4.0-SNAPSHOT.ear...
    [INFO] CWWKM2001I: installDir is C:\dev\wlp855.
    [INFO] CWWKM2001I: ConfigDir is C:\dev\wlp855\usr\servers\defaultServer.
    [INFO] CWWKM2001I: OutputDir is C:\dev\wlp855\usr\servers\defaultServer.
    [INFO] CWWKM2006I: Deploying application C:\RAD9\workspace\autostart\autostart-ear\target\autostart-ear-4.4.0-SNAPSHOT.ear to the dropins folder.
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 4.963s
    [INFO] Finished at: Wed Dec 11 10:20:21 CET 2013
    [INFO] Final Memory: 13M/245M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal com.ibm.websphere.wlp.maven.plugins:liberty-maven-plugin:1.0:deploy (deploy-apps) on project autostart-ear: CWWKM2007E:
     Liberty only supports deployment war, eba, zip, ear or jar files. -> [Help 1]

     

    • jgawor
      jgawor
      9 Posts
      ACCEPTED ANSWER

      Re: Guide for using Liberty Profile and Maven

      ‏2013-12-13T05:07:08Z  in response to bwa

      Try using liberty-maven-plugin version 1.1. That should allow deployment of ear files.

       

       

      • bwa
        bwa
        47 Posts
        ACCEPTED ANSWER

        Re: Guide for using Liberty Profile and Maven

        ‏2013-12-13T06:23:19Z  in response to jgawor

        Thanks. I discovered this yesterday, now it works better

  • jgawor
    jgawor
    9 Posts
    ACCEPTED ANSWER

    Re: Guide for using Liberty Profile and Maven

    ‏2013-12-13T05:29:49Z  in response to bwa

    The main difference between the deploy and install-apps goals is how the application to be deployed is specified. With the deploy goal, the application to deploy is specified either as appArchive or appArtifact parameter within the <configuration/> block. With install-apps the application(s) to deploy is specified as a regular Maven dependency. That way Maven can figure out the right order to build your projects. The install-apps goal also makes it easy to deploy multiple applications at the same time. However, both goals have the same end result. The applications are put into the dropins/ directory of the server. Both goals can also be combined with the package-server goal that enables you to create a custom Liberty server packaged and optimized for your applications.

    Btw, the liberty-maven-plugin is now open sourced and you can find it on GitHub: https://github.com/WASdev/ci.maven.

     

    • bwa
      bwa
      47 Posts
      ACCEPTED ANSWER

      Re: Guide for using Liberty Profile and Maven

      ‏2013-12-13T06:37:37Z  in response to jgawor

      Thanks. I have played a lot with this the last couple of days and have managed to creata a custom liberty server and deployed several applications from one pom.

       

      Now it's only some remaining issues

      1. How can I deploy like the 'Run applications directly from the workspace'
      2. How can I deploy to a already running server ?

       

      Regarding 2) : 'mvn install' executes all steps, installing, start server, deploy. But if the liberty is already running it fails, couldn't  the plugin just skip start-server if it's already running ?

       

       

      • jgawor
        jgawor
        9 Posts
        ACCEPTED ANSWER

        Re: Guide for using Liberty Profile and Maven

        ‏2013-12-16T18:36:48Z  in response to bwa

        As to question #2, that's something we want to improve. For now, I would recommend opening an enhancement for this issue at https://github.com/WASdev/ci.maven/issues.

         

        • bwa
          bwa
          47 Posts
          ACCEPTED ANSWER

          Re: Guide for using Liberty Profile and Maven

          ‏2013-12-16T21:24:15Z  in response to jgawor

          Thanks. Added request for a clean goal, as well ...

  • bwa
    bwa
    47 Posts
    ACCEPTED ANSWER

    Re: Guide for using Liberty Profile and Maven

    ‏2013-12-13T08:45:58Z  in response to bwa

    Discovered another issue. Maybe I'm not understanding this right ...

    I've added this to my pom

                        <execution>
                       <id>start-server</id>
                       <phase>pre-integration-test</phase>
                       <goals>
                           <goal>start-server</goal>
                       </goals>
                       <configuration>
                           <configFile>c:/RAD9/workspace/autostart/autostart-liberty/server.xml</configFile>
                       </configuration>
                        </execution>
     

    and running 'mvn liberty:start-server' and was expecting maven to start tte liberty server AND copy a fresh server.xml from the given location in configFile, but that is not happening. It never tries to copy the file ... Wonder why ?

     

    • jgawor
      jgawor
      9 Posts
      ACCEPTED ANSWER

      Re: Guide for using Liberty Profile and Maven

      ‏2013-12-16T18:46:23Z  in response to bwa

      The file should be copied as long as you specified a valid file (the file exists) in the <configFile> property. If the file exits and the copy is still not happening can you send the output of the mvn command when executing with -X option?

       

      • bwa
        bwa
        47 Posts
        ACCEPTED ANSWER

        Re: Guide for using Liberty Profile and Maven

        ‏2013-12-17T07:19:24Z  in response to jgawor

        It works of course now... :-)  But I'll post a -X output if I can reproduce it ...