VisualVM shows "Not supported for this JVM" - java

I am trying to profile a remote JVM with VisualVM 1.4. I am running macOS High Sierra 10.13.6 locally, with the following OpenJDK version:
java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.181-b13, mixed mode)
The server runs Debian Stretch with the following OpenJDK:
java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-2~deb9u1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
When I monitor a JVM process locally, I see all these tabs and the profiling works just fine.
However, if I do that remotely, I see something like this:
Note the CPU window that says "Not supported for this JVM" and the reduced tabs, not including "Profiler". However, as you can see, I do see some data.
I am connecting via jstatd. On the server, following this article, I am running
jstatd -J-Djava.security.policy=/home/brandwatch/jstatd.all.policy -J-Djava.rmi.server.hostname=10.2.156.160 -Djava.rmi.server.logCalltrue
Answers like this indicate that this might be due to different JVM versions, however, mine appear to be the same, despite one of them running on MacOS and one of them on Debian.

Missing CPU usage information has nothing to do with with different JDK versions. You don't see CPU usage data because jvmstat (exported via jstatd) does not provide such information. If you want to see CPU usage, you need to use JMX connection. JMX will also allow you to do CPU and Memory sampling. Profiling is supported for local applications only.

Because, as Tomas Hurka's answer correctly indicates, remote profiling does not work with VisualVM, I have used a little hack to still make it work: I have installed VisualVM on the remote server and accessed it via X-forwarding. That way, VisualVM can access the process locally an thus profile it.
ssh into the server with the -X flag
ssh -C -X <user>#<host>
download [VisualVM 1.4][8]
wget https://github.com/visualvm/visualvm.src/releases/download/1.4/visualvm_14.zip
unzip the archive
unzip visualvm_14.zip
run VisualVM
./visualvm_14/bin/visualvm
After a few seconds you should see a VisualVM window pop up. It's not very fast (just because x-forwarding is not), but for my use case it was alright.
Another way of achieving this might be using VNC, but I haven't tried that. The downside would be that you have to install all the desktop packages, which one might not want on a server.

Related

zap is not installing

i dont know why its not installing i dont know what to do error image
its showing this i did instal java 64 bit jre its not working please hele me
i tride to delete and install again it did'nt work
i delete it many times and install
still its not installing zap its showing the same thing locate java 64 bit file
i also tride to locate the file it did'nt work but i dont know where the file is if i know where the file is its not selecting the file
Based on the error message:
You didn't install a JRE >= Java 11.
You installed a 32bit JRE.
Your JRE can't be found. (If you're using Adopt OpenJDK or Temurin, etc. [I can't think of all of them.] there's an option to set JAVA_HOME and JavaSoft registry keys, you should enable those. Plus may need to reboot before installing [thanks Windows 🤷‍♂️].)
I have had this issue myself. ZAP really is a PITA on Windows. One thing I noticed is that on my Windows host, which will not run the ZAP installer, I'm using Oracle's Java:
C:\Users\Administrator>java -version
java version "1.8.0_361"
Java(TM) SE Runtime Environment (build 1.8.0_361-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.361-b09, mixed mode)
on my Linux host which runs it fine:
──(kali㉿PwnBox)-[~]
└─$ java -version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10-Debian-1)
OpenJDK 64-Bit Server VM (build 17.0.6+10-Debian-1, mixed mode, sharing)
So I deduce the difference is that ZAP doesn't like Oracle's JRE and wants OpenJDK/JRE. Thankfully, there are builds available for Windows here:
https://learn.microsoft.com/en-us/java/openjdk/download
So give that a go. In my instance I have other software that depends on Oracle's JRE, so I do not want to endanger that apps reliability by installing another JRE. So I just use ZAP 2.12 on my Linux host and ZAP 2.11 on Windows, which runs fine in Oracle JRE.
Side Note:
ZAP really is half-baked. As far as web app testing goes, I pay for BurpSuite Pro because it's so vastly superior in every measurable way. I have all kinds of headaches with ZAP and it's always a battle. That's if it can even finish a scan without crashing on larger apps (it usually can't).
Anyway, I hope this helps. But I would also suggest seeking out alternatives to ZAP until the developers get their act together. Then again, I guess you get what you pay for, so......

Java exits abruptly on a Windows 11 VM (host is M1 Mac)

I'm having a very odd issue with Java exiting abruptly and randomly.
I have a Macbook with M1 system (2021 model), with 32GB RAM. I'm running a Windows 11 (ARM64 Insider Preview) VM with Parallels. I have 16GB of RAM allocated for the VM, and 6 cores. I have Liberica JDK 8 (full with JavaFX) installed both on the host and the VM. I'm developing a multi-module Maven project, same project on both the host side and the VM side (the project depends on some Windows side things for some tasks, which is the reason I'm running the Windows VM on the side).
Output from java -version:
openjdk version "1.8.0_332"
OpenJDK Runtime Environment (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode)
I've also tried with Azul JDK and had the same issue with it.
On the host side everything works as it should. Maven and Java commands both run successfully with no interruption or issues. On the Windows VM side however, it seems that Java just randomly exits with no error logs or anything really. I noticed it just hangs for a few seconds, and then just exits abruptly. I noticed that it may happen while running a Maven command, or for example running a .jar package with java -jar. Here's a picture of what it looks like (same happens on the picture above though):
A couple weeks back I had no issues at all. But then I had to reinstall Parallels and the VM (reinstalled the whole W11 OS), and suddenly these issues started occurring. I've tried adding -XX:+HeapDumpOnOutOfMemoryError to MAVEN_OPTS environment variable to see if it's a OutOfMemoryError, but it did not seem to have any results.
Any ideas?
In case anyone runs into this issue: I was able to resolve this issue by installing the Windows 11 VM into Parallels from an image downloaded from UUP Dump.
I tried reinstalling the VM downloaded from the Microsoft's Insider Preview page, but the issue still persisted and nothing seemed to be able to fix it. Java still exited randomly pretty frequently.
I downloaded the latest Windows 11 image from UUP Dump and installed that one instead. Installed the exact same versions of Maven, Java, Groovy etc. and surprisingly, the issue vanished. I've been able to run Java on my VM for a day now without issues, whereas with the image downloaded from Microsoft I was able to reproduce the issue pretty much within minutes after configuring my environment and cloning the Git repo of the project I'm developing.
A lot improved for me after switching to ARM64 Java (Microsoft's was first one I found, there may be others).
Some background: not sure if I had exactly the same issue, but vscode compiling and code checking was slow and unreliable, and my Mendix Java application kept crashing or not even starting. Since that uses Java 11, that's what I installed the ARM64 version of. This is in Windows 11 ARM, from Microsoft's Preview page, updated (hang the first try, but worked the second).

How can I install Native JAI on Geoserver 2.20.x. & Geoserver 2.19.x

I'm currently setting up two Geoservers running on two separate Linux machines. One of the Geoservers is running version 2.20.2. and the other one is version 2.19.5.
I'm trying to install Native Jai and Native JAI ImageIO in order to increase the image handling performance.
Both machines are running Ubuntu 20.04.4 LTS.
java -version
openjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
So far I've followed these instructions: https://download.java.net/media/jai/builds/release/1_1_3/INSTALL.html
Specifically this part: The instructions I followed
It's still not working.
echo $JAIHOME
/var/lib/JAI/jai-1_1_3/lib
echo $CLASSPATH
/var/lib/JAI/jai-1_1_3/lib/jai_core.jar:/var/lib/JAI/jai-1_1_3/lib/jai_codec.jar:/var/lib/JAI/jai-1_1_3/lib/mlibwrapper_jai.jar
echo $LD_LIBRARY_PATH
.:/var/lib/JAI/jai-1_1_3/lib:/var/lib/JAI/jai-1_1_3/lib/jai_core.jar:/var/lib/JAI/jai-1_1_3/lib/jai_codec.jar:/var/lib/JAI/jai-1_1_3/lib/mlibwrapper_jai.jar
This is the Geoserver status page in case there is any relevant information: Geoserver status
Any help would be greatly appreciated.
I'm not sure why that section still appears in the manual - it is no longer needed or recommended, but is clearly marked as outdated.

How to get profile tab in VisualVM cross-platform?

Target to profile is an ARM 32-bit:
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) Server VM (build 25.111-b14, mixed mode)
My development machine is a crapbook running a totally different arch, bits, JVM etc, but VisualVM is running as:
Java: 1.8.0_112; Java HotSpot(TM) 64-Bit Server VM (25.112-b16, mixed mode)
My problem is that I don't have the profile tab that I want, although I do have the sampler tab (which I don't want to use).
I have all following debug and JMX -D arguments on my target machine:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=4000
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=3333
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Djava.rmi.server.hostname=10.223.64.109
Can anyone suggest why I'm not getting the profile tab?
Many thanks
So I think I've answered my own question now, after finding this nugget on: https://visualvm.java.net/applications_remote.html
From other research, it looks like VisualVM and a local JVM communicate using files that are dropped in the java.io.tmp directory. Files with local process IDs are dropped. Maybe profile data is too vast to be transported over a network, or that the profiling procedure needs the timeliness of something being written to file by the JVM and observed immediately by VisualVM.

java on "server" linux: Is there any way to run in client mode?

I'm running a java web server as an internal component of another project, and unfortunately java insists on running in server mode (i.e. fast, and huge memory footprint), even when I pass the -client switch.
This is a problem because java takes up so much memory that my whole project is killed by the server.
I'm running java with the command:
java -client -classpath /home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/commons-fileupload-1.2.2.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/fop-20120125.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/xmlgraphics-commons-1.5svn.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/batik-all.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/docx4j-nightly-20120105.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/spark-0.9.9.3-SNAPSHOT.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/slf4j-log4j12-1.6.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/slf4j-api-1.6.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/jetty-webapp-7.3.0.v20110203.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/servlet-api-3.0.pre4.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/antlr-2.7.7.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/commons-codec-1.6.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/docx4j-2.7.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/poi-scratchpad-3.8-beta4.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/xalan-2.7.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/antlr-runtime-3.3.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/commons-io-2.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/serializer-2.7.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/xml-apis-1.3.04.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/avalon-framework-api-4.3.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/commons-lang-2.4.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/log4j-1.2.15.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/stringtemplate-3.2.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/avalon-framework-impl-4.3.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/commons-logging-1.1.1.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/poi-3.8-beta4.jar:/home/marcintustin/webapps/django/oneclickcosvirt/oneclickcos/java/wmf2svg-0.9.0.jar: Transcoder
java -version reports:
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
As I'm on a shared host, I can't install 32-bit compatibility libraries, so I can't use the 32-bit JRE. This turns out to be a problem because as confirmed by #birryree in the comments (thanks!), 64-bit JRE always runs in server mode.
Is there a way to force java to run in normal client mode?
Based on comments received (and testing), it seems that the 64bit JVM ALWAYS runs in server mode, which means that it is VERY profligate with memory.
The work-arounds are:
Get the 32bit JVM (and appropriate compatibility libraries if on Linux); or
Use the -X options to limit memory to a certain maximum.

Categories

Resources