How to use the GraalVM Native Image Agent with Quarkus? - quarkus

I'm trying to figure out how to use the GraalVM native image agent with a Quarkus app running via mvn quarkus:dev.
I tried running:
mvn quarkus:dev -Djvm.args="-agentlib:native-image-agent=config-output-dir=native-image-config"
However I get the error:
ERROR: JDWP unable to get necessary JVMTI capabilities.
Any tips?
My version of Java:
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03)
OpenJDK 64-Bit Server VM GraalVM CE 20.2.0 (build 11.0.8+10-jvmci-20.2-b03, mixed mode, sharing)

By default mvn quarkus:dev enables debug with -Xrunjdwp, something like -Xrunjdwp:transport=dt_socket,address=0.0.0.0:5005,server=y,suspend=n
Then you stumble upon an issue described in this answer -- in short JDWP and JVMTI don't seem to work together well.
You can disable debug with passing -Ddebug=false and then it works. Something like this:
mvn quarkus:dev -Ddebug=false -Djvm.args="-agentlib:native-image-agent=config-output-dir=native-image-config"

Related

springboot 3 graalvm native image stuck forever: mac m1

I am using spring boot 3.0.2 and I am using native-maven-plugin.
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.19</version>
</plugin>
when I try to build a graalvm native image with this command
./mvnw -Pnative spring-boot:build-image
The process runs for a while and then it is just waiting at this stage forever.
[INFO] [creator] Executing native-image -H:+StaticExecutableWithDynamicLibC #/workspace/META-INF/native-image/argfile -H:Name=/layers/paketo-buildpacks_native-image/native-image/com.example.spring6.Spring6Application -cp /workspace:/workspace/BOOT-INF/classes:/workspace/BOOT-INF/lib/spring-boot-3.0.2.jar:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-3.0.2.jar:/workspace/BOOT-INF/lib/logback-classic-1.4.5.jar:/workspace/BOOT-INF/lib/logback-core-1.4.5.jar:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.19.0.jar:/workspace/BOOT-INF/lib/log4j-api-2.19.0.jar:/workspace/BOOT-INF/lib/jul-to-slf4j-2.0.6.jar:/workspace/BOOT-INF/lib/jakarta.annotation-api-2.1.1.jar:/workspace/BOOT-INF/lib/snakeyaml-1.33.jar:/workspace/BOOT-INF/lib/jackson-databind-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-annotations-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-core-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.14.1.jar:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.14.1.jar:/workspace/BOOT-INF/lib/tomcat-embed-core-10.1.5.jar:/workspace/BOOT-INF/lib/tomcat-embed-el-10.1.5.jar:/workspace/BOOT-INF/lib/tomcat-embed-websocket-10.1.5.jar:/workspace/BOOT-INF/lib/spring-web-6.0.4.jar:/workspace/BOOT-INF/lib/spring-beans-6.0.4.jar:/workspace/BOOT-INF/lib/micrometer-observation-1.10.3.jar:/workspace/BOOT-INF/lib/micrometer-commons-1.10.3.jar:/workspace/BOOT-INF/lib/spring-webmvc-6.0.4.jar:/workspace/BOOT-INF/lib/spring-aop-6.0.4.jar:/workspace/BOOT-INF/lib/spring-context-6.0.4.jar:/workspace/BOOT-INF/lib/spring-expression-6.0.4.jar:/workspace/BOOT-INF/lib/reactor-netty-http-1.1.2.jar:/workspace/BOOT-INF/lib/netty-codec-http-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-common-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-buffer-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-transport-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-codec-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-handler-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-codec-dns-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-native-macos-4.1.87.Final-osx-x86_64.jar:/workspace/BOOT-INF/lib/netty-resolver-dns-classes-macos-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.87.Final-linux-x86_64.jar:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-transport-classes-epoll-4.1.87.Final.jar:/workspace/BOOT-INF/lib/reactor-netty-core-1.1.2.jar:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.87.Final.jar:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.87.Final.jar:/workspace/BOOT-INF/lib/spring-webflux-6.0.4.jar:/workspace/BOOT-INF/lib/reactor-core-3.5.2.jar:/workspace/BOOT-INF/lib/reactive-streams-1.0.4.jar:/workspace/BOOT-INF/lib/slf4j-api-2.0.6.jar:/workspace/BOOT-INF/lib/spring-core-6.0.4.jar:/workspace/BOOT-INF/lib/spring-jcl-6.0.4.jar:/workspace/BOOT-INF/lib/spring-boot-jarmode-layertools-3.0.2.jar com.example.spring6.Spring6Application
I am using macbook pro m1. My java version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13, mixed mode, sharing)
For native image command is mvn -Pnative native:compile
With the native profile active, you can invoke the native:compile goal to trigger native-image compilation:
$ mvn -Pnative native:compile
The native image executable can be found in the target directory.
Source
The command you used is spring-boot:build-image which is generating docker image and running the native image under docker. if that command is stucking at some point it means docker is not responding or something freezing that side. Check this doc for further details.
Last note please do not use version number in native-maven-plugin plugin. pom should look like this
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>

Why I couldn't run same installed app on IDE integrated terminal even I could run on default terminal

I just switch to try develop on Linux for a while.
But one thing I couldn't understand how to solve it, as I mentioned in topic.
I'm going to develop a project that need Java SDK, then I installed the SDK with command:
#bash
sudo apt install openjdk-17-jdk-headless
After installation finished, I could run command java -version and javac -version to see the result of installation and it looks OK.
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+7-Ubuntu-0ubuntu0.22.04.1)
OpenJDK 64-Bit Server VM (build 17.0.3+7-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)
And then when I open IDE (Intellij IDEA) and it has feature of integrated terminal. (see picture)
But when I try to test java -version it was shown the error:
bash: java: command not found
As you can see from picture, I run java -version on terminal it return output properly, but when I run the same command java -version, it output with error message, like it couldn't find the java SDK that I installed.
Could anyone help me to describe the reason and solutions to solve the issue?
P.S. This is same on VS Codium.
I found the answer.
Solution:
Install the IDE app with the file from official website instead of using package manager of OS.
Description:
The cause is I installed the IDE via Package Manager of OS (here I'm using Pop_OS, install via Pop!_Shop)
And its package manager has some strict rules for security purpose.
I'm not sure, Pop_OS using which package manager, but I'll raise Flatpak as reference: https://docs.flatpak.org/en/latest/sandbox-permissions.html
And on blacklisted directories, my installed java command is under /usr/bin/ which is in blacklist.

Xcode fails to trigger ./gradlew script for KMM project in bigSur

This is my output when I try running my Xcode KMM project
jenv global -> openjdk version "1.8.0_212"
java -version -> {
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)
oracle64-11.0.10
}
echo $JAVA_HOME -> ***Nothing comes here***
./gradlew :shared:packForXCode -PXCODE_CONFIGURATION=${CONFIGURATION}
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/ch/AndroidStudioProjects/Test4001/androidApp/build.gradle.kts' line: 1
* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.
----<<<<>>>>-----
Anywhere in my Terminal:
java -version -> {
java version "11.0.10" 2021-01-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)
}
jenv global -> oracle64-11.0.10
echo $JAVA_HOME -> /Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home
I would like to understand how and why Xcode could be picking up the wrong version, obviously besides the fact that it can't find JAVA_HOME
It looks like this happens because xcode can't find the setup java version and gets some sort of default value.
If you would try to run your xcode project right now (I only reproduced this on BigSur) it will not work because the java version will show as outdated.
If you inspect with jenv or java you will find that your innner project folders and general version of java are setup correctly.
To fix this I just add an "export JAVA_HOME=$(/usr/libexec/java_home -v)" or "source ~/.zshrc" or "source ~/.bash_profile" before your run your scripts in Xcode
Of course the global version or your java_home must be in the correct java version you want to use

How to run sonarqube on NetBSD

According to the requirements document for sonarqube:
The only prerequisite for running SonarQube is to have Java (Oracle JRE 7 onwards or OpenJDK 7 onwards) installed on your machine.
I want now to use a NetBSD 7.0 machine to run a sonarqube server.
OpenJDK8 is installed:
openjdk version "1.8.0_77-internal"
OpenJDK Runtime Environment (build
1.8.0_77-internal-pkgsrc_1.8.77-b00)
OpenJDK 64-Bit Server VM (build 25.77-b00, mixed mode)
However, sonarqube is using wrapper, and that software does not support NetBSD (FreeBSD is supported, but this is not close enough to serve as a working substitute).
I already tried using linux emulation mode. But, having a NetBSD native java being started from a linux emulated wrapper is not giving a usable configuration for runtime environment (libc version clashes, et. al.).
And installing a linux native openjdk8 and get the complete setup running in emulation mode is also not to be recommended.
With sonarqube 4.x (long ago) I had used war distribution
and this worked OK. But with this new environment I hoped for being able to use newer versions of sonarqube.
Questions:
Is there a way to bypass wrapper and start sonarqube relying on java only?
Alternatively, is there a way to get a NetBSD version of wrapper?
Would I be better of dropping sonarqube alltogether,
given my target platform?
The version of Java Service Wrapper used by SonarQube does not support NetBSD. That's not as critical as for MSWindows. SonarQube can be easily started as a unix daemon without it. You just have to execute java -jar lib/sonar-application-{version}.jar from the installation directory.

Trying to figure out why the Informix JDBC driver won't install

While trying to install Informix's JDBC driver, I get this error:
java -cp /home/ics/sandbox/jdbc/setup.jar run -console
The wizard cannot continue because of the following error:
could not load wizard specified in /wizard.inf (104)
I have pointed to a newer Java from Sun using:
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_05
export PATH=$JAVA_HOME/bin:$PATH
java -version
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)
Pointing to a newer Java and, as IBM/Informix support told me, getting away from OpenJDK should allow the installer to run, but that does not work. I also saw using Sun's or IBM's java elsewhere, when I searched for posts on the specific error. On another Centos System, OpenJDK is installed, and I can install the JDBC driver successfully
I also tried removing tty settings from my environment, which also did not work.
Here is the so post where this error is mentioned.
If anyone has heard of a solution, I'd love to hear it, 'cause without the jdbc driver, there's no Clojure database work with Informix, and, when working, it works well. And, I have thought of tarring and zipping the good install and moving it, but that's kind of cheating.
This problem occurs on
cat /etc/redhat-release
CentOS release 6.4 (Final)
The installed java version, not my workaround newer version is
java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.11.90) (rhel-1.62.1.11.11.90.el6_4-i386)
OpenJDK Server VM (build 20.0-b12, mixed mode)
Until an answer arrives that allows an install, I took #MichaƂ Niklas 's suggestion and manually installed the driver under /opt/ on the new system. This worked.
I am still going to pursue the cause of this problem. I edited the OP to reflect #ceinmart 's suggestion to remove tty settings. This did not work, but I found it a useful suggestion.

Resources