I deployed a Java app to server and need to run Jconsole for profiling. I connected to server over SSH and run jconsole, however I got an error
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
How can I run JConsole over SSH on my client machine?
when connection to the server, enable X forwarding with ssh -X $servername
Related
My server is running on OS ubuntu 10.4.
When I run command "skype -callto userid" it makes a call using Skype user interface.
But when I run same command by connecting via SSH or
java code
Runtime.getRuntime().exec(command), its not working.
What could be the reason of such behavior?
I guess your problem is that Skype needs an X server to run properly. So you could enable X11 forwarding.
X11 forwarding needs to be configured on the client and server side:
On the server side enable X11 forwarding by setting X11Forwarding yes in /etc/ssh/sshd_config and restarting the ssh service service sshd restart. You might also need to install xauth on the server side.
On the client side you need to open the ssh connection with the -X parameter to enable X11 forwarding for the session.
I am trying to use JProfiler on my MAC to connect to a machine remotely that is behind a firewall and only accessible via a Linux machine.
I have set up a direct SSH tunnel as follows:
ssh -L 8849:remote:8849 forwardingmachine
And start Jprofiler with
java -agentpath:/path/jprofiler8/bin/linux-x64/libjprofilerti.so=port=8849 ..."
I systematically get the error:
Connection error
Either an old version of the native library is used or another
application is listening on port 8849. Please check your
DYLD_LIBRARY_PATH environment variable and your port configuration
Online there are solutions for using a 2 hop SSH tunnel, but I can't do that due to the second machine only being accessible to forwardingmachine.
Any ideas of how to get around this?
(The remote machine uses Java 1.7, whereas my Mac uses Java 1.8). Both machines are using jprofiler8
A direct tunnel to remote is set up with the command
ssh -t user#remote -L [localPort]:localhost:[remotePort] -N
I'm trying to connect JProfiler to a JVM running on a server that I'll call remote. This server is only accessible from my workstation (local) via another server that I'll call middle. My plan for connecting JProfiler to remote was this:
Install the JProfiler instrumentation on remote
Establish SSH tunnel from local, through middle, to remote:
ssh -v -N -L 8849:[remote's private address (192.168... etc)]:8849 [middle]
Establish a new JProfiler session on localhost:8849, choosing "Startup immediately, connect later with JProfiler GUI"
However, I end up getting an error:
Connection error
Either an old version of the native library is used or another
application is listening on port 8849. Please check your
DYLD_LIBRARY_PATH environment variable and your port configuration
I don't have any other programs bound to local port 8849, aside from my SSH tunnel, and I have confirmed that the SSH tunnel itself should be working correctly - I'm able to forward connections for a test HTTP server from remote to local via a similarly configured tunnel.
I found this similar question, but no solution was provided.
What am I missing from my configuration?
A direct tunnel is established with
ssh -t user#remote -L [localPort]:localhost:[remotePort] -N
A 2-hop tunnel is built with chained ssh commands:
ssh -t user#middle -L [localPort]:localhost:[remotePort] \
ssh -t user#remote -L [remotePort]:localhost:[remotePort] -N
where localPort is the port you want to use locally, and remotePort is the port that the profiling agent is listening on. All of this is executed in a single command on your local machine. More hops can be added with additional ssh calls like in the first line. There must by exactly one trailing -N for the entire command.
This approach works with JProfiler.
If the tunnels fails or if the profiling agent is not listening, you will get the message that you mentioned because of the way that the connection fails in the case of an SSH tunnel.
I have a java program in a weird condition where it has stopped running a certain thread.
I would like to connect to it using JMX, but I didn't provide the JMX arguments.
I could restart but then I would loss the information of the current condition.
I know that on Windows it can connect with jconsole on localhost without parameters, but my java app is running on a Linux server.
So any ideas on how to still be able to connect even without jmx parameters?
JConsole works on linux also. If the linux server have xhost or some remote displaying capability, I would just run jconsole on the linux server.
If you didn't enable JMX when the java program was started, you would not be able to connect remotely via JMX.
I found out that there is an option to dump the threads:
kill 3
Used it and found the reason.
Thank you.
I'm using the ganymed lib to access remote hosts in my network. But, in this network has routers and switches that can only be accessed by another host.
To illustrate this, in my network there is a Linux server and connected to it there is a Cisco router. The connection to the Linux server worked, but i try to execute the command:
ssh user#ip
After this i use the session.getStdin.write() for executing another command in the session and make the login in the password prompt. But, after the execution of the first command (ssh), the program still running and doesn't send any output.