CPU and profiling not supported for remote jvisualvm session - java

When monitoring a remote app (using jstatd) I can neither profile nor monitor CPU consumption. Heap monitoring (provided I do not use G1) works. jvisualvm provides the message "Not supported for this JVM." in the CPU graph window.
Is there anything missing in my setup? Google showed very few results.
The local environment (Mac OS X 10.6):
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03-219)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02-90, mixed mode)
The remote environment (Linux version 2.6.16.27-0.9-smp (gcc version 4.1.0 (SUSE Linux))):
java version "1.6.0_16" Java(TM) SE
Runtime Environment (build
1.6.0_16-b01) Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
Local monitoring works as advertised.

Remote profiling of code and allocation isn't supported by Visual VM. This sucks, however if you want to enable the CPU graph you can do this by enabling JMX with
-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=12345
You may need to add some authentication settings too based on your network. The JMX settings will give you the CPU usage, and thread state, as well as doing a remote jstack.
A list of features for the remote version can be found here:
Visual VM features
EDIT
Get the latest version of visual vm 1.2.1 and download the VisaulVM-Sampler. This will read from a JMX connection to show the profiling information.

Connecting the eclipse java program.
Step 1: ensure your Eclipse -> Preferences -> Java -> Installed JREs is pointing to the same jdk where you have started the visualvm.
Step 2: Ensure Right click -> Run configuration has the following
-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=16001
Step 3: Importantly follow the below suggestion.
https://visualvm.java.net/troubleshooting.html#jpswin2
Description: An error dialog saying that local applications cannot be monitored is shown immediately after VisualVM startup. Locally running Java applications are displayed as (pid ###).
Resolution: This can happen on Windows systems if the username contains capitalized letters. In this case, username is UserName but the jvmstat directory created by JDK is %TMP%\hsperfdata_username. To workaround the problem, exit all Java applications, delete the %TMP%\hsperfdata_username directory and create new %TMP%\hsperfdata_UserName directory.
Also try JVMMonitor is decent plugin for eclipse stand alone program monitoring.

Is it because the remote version is (albeit slightly) greater than the local version?

I'm able to resolve this issue by providing same port number for JMX and RMI.
-Dcom.sun.management.jmxremote.port=29898
-Dcom.sun.management.jmxremote.rmi.port=29898
See Why Java opens 3 ports when JMX is configured?

Related

Can't start the Elastic service in Windows 10

Similar question to this one but with a different OS. I've installed the latest Java and verified by:
> java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
I also make sure that JAVA_HOME is set as system variable and verify it by:
> $env:java_home
C:\Program Files (x86)\Java\jdk1.8.0_192
Then, I tried both ZIP installation and MSI installation of the Elastic Windows Service. It's installed but doesn't run. When forced manually, it says that it can't do that on the local system (1067, the process terminated unexpectedly).
I tried to reinstall all the relevant components. I tried scm /scannow and reimporting the keys into registry. I tried to re-set the user and system environment variables. Etc. I'm out of ideas.
I noticed that there's no logs directory in Elastic installation root. Also, there's no configuration files in that directory as far I could see. Where exactly should they be located so I can check what's logged and play around with different settings.

Install java plugin in chrome in Ubuntu 14.04

I have installed Oracle Java 7 in my /home directory by following steps given here (by just changing the path of installation). But still I cannot see the plugin listed in the chrome://plugins tab.
I also cannot see it running in JavaTester or here. I have tried enabling by following steps provided here but nothing works.
Some specifications:
Operating System: Ubuntu 14.04
output of java -version:
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
Please comment if anything more is needed for resolving the problem
Just pull it from webupd8 servers. Follow the directions at the following link.
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
Also, this belongs on a different forum. This forum is for programming questions, installing a chrome plugin isn't really what we do. Next time post to the Ubuntu stack exchange located here.

Can not start Integrated WebLogic server in Oracle Jdeveloper 12c

I got homework to create Oracle ADF applications according to the instructions on oracle.com, specifically there: http://docs.oracle.com/cd/E37547_01/tutorials/tut_rich_app/tut_rich_app_2.html
But in step 10, I can not start IntegratedWeblogic server.
Log with fails is there: http://www.sendspace.com/file/v9l7vy
My bare idea is diacritical marks and space in my Windows username 'Petr Mojžíš'. I use Microsoft account to login to Windows, which create this anomaly.
I use Windows 8.1 64bit in English version and Oracle JDeveloper 12c.
Thank you for your advice
Modify %HOME%\oracle_common\common\bin\commEnv.cmd file setting USER_MEM_ARGS environment variable after ":continue" tag and re-create default domain again from Application Servers view on JDeveloper.
SET USER_MEM_ARGS=-Xms32m -Xmx1024m -XX:MaxPermSize=512m -XX:MaxHeapSize=512m
Try to set a system environment variable JDEV_USER_HOME and point it to a path in your directory D:\JDEV_USER_HOME . But this way the Jdeveloper related information is stored in the D:\JDEV_USER_HOME rather than AppData under user directory .
The problem is that you have your Weblogic in directory that has both special characters and spaces C:\Users\Petr Mojžíš\AppData\Roaming\JDeveloper\system12.1.2.0.40.66.68\DefaultDomain
In order to overcome this, Close your JDeveloper, create a new Environment variables JDEV_USER_HOME which points to a directory without any spaces or special characters. Open JDeveloper again and you should be good to go.
I had experienced a situation with the integrated weblogic server goes to the point when it says it is and it stops there, jdeveloper does not exit task. Making it impossible to deploy apps.
Possible solution.
It seems that it might have to do with Environment settings.
I changed the JAVA_HOME to point to the one in %ORACLE_HOME%\oracle_common\jdk and set the path to %JAVA_HOME%\bin and it seems to solve the issue.
Previously I was on
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
and now on
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Change Default Java VM to Client

I installed Oracle's Java on Fedora 17, and I noticed that when using the command java -version it returns this
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
Java seems to run the -server option by default. The help text came up as
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.
Is there any way to change the default to client?
The default setting is defined in the file jvm.cfg. A content like
-client KNOWN
-server KNOWN
defines the client as the default.
-server KNOWN
-client KNOWN
sets the server as the default.
Source: www.rgagnon.com/javadetails/java-0566.html
jvm.cfg location
Unknown Mac OS X version:
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/jvm.cfg
Mac OS X version 10.9 without installing JDK:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jvm.cfg
Mac OS X version 10.9 with installed JDK version 1.8.0_u92:
/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/jre/lib/jvm.cfg
You can find your jvm.cfg from the command line (Terminal.app) using the command $ locate /jvm.cfg. You might need to update your locate database first, using the command: $ sudo /usr/libexec/locate.updatedb
From the docs:
Note: For J2SE 5.0, the definition of a server-class machine is one
with at least 2 CPUs and at least 2GB of physical memory.
So there doesn't seem any way to alter the server-class machine detection technique, I'm guessing you will have to stick to passing the -client VM argument if you need it on your machine.
Also worth noting is that this page is for Java 5, so things might be different with Java 6 and higher.
Starting with Java 5, you can specify this as an option to the JVM:
the -client option will make the VM start in client mode. In this mode, the start-up will be much faster.
the -server option will make the VM start in server mode. The start-up will be slower, but in the long run, it will execute faster.
See this question for more details about the differences about the 2 modes.
If you do not specify these options, the VM will check to see if you have at least 2 CPUs and at least 2 GB RAM. If you do, then it will start in server mode.
You can see the tables about how these decisions are made:
here for Java 5
here for Java 6 and
here for Java 7
FYI: they are all the same.

How to make sure I'm using the "server" JVM?

Sun's JVM comes in two flavors: -client and -server, where the Server VM is supposed to be optimized for long running processes, and is recommended for server applications.
When I run java with no parameters, it displays the usage options, which includes the following text:
The default VM is server,
because you are running on a server-class machine.
Having seen this, I didn't bother to add the -server to the process startup command.
However, on a recent JVM crash log, I noticed the following line near the end of the file:
vm_info: Java HotSpot(TM) Client VM (14.0-b16) for linux-x86 JRE (1.6.0_14-b08), built on May 21 2009 02:01:47 by "java_re" with gcc 3.2.1-7a (J2SE release)
It seems to me that Java is using the Client VM, despite what it says in the help message. I'm going to add the -server option to my startup command, but now I'm suspicious. So my question is: is there a way to make sure that the VM I'm running in is really the Server VM, without resorting to forcing a JVM crash?
The OS is ubuntu 8.04, but I'm using JDK 1.6.0_14 which I downloaded from Sun's website.
You can do
System.out.println(System.getProperty("java.vm.name"));
Which on my machine returns either:
Java HotSpot(TM) Client VM
or
Java HotSpot(TM) 64-Bit Server VM
Of course you shouldn't do anything critical based on this value, as it will probably change in the future, and will be completely different on another JVM.
I had a very similar question which I asked on ServerFault. I would say, if you care which version is run, always use -client or -server.
Well, if you explicitly start with the -server command line prompt, you are running in server mode. You can check that with this:
ManagementFactory.getRuntimeMXBean().getInputArguments();
You can look at RuntimeMXBean which may open up more information, but that would have to be tested on the specific JVM you are running.
Without writing any single line of code, if you use JConsole to connect to your JVM, under 'VM Summary' tab, it should say exactly which (server or client) Virtual Machine is being monitored.
For example,
Virtual Machine: OpenJDK Server VM version 1.6.0-b09
To remotely monitor your JVM using JConsole, simply enable the JMX (Java Management Extensions) agent by starting JVM with the following System Properties
> java.rmi.server.hostname=[your server IP/Name] // without this, on linux, jconsole will fail to connect to the remote server where JVM is running
> com.sun.management.jmxremote.authenticate=false
> com.sun.management.jmxremote.ssl=false
> com.sun.management.jmxremote.port=[portNum]

Categories