Quantcast
Channel: DevOps tips & tricks
Viewing all articles
Browse latest Browse all 181

Configure development environment for Java Microproflle using OpenLiberty on Fedora

$
0
0
Follow the guide fron OpenLiberty
https://openliberty.io/guides/maven-intro.html

Install latest Maven


https://computingforgeeks.com/installing-latest-apache-maven-on-centos-fedora/

[dave@localhost ~]$ export VER="3.6.2"
[dave@localhost ~]$ curl -O http://www-eu.apache.org/dist/maven/maven-3/${VER}/binaries/apache-maven-${VER}-bin.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8928k  100 8928k    0     0  9508k      0 --:--:-- --:--:-- --:--:-- 9497k
[dave@localhost ~]$ tar xvf apache-maven-${VER}-bin.tar.gz



[dave@localhost ~]$ sudo mv apache-maven-${VER} /opt/maven
[sudo] password for dave:
[dave@localhost ~]$ cat <<EOF | sudo tee /etc/profile.d/maven.sh
> export MAVEN_HOME=/opt/maven
> export PATH=\$PATH:\$MAVEN_HOME/bin
> EOF
export MAVEN_HOME=/opt/maven
export PATH=$PATH:$MAVEN_HOME/bin
[dave@localhost ~]$ source /etc/profile.d/maven.sh
[dave@localhost ~]$ echo $MAVEN_HOME
/opt/maven
[dave@localhost ~]$ echo $PATH
/home/dave/.local/bin:/home/dave/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/opt/maven/bin
[dave@localhost ~]$ mvn --version
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: /opt/maven
Java version: 1.8.0_232, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.fc30.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.3.6-200.fc30.x86_64", arch: "amd64", family: "unix"


Install Oracle JDK


You can also use OpenJDK but I want to run Weblogic on this host so I need Oracle JDK 


[dave@localhost finish]$ sudo dnf install ~/Downloads/jdk-8u231-linux-x64.rpm 
Error: 
 Problem: conflicting requests
  - nothing provides /bin/basename needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
  - nothing provides /bin/cp needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
  - nothing provides /bin/ls needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
  - nothing provides /bin/mkdir needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
  - nothing provides /bin/mv needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
  - nothing provides /bin/pwd needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
  - nothing provides /bin/sort needed by jdk1.8-2000:1.8.0_231-fcs.x86_64
(try to add '--skip-broken' to skip uninstallable packages)


Use direct rpm installation due to missing deps


[dave@localhost Downloads]$ sudo rpm -Uvh  ~/Downloads/jdk-8u231-linux-x64.rpm 
warning: /home/dave/Downloads/jdk-8u231-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8-2000:1.8.0_231-fcs        ################################# [100%]
Unpacking JAR files...
    tools.jar...
    plugin.jar...
    javaws.jar...
    deploy.jar...
    rt.jar...
    jsse.jar...
    charsets.jar...
    localedata.jar...
[dave@localhost Downloads]$ rpm -qi jdk1.8
Name        : jdk1.8
Epoch       : 2000
Version     : 1.8.0_231
Release     : fcs
Architecture: x86_64
Install Date: Sat 26 Oct 2019 09:50:36 AM CEST
Group       : Development/Tools
Size        : 308047737
License     : https://java.com/bc_license
Signature   : RSA/SHA256, Sat 05 Oct 2019 12:32:51 PM CEST, Key ID 72f97b74ec551f03
Source RPM  : jdk1.8-1.8.0_231-fcs.src.rpm
Build Date  : Sat 05 Oct 2019 12:18:14 PM CEST
Build Host  : java.com
Relocations : /usr/java
Vendor      : Oracle Corporation
URL         : http://www.oracle.com/technetwork/java/javase/overview/index.html
Summary     : Java Platform Standard Edition Development Kit
Description :
The Java Platform Standard Edition Development Kit (JDK) includes both
the runtime environment (Java virtual machine, the Java platform classes
and supporting files) and development tools (compilers, debuggers,
tool libraries and other tools).

The JDK is a development environment for building applications, applets
and components that can be deployed with the Java Platform Standard
Edition Runtime Environment.


Set new Java home

[dave@localhost Downloads]$ sudo  /usr/sbin/alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.fc30.x86_64/jre/bin/java)
   2           /usr/java/jdk1.8.0_231-amd64/jre/bin/java

Enter to keep the current selection[+], or type selection number: 2
[dave@localhost Downloads]$ java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)



Get the code for sample


git clone https://github.com/openliberty/guide-maven-intro.git
cd guide-maven-intro/finish
mvn install


Start server

[dave@localhost finish]$           mvn liberty:start-server
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for io.openliberty.guides:ServletSample:war:1.0-SNAPSHOT
[WARNING] 'parent.version' is either LATEST or RELEASE (both of them are being deprecated) @ line 8, column 18
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ----------------< io.openliberty.guides:ServletSample >-----------------
[INFO] Building ServletSample 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- liberty-maven-plugin:3.0.M1:start-server (default-cli) @ ServletSample ---
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:RELEASE:zip.
[INFO] CWWKM2102I: Using installDirectory : /git/guide-maven-intro/finish/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : ServletSampleServer.
[INFO] CWWKM2102I: Using serverDirectory : /git/guide-maven-intro/finish/target/liberty/wlp/usr/servers/ServletSampleServer.
[INFO] CWWKM2112I: Re-using previously installed assembly.
[INFO] Copying 1 file to /git/guide-maven-intro/finish/target/liberty/wlp/usr/servers/ServletSampleServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /git/guide-maven-intro/finish/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-intro/finish/target/liberty/wlp/usr/servers/ServletSampleServer.
[INFO] CWWKM2001I: server.output.dir is /git/guide-maven-intro/finish/target/liberty/wlp/usr/servers/ServletSampleServer.
[INFO] CWWKM2001I: Invoke command is [/git/guide-maven-intro/finish/target/liberty/wlp/bin/server, start, ServletSampleServer].
[INFO]
[INFO] Starting server ServletSampleServer.
[INFO] Server ServletSampleServer started with process ID 18867.
[INFO] Waiting up to 30 seconds for server confirmation:  CWWKF0011I to be found in /git/guide-maven-intro/finish/target/liberty/wlp/usr/servers/ServletSampleServer/logs/messages.log
[INFO] CWWKM2010I: Searching for CWWKF0011I in /git/guide-maven-intro/finish/target/liberty/wlp/usr/servers/ServletSampleServer/logs/messages.log. This search will timeout after 30 seconds.
[INFO] CWWKM2015I: Match number: 1 is [10/26/19 10:16:29:999 CEST] 00000020 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The ServletSampleServer server is ready to run a smarter planet. The ServletSampleServer server started in 1.286 seconds..
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.408 s
[INFO] Finished at: 2019-10-26T10:16:30+02:00
[INFO] ------------------------------------------------------------------------


Test server

[dave@localhost finish]$ pgrep -a java
18867 /usr/java/jdk1.8.0_231-amd64/jre/bin/java -javaagent:/git/guide-maven-intro/finish/target/liberty/wlp/bin/tools/ws-javaagent.jar -Djava.awt.headless=true -Djdk.attach.allowAttachSelf=true -jar /git/guide-maven-intro/finish/target/liberty/wlp/bin/tools/ws-server.jar ServletSampleServer


[dave@localhost finish]$ wget -O - http://localhost:9080/ServletSample/servlet
--2019-10-26 10:19:27--  http://localhost:9080/ServletSample/servlet
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:9080... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified
Saving to: ‘STDOUT’

-                                          [<=>                                                                         ]       0  --.-KB/s               Hello! How are you today?
-                                          [ <=>                                                                        ]      26  --.-KB/s    in 0s     

2019-10-26 10:19:27 (2.10 MB/s) - written to stdout [26]


Viewing all articles
Browse latest Browse all 181

Trending Articles