Saturday, October 26, 2019

Create microservices multimodule OpenLiberty project using Maven

Multimodule project guide
https://openliberty.io/guides/maven-multimodules.html

Sample multimodule project
https://github.com/Yavin/maven-ear-example

Get the code

[dave@localhost git]$ git clone https://github.com/openliberty/guide-maven-multimodules.git
Cloning into 'guide-maven-multimodules'... 

Project structure

[dave@localhost finish]$ find
.
./ear
./ear/pom.xml
./ear/src
./ear/src/main
./ear/src/main/liberty
./ear/src/main/liberty/config
./ear/src/main/liberty/config/server.xml
./ear/src/test
./ear/src/test/java
./ear/src/test/java/it
./ear/src/test/java/it/io
./ear/src/test/java/it/io/openliberty
./ear/src/test/java/it/io/openliberty/guides
./ear/src/test/java/it/io/openliberty/guides/multimodules
./ear/src/test/java/it/io/openliberty/guides/multimodules/Test.java
./war
./war/pom.xml
./war/src
./war/src/main
./war/src/main/java
./war/src/main/java/io
./war/src/main/java/io/openliberty
./war/src/main/java/io/openliberty/guides
./war/src/main/java/io/openliberty/guides/multimodules
./war/src/main/java/io/openliberty/guides/multimodules/web
./war/src/main/java/io/openliberty/guides/multimodules/web/HeightsBean.java
./war/src/main/webapp
./war/src/main/webapp/index.jsp
./war/src/main/webapp/WEB-INF
./war/src/main/webapp/WEB-INF/web.xml
./war/src/main/webapp/heights.jsp
./jar
./jar/pom.xml
./jar/src
./jar/src/main
./jar/src/main/java
./jar/src/main/java/io
./jar/src/main/java/io/openliberty
./jar/src/main/java/io/openliberty/guides
./jar/src/main/java/io/openliberty/guides/multimodules
./jar/src/main/java/io/openliberty/guides/multimodules/lib
./jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.java
./pom.xml


Build the project using mvn install


[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] io.openliberty.guides.multimodules.modules                         [pom]
[INFO] io.openliberty.guides.multimodules.jar                             [jar]
[INFO] io.openliberty.guides.multimodules.war                             [war]
[INFO] io.openliberty.guides.multimodules.ear                             [ear]
[INFO] 
[INFO] --< io.openliberty.guides:io.openliberty.guides.multimodules.modules >--
[INFO] Building io.openliberty.guides.multimodules.modules 0.0.1-SNAPSHOT [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ io.openliberty.guides.multimodules.modules ---
[INFO] Installing /git/guide-maven-multimodules/finish/pom.xml to /home/dave/.m2/repository/io/openliberty/guides/io.openliberty.guides.multimodules.modules/0.0.1-SNAPSHOT/io.openliberty.guides.multimodules.modules-0.0.1-SNAPSHOT.pom


Start the server using mvn liberty:start-server

INFO] --- liberty-maven-plugin:3.0.M1:start-server (default-cli) @ io.openliberty.guides.multimodules.modules ---
[INFO] CWWKM2102I: Using installDirectory : /git/guide-maven-multimodules/finish/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /git/guide-maven-multimodules/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] Installing from Open Liberty repository...
[INFO] Getting: https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/release/info.json
[INFO] To: /home/dave/.m2/repository/wlp-cache/openliberty-versions.json
[INFO] Using runtime version: 2019-10-02_0300
[INFO] Getting: https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/release/2019-10-02_0300/info.json
[INFO] To: /home/dave/.m2/repository/wlp-cache/2019-10-02_0300.json
[INFO] Getting: https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/release/2019-10-02_0300/openliberty-19.0.0.10.zip
[INFO] To: /home/dave/.m2/repository/wlp-cache/2019-10-02_0300/openliberty-19.0.0.10.zip


[INFO] Copying 1 file to /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /git/guide-maven-multimodules/finish/ear/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO] CWWKM2001I: server.config.dir is /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2001I: server.output.dir is /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2001I: Invoke command is [/git/guide-maven-multimodules/finish/ear/target/liberty/wlp/bin/server, start, defaultServer].
[INFO] 
[INFO] Starting server defaultServer.
[INFO] Server defaultServer started with process ID 21980.
[INFO] Waiting up to 30 seconds for server confirmation:  CWWKF0011I to be found in /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/logs/messages.log
[INFO] CWWKM2010I: Searching for CWWKF0011I in /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/logs/messages.log. This search will timeout after 30 seconds.
[INFO] CWWKM2015I: Match number: 1 is [10/26/19 12:10:53:843 CEST] 0000001f com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 1.067 seconds..

[dave@localhost finish]$ tail -500f /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/logs/messages.log
********************************************************************************
product = Open Liberty 19.0.0.10 (wlp-1.0.33.cl191020191002-0300)
wlp.install.dir = /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/
java.home = /usr/java/jdk1.8.0_231-amd64/jre
java.version = 1.8.0_231
java.runtime = Java(TM) SE Runtime Environment (1.8.0_231-b11)
os = Linux (5.3.6-200.fc30.x86_64; amd64) (en_US)
process = 21980@localhost.localdomain
********************************************************************************
[10/26/19 12:10:52:876 CEST] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           A CWWKE0001I: The server defaultServer has been launched.
[10/26/19 12:10:53:275 CEST] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           I CWWKE0002I: The kernel started after 0.498 seconds
[10/26/19 12:10:53:296 CEST] 0000001f com.ibm.ws.kernel.feature.internal.FeatureManager            I CWWKF0007I: Feature update started.
[10/26/19 12:10:53:457 CEST] 00000015 com.ibm.ws.app.manager.internal.monitor.DropinMonitor        A CWWKZ0058I: Monitoring dropins for applications.
[10/26/19 12:10:53:527 CEST] 00000023 com.ibm.ws.tcpchannel.internal.TCPPort                       E CWWKO0221E: TCP Channel defaultHttpEndpoint initialization did not succeed.  The socket bind did not succeed for host * and port 9080.  The port might already be in use.  Exception Message: Address already in use
[10/26/19 12:10:53:625 CEST] 00000026 com.ibm.ws.app.manager.AppMessageHelper                      I CWWKZ0018I: Starting application io.openliberty.guides.multimodules.ear.
[10/26/19 12:10:53:626 CEST] 00000026 bm.ws.app.manager.ear.internal.EARDeployedAppInfoFactoryImpl I CWWKZ0134I: The io.openliberty.guides.multimodules.ear application is using the loose application definition at the /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/apps/io.openliberty.guides.multimodules.ear-0.0.1-SNAPSHOT.ear.xml location.
[10/26/19 12:10:53:815 CEST] 00000026 com.ibm.ws.session.WASSessionCore                            I SESN8501I: The session manager did not find a persistent storage location; HttpSession objects will be stored in the local application server's memory.
[10/26/19 12:10:53:826 CEST] 00000026 com.ibm.ws.webcontainer.osgi.webapp.WebGroup                 I SRVE0169I: Loading Web Module: Archetype Created Web Application.
[10/26/19 12:10:53:827 CEST] 00000026 com.ibm.ws.webcontainer                                      I SRVE0250I: Web Module Archetype Created Web Application has been bound to default_host.
[10/26/19 12:10:53:830 CEST] 00000026 com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0001I: Application io.openliberty.guides.multimodules.ear started in 0.205 seconds.
[10/26/19 12:10:53:842 CEST] 0000001f com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0012I: The server installed the following features: [el-3.0, jsp-2.3, servlet-3.1].
[10/26/19 12:10:53:843 CEST] 0000001f com.ibm.ws.kernel.feature.internal.FeatureManager            I CWWKF0008I: Feature update completed in 0.568 seconds.
[10/26/19 12:10:53:843 CEST] 0000001f com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 1.067 seconds.
[10/26/19 12:10:53:847 CEST] 00000029 com.ibm.ws.session.WASSessionCore                            I SESN0176I: A new session context will be created for application key default_host/converter
[10/26/19 12:10:53:861 CEST] 00000029 com.ibm.ws.util                                              I SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.
[10/26/19 12:10:53:868 CEST] 0000002a com.ibm.ws.webcontainer.osgi.mbeans.PluginGenerator          I SRVE9103I: A configuration file for a web server plugin was automatically generated for this server at /git/guide-maven-multimodules/finish/ear/target/liberty/wlp/usr/servers/defaultServer/logs/state/plugin-cfg.xml.


Test the application

No comments:

Post a Comment