panga / hammock-jpms

Hammock MicroProfile (CDI + JAXRS + JSON) HelloWorld using Java Module System (JPMS)

Home Page:https://medium.com/criciumadev/first-microprofile-io-application-using-java-module-system-33b83ae939c9

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hammock JPMS

Hammock MicroProfile (CDI + JAX-RS + JSON) HelloWorld using Java Module System (JPMS).

The stack uses Weld 3 for CDI, RestEasy 3.5 for JAX-RS and Johnzon 1.1 for JSON

The total size of this example application is around 12mb and the full Docker image is only 55mb!

Note: Tested with JDK 11-ea+23

How To

Package and generate target/modules folder (weld profile)

mvn clean package

Package and generate docker image (docker + weld profiles)

mvn clean package -Pweld,docker

Package using with OpenWebBeans 2 for CDI (owb profile)

mvn clean package -Powb

Run using the default JRE

java --module-path target/modules --module hammock.jpms

Run using a minimal JRE (35mb)

  1. Run jlink to create minimal JRE
jlink \
	--add-modules java.logging,java.xml,java.naming,java.management,jdk.unsupported \
	--verbose \
	--strip-debug \
	--compress 2 \
	--no-header-files \
	--no-man-pages \
	--output target/jlink-image
  1. Run minimal JRE with patch module for java.beans:
target/jlink-image/bin/java \
    --patch-module java.base=target/patch/java.beans \
    --add-exports java.base/java.beans=johnzon.mapper \
    --add-exports java.base/java.beans=org.apache.logging.log4j.core \
    --module-path target/modules \
    --module hammock.jpms

Note: https://github.com/panga/lite-beans was used to patch java.beans implementation required by some 3rd party dependencies and remove the requirement of adding java.desktop module into the minimal JRE.

Run using the Docker image

docker run --rm -it -p 8080:8080 hammock-jpms

Test the application

curl http://localhost:8080/hello

About

Hammock MicroProfile (CDI + JAXRS + JSON) HelloWorld using Java Module System (JPMS)

https://medium.com/criciumadev/first-microprofile-io-application-using-java-module-system-33b83ae939c9

License:Apache License 2.0


Languages

Language:Java 52.6%Language:Dockerfile 47.4%