title: VisualVM over Putty SSH-tunnel
body: <p>I'm trying to profile remote java app, actually it is a gameserver. It works normally on my local machine (windows XP x64 with JDK1.7.0_02 x64), but behaves very wierd on the production server (CentOS with JDK1.7.0_03 i586).</p>
  
  <p>I've done a lot of searching and found out that I should use VisualVM for this task. So VisualVM works great on local machine, but there is no hangs on local machine, i need profiling in production environment with real payload. I started jstatd on the remote machine with arguments</p>
  
  <pre><code>jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.logCalls=false &amp;
  </code></pre>
  
  <p>with the policy file</p>
  
  <pre><code>grant codebase "file:/usr/java/jdk1.7.0_02/lib/tools.jar" {
      permission java.security.AllPermission;
  };
  </code></pre>
  
  <p>then I started my java application like this</p>
  
  <pre><code>java -server -Dcom.sun.management.jmxremote\
   -Dcom.sun.management.jmxremote.port=4000\
   -Dcom.sun.management.jmxremote.ssl=false\
   -Dcom.sun.management.jmxremote.authenticate=false\
   -jar /home/pinballSocketServer/pinballSocketServer.jar
  </code></pre>
  
  <p>Both application and jstatd are launched with root priveledges.</p>
  
  <p>and VisualVM didn't manage to connect to remote host. But on the remote host i see the following log, while VisualVM is running and remote host added:</p>
  
  <pre><code>Feb 16, 2012 7:11:52 PM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(3)-217.16.27.195: [217.16.27.195: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
  Feb 16, 2012 7:11:56 PM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(3)-217.16.27.195: [217.16.27.195: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
  Feb 16, 2012 7:12:00 PM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(3)-217.16.27.195: [217.16.27.195: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
  Feb 16, 2012 7:12:04 PM sun.rmi.server.UnicastServerRef logCall
  FINER: RMI TCP Connection(3)-217.16.27.195: [217.16.27.195: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
  </code></pre>
  
  <p>After further googling, I found out that I need to use ssh tunneling. I configured putty in the following way</p>
  
  <p><a href="http://www.advancedigital.ru/show/putty_config.jpg" rel="nofollow noreferrer">http://www.advancedigital.ru/show/putty_config.jpg</a></p>
  
  <p>and VisualVM as this</p>
  
  <p><a href="http://www.advancedigital.ru/show/visualvm_config.jpg" rel="nofollow noreferrer">http://www.advancedigital.ru/show/visualvm_config.jpg</a></p>
  
  <p>Adter munipulations above VisualVM connects to remote host, but I can only see the threads summary chart and profiler is inactive.</p>
  
  <p>I've seen some recommendations that jvms on both machines should be similar and have the same platform (x86 or x64) but i've already tried profiling from another machine (windows 7 x86 with JDK1.7.0_03 x86), and have the same result.</p>
  
  <p>I've also tried this, but get the same result again.
  <a href="https://stackoverflow.com/questions/1609961/visualvm-over-ssh">VisualVM over ssh</a></p>
  
  <p>How can I get this profiling to work?</p>