JProfiler: Cannot detect remote JVM - java

I'm running Tomcat 9 (as user tomcat) with OpenJDK 11 on an Ubuntu 18.04 server. I'd like to be able to attach JProfiler 11 to the Tomcat process.
In the past, I've simply used the option to connect to a remote JVM via ssh, and JProfiler locates the process. On this machine, JProfiler never finds the Tomcat process.
I've tried using both the su and sudo options to switch to the tomcat user. I've even enabled login directly as tomcat. No matter what, JProfiler cannot locate the JVM process.
I think this is because the /tmp/hsperfdata_tomcat folder is empty. I've set -XX:+UsePerfData even though it should be enabled by default (trying both JAVA_OPTS and CATALINA_OPTS) but that didn't solve anything. I've checked the tomcat command line, there is nothing there to disable UsePerfData. I've also monitored the folder to see if somehow the hsperfdata gets populated but then deleted - the file is never created.
How do I enable profiling with Tomcat 9 on Ubuntu 18.04 with OpenJDK 11?
UPDATE:
Using jps -l -m running as tomcat returns no output. However running it as root does list the tomcat java process, despite no entry in /tmp/hsperfdata_tomcat.

I just ran into this exact issue. I was unable to see the JVM started under tomcat user: in jprofiler (11), switching to the tomcat user via sudo showed no JVMs.
It was a permission problem on the uploaded by jprofiler. jpenable is uploaded under my remote home directory to which tomcat has no access to.
Solution was to:
ssh to remove node (with same user as what jprofiler will use)
chmod 555 ${HOME}
chmod 555 -R ${HOME}/.jprofiler11. Tomcat user needs to access ${HOME}/.jprofiler11/agent/11082_11.0.2/jprofiler11/bin/jpenable and jar file in the same dir.
Test: sudo -u tomcat ${HOME}/.jprofiler11/agent/11082_11.0.2/jprofiler11/bin/jpenable
Then you'll be able to connect your laptop jprofiler to that tomcat user via remote ssh + sudo tomcat.

Related

Running Jenkins Node/Agent as a Windows Service with OpenJDK

I have a Windows virtual machine with OpenJDK 13 installed that I would like to setup as a Jenkins node/agent.
When I create the node configuration using the Jenkins UI and select Launch Method: Launch Agent by connecting it to the master it provides a link to download slave-agent.jnlp
On a system with the original jdk/jre older than version 9, which contains java web start, if I run that jnlp file, it brings up a window with a menu that includes an option File - Install as A Service
However, as OpenJDK (and I believe any JRE/JDK versions greater than 8) do NOT contain Java Web Start, I cannot seem to gain access to that option.
I am able to successfully run java -jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory" and have the node register with Jenkins, but it is not running as a service.
I had an older agent that was still using old version of JRE, so I looked at its Jenkins service configuration and unfortunately it seems to be relying on executable(s), .config file(s), and xml file(s), which I cannot determine the source of, beyond they must be created when running the "Install as a service" instructions from slave-agent.jnlp
I also attempted to use IcedTea-Web which is apparently supposed to be a Java Web Start replacement, but I've had no success.
Can anyone tell me how to setup a Windows machine running OpenJDK as a Jenkins node/agent with the Jenkins node/agent components running as a Windows service?
I had a similar issue and now I use NSSM.
Download NSSM
Open a cmd and install the service (I used JenkinsService as Servicename):
<path to nssm.exe>\nssm install <Servicename>
Insert the path to the jdk to the field Path
add the rest to the field Arguments:
-jar agent.jar -jnlpUrl https://jenkinsserver/blah/slave-agent.jnlp -secret blah -workDir "somedirectory"
Click on install the service
Now you can check the new service JenkinsService in the windows service manager. As soon as it's running you can check the connection to the master.
If you want to setup a Java base application as a service, I believe the best option would be to use Procrun from Apache. It is the exact method that Tomcat uses.

Wildfly service 10.0 and 10.1 cannot be stopped in Windows

We have successfully installed both Wildfly 10.0 and Wildfly 10.1 in Windows system (Windows 10 and Windows server 2008/2012) as a service but when we try to stop it this operation fails.
If we try to stop it from Windows Service Manager we get error 1053, instead if I launch service.bat stop from <WILDFLY_ROOT>\bin\service I get the error "Failed to load service service_name configuration". In both cases service remains forever in "Stopping" state in Windows services manager.
I now there are some documented issues like this but I have already done many trials.
In my service.bat for Wildfly 10 I have set both JBOSSUSER and JBOSSPASS variables to be used in shutdown command and I set them both with the ones used for Wildfly management console (I know that not setting up management console will prevent Wildfly from being stopped) and with a real Windows ones (my login account in Windows). I know they are correctly used as CREDENTIALS for shutdown when running .bat file.
That does not work.
Moreover, I thought the problem was caused as we have both JDK 6 and JDK 8 installed. JDK 8 is to run Widlfly while JDK 6 is still (unfortunately) used to develop our software. I set JAVA_HOME variable in jboss-cli.bat file to JDK 8 but that does not work too. For sure, java -version command prints 1.8.0_171 and echo %JAVA_HOME% commands prints path to jdk1.8.0_144
How can I solve this?

LD_LIBRARY_PATH cleared when logging in through xrdp

Background:
I am currently working in a Linux Virtual Machine on some Java plugins that I install into Eclipse by placing them into the /opt/eclipse/dropins folder. My plugins need to support both CentOS 6 and CentOS 7 VMs (shouldn't be a big deal since they are written in Java and both flavors of CentOS have Java 1.8.0 installed). My plugins build and install just fine on both OSs. I see them in Eclipse and can interact with them as expected.
The VMs I need to support can either be local to my machine (opened with VMWare Player/Workstation) or hosted on a cloud server. We use Windows Remote Desktop to get into the cloud VMs through xrdp on the Linux server.
Problem:
One of my plugins needs nddsjava.so from /opt/rti_connext_dds-5.2.3/lib/x64Linux3gcc4.8.2.
On both local VMs (CentOS 6 and 7), I can just set the LD_LIBRARY_PATH in an /etc/profile.d script so that any user that logs in can get the path to the required C++ library.
On CentOS 7 cloud VMs, however, when this plugin is invoked, I get java.lang.UnsatisfiedLinkError: no nddsjava in java.library.path. This happens only when opening Eclipse via the Linux menus. If I open a terminal and start Eclipse from there, the plugin can find the C++ library (because my LD_LIBRARY_PATH is set in my /bin/bash terminal). I did a little digging and found out that running chmod g-s /usr/bin/ssh-agent fixes the issue when opening Eclipse from the Linux menus (yes I understand that the chmod opens a security vulnerability. I am willing to look past this).
On CentOS 6 cloud VMs, I have never gotten the plugin to find the C++ library. LD_LIBRARY_PATH seems to get wiped when signing in through xrdp and for whatever reason, CentOS 6 appears to be explicitly not sourcing any of the profile scripts in the main top-level gnome-session process, which means other processes spawned from the GUI will not have LD_LIBRARY_PATH either.
I have also tried adding -Djava.library.path to my eclipse.ini file with no luck. It will fail on the next C++ library needed even though it lives in the same directory: java.lang.UnsatisfiedLinkError: /opt/rti_connext_dds-5.2.3/lib/x64Linux3gcc4.8.2/libnddsjava.so: libnddsc.so: cannot open shared object file: No such file or directory
Question:
Is there a single place that I can set my LD_LIBRARY_PATH for all flavors of Linux I am attempting to support (local CentOS 6, xrdp CentOS 6, local CentOS 7, and xrdp CentOS 7)?
Note: When I say cloud VM below, I mean server hosted VM in which I Windows-Remote-Desktopped into via xrdp.
This answer from server fault worked for me in the CentOS 6 cloud VM. The CentOS 7 cloud VM did not have the startwm.sh script in /etc/xrdp. Instead, it lived in /usr/libexec/xrdp and did not contain the xinitrc lines (referenced in the server fault link) causing the issue in the CentOS 6 cloud VM. Something else must be wiping the LD_LIBRARY_PATH variable in the CentOS 7 cloud VM, so I still needed to perform chmod g-s /usr/bin/ssh-agent to allow my /etc/profile.d script to be invoked on startup.

How do I monitor Tomcat6 with JVisualvm in Ubuntu Linux?

I'm trying to set up JVisualVm to monitor a Tomcat 6 instance (running on Ubuntu Server 10.04 LTS). I've seen other questions, but none of them directly answer my problem. I try to connect to Tomcat with JVisualvm and it comes back with a "Cannot connect" error - but there are TCP connections being made to the server; the server drops the connection after a short burst of traffic.
I have already added this to /etc/default/tomcat6 and restarted tomcat6
# This enables JMX in order to permit VisualVM to profile the JVM.
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=9090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
I started rmiregistry using default settings:
rmiregistry &
I haven't started jstatd; installing it on the server requires the full JDK which requires X libraries. I'm not about to install X just to get one single binary.
I wonder if not running jstatd would have something to do with it; I was of the impression that I needed neither RMI nor jstatd, as long as I could use JMX directly via the JMX port.
There is no firewall in between the server and the JVisualvm client, and the iptables host firewall is open. Using jconsole results in the same error.
Running JVisualVM against the local Ubuntu 10.04 machine (by using its IP address and JMX port) and adding a JMX instance works fine - and I'm running neither rmiregistry nor jstatd - though the monitor shows RMI threads running.
Question: What must I do (either on the server or the client) in order to be able to monitor Tomcat (and other Java programs) via JMX with JVisualVM?
Thanks in advance.
If there is no firewall, try to set java.rmi.server.hostname system property for your Tomcat. Add this to your Tomcat's JAVA_OPTS:
-Djava.rmi.server.hostname=<IP address of Ubuntu Server>
You don't need to start rmiregistry and you don't need to run jstatd to be able to monitor your Tomcat remotely.
For the record: jstatd does not require X libraries, it only depends on them via some other recommended package. You can make aptitude or apt-get skip installation of recommended packages and have jstatd installed without any X11 libraries.
For aptitude, go into options ➞ preferences ➞ Install recommended packages automatically. For apt-get, see this question on askubuntu.

Jconsole cannot connect to java processes running as Windows 7 Services

We have a Java process which we run as a Windows service (using srvany). It runs with Java 1.6 (1.6.0.23 at the moment).
In the past (Windows XP), I could connect JConsole to the processes, on Windows 7 I cannot do this anymore.
If I run jconsole <pid> I get “Invalid process id:4488”. The services are running as SYSTEM user.
If I make the service run as my desktop user (using “Log On as This Account”) the services process ID appear in JConsole, but they are grayed out and I cannot connect.
Is it impossible to dynamically connect to Java processes when they are running as a Windows 7 service?
Perhaps it is a 64bit/32bit problem, I have several applications compiled with 32bit JDK, which could not be opened with JConsole from 64bit JDK on Windows 7 64bit, after I downloaded the 32bit JDK it worked.
Others have been able to run jstack on 2008r2 which may provide some insight on how to get jconsole to connect on Windows 7. As you noted in your comment, the permissions are important. If the service and jconsole can't access the temp directory to write to the appropriate hsperf subdirectory, it won't work. What is also important is the location of the temp directory, the user the service is running, and the user that is running jconsole.
Running SysInternals psexec -s -i <jdk_home>\bin\jconsole <PID> can be used to run jconsole as Local System, the same user that I believe you are using to run your service.
My experience running jconsole from JDK 1.5 in Server 2008 as a system user was unsuccessful. With permissions that I thought should have been sufficient, I got a Could Not Open PerfMemory error. Java 1.6 may be a different story.
In light of all the challenges with running jconsole locally, you would probably have better luck setting it up to accept remote connections. You could set it up for local-only access with your firewall blocking that port from external access.
Add the following to JAVA_OPTION
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
Then,
Use JConsole to connecet remote session:
localhost:8086
I am currently facing the same problem but on Windows 2003 R2 (SP2). There is on open bug in Oracle Bug database (bug id 6399729)
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399729
Also there is a work-around posted towards the end. It talks about installing java in "install" mode :-), but didn't work for me on Windows 2003 though. But your mileage may vary!!
Change Environment Variable TEMP and Tmp to a different folder that you created.
Like c:\theTemp
It might be a problem with the folder %TMP%/hsperfdata_{USER_NAME}.
In my case, it worked after I :
close all applications running over the JVM
delete the folder %TMP%/hsperfdata_{USER_NAME} (exemple: C:/Temp/hsperfdata_MyUser)
reopen JConsole (it recreates the folder)
Hope it helps. You can also take a look at this thread in Oracle community.

Categories