AttachNotSupportedException when trying to start a JFR recording - jvm

I'm receiving AttachNotSupportedException when trying to start a JFR recording.
It was working normally, until now.
jcmd 3658 JFR.start maxsize=100M filename=jfr_1.jfr dumponexit=true settings=profile
Output:
3658:
com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
What might be happening?
SO: Oracle Linux Server release 6.7
$ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

One of the probable reasons is that /tmp/.java_pid1234 file has been deleted (where 1234 is PID of a Java process).
Tools that depend on Dynamic Attach Mechanism (jstack, jmap, jcmd, jinfo) communicate to JVM through a UNIX domain socket created at /tmp.
This socket is created by JVM lazily on the first attach attempt or eagerly at JVM initialization if -XX:+StartAttachListener flag is specified.
Once the file corresponding to the socket is deleted, tools cannot connect to the target process, and unfortunately there is no way to re-create communication socket without restarting JVM.
For the description of Dynamic Attach Mechanism see this answer.

With personal experience... This problem also occurs in scenarios where the development environment is divided into partitions, and the partition where the operating system is located is different from the operating system partition. Example, operating system partition is EXT4 and the development environment partition is NTFS (where the JVM is). Problem occurs because you can not create a file "/tmp/.java_pid6024" (where 6024 is the PID of the java process).
To troubleshoot add -XX: + StartAttachListener at the start of the JVM, or application server.

Another possibility: your app is running under systemd with 'PrivateTmp=yes'. This prevents the /tmp/.java_pid1234 file from being found.

Related

Jmeter remote testing exits too early

I have 3 instances in AWS with Jmeter installed - one master and two slaves.
I want to test 1M requests against my application. I have a script, which runs 100 threads concurrently 10,000 times.
When running the test on localhost or on a single instance only it runs fine.
My issue is that when I run the test using remote servers it exits immediately on both machines. The only logs I get from this are these:
Starting the test on host 10.229.48.10 # Mon Dec 02 15:21:49 UTC 2019 (1575300109383)
Warning: Nashorn engine is planned to be removed from a future JDK release
Finished the test on host 10.229.48.10 # Mon Dec 02 15:22:00 UTC 2019 (1575300120030)
I get nothing else even with verbose logging enabled.
This is the command I use to run the test:
JVM_ARGS="-Xms2048m -Xmx2048m" ./bin/jmeter -n -t test.jmx -R 10.229.48.10,10.
System load: 0.0 Processes: 122 │229.48.23
Both machines are fully open to the master instance.
Why does the script run fine on a single instance but craps out when using remote hosts?
The general checklist for troubleshooting JMeter master-slave configuration is:
Check jmeter.log file on the master and jmeter-server.log on the slaves
Ensure that Java version is the same on master and the slaves, if it is not the same - get the relevant (better latest) version of 64-bit JDK or Server JRE
Ensure that JMeter version is the same on master and the slaves, if it's not the case - get the relevant (better latest) version of JMeter
If your test is using any of JMeter Plugins - ensure that the same set of plugins is installed on all the machines. The plugins can be installed using JMeter Plugins Manager
If you're using any external data files, i.e. CSV files which are consumed by the CSV Data Set Config - the file(s) need to be copied over to all the slaves
If your test relies on some JMeter Properties make sure to supply the properties via -J or -D command-line arguments on all the machines or via -G command-line arugment on the master or put them into user.properties file
Which version of JDK are you using?
Is it JDK 8 or something else?
Make sure the following things,
a. Internal Networking is enabled in all three instances.
b. JDK 8 is installed from official resources.
c. You are able to communicate with the instances individually.
d. Installed JMeter from the official resource instead of "apt install jmeter"

Sat4j Remote Control window doesn't open

What happens:
I execute the following command.
java -jar sat4j-sat.jar -remote
No window opens, and I get a console output same as without the -remote flag, which begins:
c SAT4J: a SATisfiability library for Java (c) 2004-2013 Artois (...)
c This is free software under the dual EPL/GNU LGPL licenses.
c See www.sat4j.org for details.
c version 2.3.4.v20130419
c java.runtime.name OpenJDK Runtime Environment
c java.vm.name OpenJDK Client VM
c java.vm.version 24.65-b04
c java.vm.vendor Oracle Corporation
c sun.arch.data.model 32
c java.version 1.7.0_65
c os.name Linux
c os.version 3.2.0-4-686-pae
(...)
What is expected:
From readme.txt:
To run sat4j with on the fly configuration:
java -jar sat4j-sat.jar -remote
These instructions should open a java window named Remote Control. We
assume that the 1.5 version of the java command is in your path. If
it isn’t, then you should either specify the complete path to the java
command or update your PATH environment variable as described in the
installation instructions for the Java 2 SDK.
Other details
I have tried multiple versions of the library, up to 2.3.4.
My system is Debian 7 with Gnome 2.
My default Java installation is OpenJDK 1.7.0_65.
My secondary Java installation is Oracle Java 1.8.0_45 (with the same issue).
Gnuplot 4.6 is installed.
My first machine has a 32 bit dual core CPU with 2GB of RAM.
My second machine has a 64 bit quad core CPU with 8GB of RAM with nearly identical software.
Question
Has anyone used SAT4J's remote control feature? What is the problem with my method?
Update
On another machine (64 bit Debian 7) the window opens. After start dat files are created, but plotting does not start.
Update 2
I ran the generated instance.dimacs-gnuplot.gnuplot file manually from a gnuplot terminal, and I got the message unknown or ambiguous terminal type for the x11 type. I installed the gnuplot-x11 package, and now it works on the workplace machine: I can see the diagrams (wow!). Unfortunately on my home machines the Remote Control window still doesn't open.
The -remote parameter is used to display the remote control, i.e. to setup the various parameters of the solver.
If you want to always monitor what the solver is doing, you need to use in conjunction the -r parameter.
So the complete command line should be:
java -jar sat4j-sat.jar -r -remote file.cnf
You can get a fresh snapshot of Sat4j Sat on our continuous integration server:
http://bamboo.ow2.org/browse/SAT4J-DEF2-41/artifact/JOB1/nightly_build/
This might solve the issue you met with the 2.3.4 release.
Cheers,
Daniel

Error initializing JVM

I am getting "Could not reserve enough space for object heap" error when I am trying to start hybris server.
I have set
wrapper.java.additional.1=-Xmx1G
wrapper.java.additional.2=-XX:MaxPermSize=1024M
My machine is 64 bit 8GB RAM Windows
I faced the same problem once, The problem in my case was that too many other Applications were running on my system.
So go to the task manager and check the memory available use.
Close some applications and try running.
Also if you are using eclipse Then, In your eclipse.ini file (this is beside the eclipse executable), replace -Xmx256m with -Xmx1024m (or Xmx512m).
This is not compulsory but in certain cases it works.
If you are using some extension then,
Open YOURPATH/config/local.properties file.
Add the following entry:
config/local.properties
build.parallel=true
Save the file.
(In cases where we have multiple cores in the machine, we can tell hybris to utilize these by building in parallel and in certain cases this too works)
I too faced the same probelm. I followed below steps and set the max heap size to 1GB.
Add the following content to local.properties
tomcat.generaloptions=-Xmx4G -ea -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true -Djava.endorsed.dirs="%CATALINA_HOME%/lib/endorsed" -Dcatalina.base=%CATALINA_BASE% -Dcatalina.home=%CATALINA_HOME% -Dfile.encoding=UTF-8 -Dlog4j.configuration=log4j_init_tomcat.properties -Djava.util.logging.config.file=jdk_logging.properties -Djava.io.tmpdir="${HYBRIS_TEMP_DIR}"
ant clean all
start hybrisserver
Reference
https://launchpad.support.sap.com/#/notes/0002437669

How to Jprofile on linux system (No GUI)

I have Linux system where jprofiler installed.
I have to profile one running server and one client together which lying on same Linux system. I am sending 100+ different request from client to server.
My query is:
How to Automate whole jprofile process without GUI intervention?
When start the jprofiling, before 100 request submitted to client or after?
I haven't found config.xml (/root/.jprofiler8) after installing jprofiler in Linux system. How to create it?
How to create session without GUI?
To analyse the jprofiler output I will copy on window system and will use GUI jprofiler.
Thanks in advance,
Edit-1
I can automate profiling procedure step 4 and 5 from below. All below steps are correct or not?
Configure session using GUI as you suggested on yours reply (Session->Integration Wizards->New Remote Integration)
export session using GUI as you suggested on yours reply (Session->Export Session Settings).
Copy config.xml from window to Linux where jvm are running.
Run jpenable in linux system like below:
jpenable --pid=8568 --noinput --offline --config=/home/myuser/config.xml --id=106
Run jpcontroller in Linux system like below and Save snapshot:
jpcontroller 8568
Copy snapshot output from Linux system to window and open snapshot(Session-> Open Snapshot) using jprofiler for further analysis.
Edit-2
-agentpath VM parameter added in start script instead of using my step 4. Now, can I start my created session to use JProfiler GUI instead of using my step 5-6? I am receiving connection error when select and start my session.
Session -> Start Center -> Select and Start session (e.g. id="138" name="Remote application on linux1")
Also, I ran "netstat -a | grep 8849" on Linux system but didn't get any result/output.
Replaced and executed step 4 like below:
linux1:/var/opt# su myuser
myuser#linux1:/var/opt> java -Xmx2g -agentpath:/opt/jprofiler8/bin/linux-x64/libjprofilerti.so=offline,id=138,config=/home/myuser/.jprofiler8/config.xml -classpath /opt/jprofiler8/bin/agent.jar -jar /opt/myapp.jar
JProfiler> Offline profiling mode.
JProfiler> Protocol version 41
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Using config file /home/myuser/.jprofiler8/config.xml (id: 138)
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
SLF4J: Class path contains multiple SLF4J bindings.
MyApp started
But, I am able use JProfiler GUI if i followed below steps instead of using my step 1-2-3-4-5-6 and it's not offline:
Step 1:
Go to Linux jprofiler
myuser#linux1:/opt/jprofiler8/bin> ./jpenable
Select a JVM:
myapp.jar [29389] [1]
myapp2.jar [29228] [2]
1
Please select the profiling mode:
GUI mode (attach with JProfiler GUI) [1, Enter]
Offline mode (use config file to set profiling settings) [2]
1
Please enter a profiling port
[31757]
You can now use the JProfiler GUI to connect on port 31757
Step 2:
Go to window jprofiler
Session -> New session -> [Attach (Squire shape Button) -> Attach to profiled JVM (radio button) --> Host: linux1 --> Profilling port: 31757 --> OK]
You cannot create the triggers without a GUI. The idea is to configure the session locally on your desktop machine by invoking
Session->Integration Wizards->New Remote Integration
from the main menu. Select "Profile offline" in the "Startup mode step". The wizard will give you the VM parameter that you have to add on the remote side and create a new session on which you can configure triggers.
After that, export the session by invoking
Session->Export Session Settings
from the main menu and copy that config file to the remote server into the directory that you specified on the "Config synchronization" step of the wizard.

install run Tomcat on VPS/Burstnet

What is the minimum memory requirement to start JVM?
I have the cheapest VPS Burstnet (512mb memory) and installed java.
When I type java, it says
$java
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
When I type top, there is still around around 400MB free memory.
The support tells me the only solution is to increase my memory, I doubt his suggestion. In case it is caused by insufficient memory,I tried to create a swap file, however swap file is not allowed due to my VPS runs on OpenVS, and OpenVs does not allow swap files. http://writereadspread.blogspot.com/2010/08/swap-on-vpsopenvs.html
I would be very much appreciated if you can answer any of the following questions:
What is the cause of the issue?
What is the minimum memory requirement for installing JRE and JDK?
If u r running java apps on VPS, what is your memory, and which host r u using?
To run Tomcat on VPS:
* if openjkd installed, uninstall
* install sun-java linux installation
* install tomcat
* run export JAVA_OPTS="-XX:MaxPermSize=64m -Xms16M -Xmx64m"
* start Tomcat ./startup.sh