ring bearer
ring bearer

Reputation: 20783

How to install jwdp dependencies while using Jlink

I am creating a container with a spring boot application. Java and required modules are installed using jlink. It looks like this:

RUN jlink --compress=2 --no-header-files --no-man-pages \
     --add-modules java.base,java.desktop,java.instrument,java.logging,java.sql,java.xml \
     --output /opt/jre

and the entry point looks like:

ENTRYPOINT [ "sh", "-c", "java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -jar /app.jar"]

The container start up fails as the JVM can not find native library for jdwp. There is no documentation for jlink to include jdwp binaries. May be it is by design that a minimal run-time need not support debugging.

So I attempted to put the required library manually into /opt/jre/lib of the container. I copied libjdwp.so from a linux vm running OpenJDK 11 and placed that in to my container using:

ADD libjdwp.so /opt/jre/lib/

This caused a crash at start up:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000000001e66, pid=1, tid=6
#
# JRE version: OpenJDK Runtime Environment (Zulu11.33+15-CA) (11.0.4+11) (build 11.0.4+11-LTS)
# Java VM: OpenJDK 64-Bit Server VM (11.0.4+11-LTS, mixed mode, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C  0x0000000000001e66

Has anyone figured a consistent way to provide jdwp to java VM started with jlink ?

Upvotes: 4

Views: 1319

Answers (1)

Sameera P
Sameera P

Reputation: 51

You will need to add the jdwp openjdk module

RUN jlink --compress=2 --no-header-files --no-man-pages \
 --add-modules java.base,java.desktop,java.instrument,java.logging,java.sql,java.xml,jdk.jdwp.agent \
 --output /opt/jre

Upvotes: 5

Related Questions