title: JProfiler: Help in Step by step guide to integrate jprofiler on remote server ubuntu
body: <p>I am trying to profile a remote server running tomcat7 on ubuntu. I have read multiple tutorials but not able to run it.</p>
  
  <p><strong>JProfiler integration on remote server</strong></p>
  
  <p>First I <strong>downloaded</strong> <a href="http://download-keycdn.ej-technologies.com/jprofiler/jprofiler_linux_9_2.tar.gz" rel="nofollow">jprofiler9</a> and <strong>extracted</strong> on remote system.</p>
  
  <pre><code>wget http://download-keycdn.ej-technologies.com/jprofiler/jprofiler_linux_9_2.tar.gz
  tar -xzf jprofiler_linux_9_2.tar.gz
  </code></pre>
  
  <p>and ran following command</p>
  
  <pre><code>jprofiler9/bin# ./jpintegrate
  </code></pre>
  
  <p>It asked me few information and generated 2 files</p>
  
  <ol>
  <li><strong>startup-jp.sh</strong> This file I guess is created from <code>startup.sh</code>, as the above wizard asked me to provide path to startup script (/usr/share/tomcat7/bin/startup.sh) so new file is created in the same folder.</li>
  <li><strong>config-jp.xml</strong> The same wizard asked me to enter the name of configuration file with some instructions: can be imported in a
  JProfiler GUI to quickly connect to the application server</li>
  </ol>
  
  <p>The changed contents startup-jp.sh are as follows </p>
  
  <pre><code># The following lines have been added by the
  # application server integration wizard of JProfiler
  
  CATALINA_OPTS="-agentpath:/home/ubuntu/jprofiler9/bin/linux-x64/libjprofilerti.so=port=8383 $CATALINA_OPTS"
  export CATALINA_OPTS
  
  # end of modifications
  
  exec "$PRGDIR"/"$EXECUTABLE" run "$@"
  </code></pre>
  
  <p><strong>Statring JProfiler</strong>
  Here I am confused how to run jprofiler, I guess running startup-jp.sh will start the profiler</p>
  
  <p>It runs successfully but when I connect to this remote server from my local system with JProfiler GUI, server genrates few errors about path not found</p>
  
  <p>here the console log after running the startup-jp.sh</p>
  
  <pre><code>root# /usr/share/tomcat7/bin/startup.sh
  Using CATALINA_BASE:   /usr/share/tomcat7
  Using CATALINA_HOME:   /usr/share/tomcat7
  Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
  Using JRE_HOME:        /usr
  Using CLASSPATH:       /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
  JProfiler&gt; Protocol version 55
  JProfiler&gt; Using JVMTI
  JProfiler&gt; JVMTI version 1.1 detected.
  JProfiler&gt; 64-bit library
  JProfiler&gt; Listening on port: 8383.
  JProfiler&gt; Instrumenting native methods.
  JProfiler&gt; Can retransform classes.
  JProfiler&gt; Can retransform any class.
  JProfiler&gt; Native library initialized
  JProfiler&gt; VM initialized
  JProfiler&gt; Waiting for a connection from the JProfiler GUI ...
  JProfiler&gt; Using dynamic instrumentation
  JProfiler&gt; Time measurement: elapsed time
  JProfiler&gt; CPU profiling enabled
  Oct 28, 2016 4:27:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
  WARNING: Problem with directory [/usr/share/tomcat7/common/classes], exists: [false], isDirectory: [false], canRead: [false]
  Oct 28, 2016 4:27:31 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
  WARNING: Problem with directory [/usr/share/tomcat7/common], exists: [false], isDirectory: [false], canRead: [false]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
  WARNING: Problem with directory [/usr/share/tomcat7/server/classes], exists: [false], isDirectory: [false], canRead: [false]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
  WARNING: Problem with directory [/usr/share/tomcat7/server], exists: [false], isDirectory: [false], canRead: [false]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
  WARNING: Problem with directory [/usr/share/tomcat7/shared/classes], exists: [false], isDirectory: [false], canRead: [false]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.ClassLoaderFactory validateFile
  WARNING: Problem with directory [/usr/share/tomcat7/shared], exists: [false], isDirectory: [false], canRead: [false]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.Catalina initDirs
  SEVERE: Cannot find specified temporary folder at /usr/share/tomcat7/temp
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.Catalina load
  WARNING: Unable to load server configuration from [/usr/share/tomcat7/conf/server.xml]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.Catalina initDirs
  SEVERE: Cannot find specified temporary folder at /usr/share/tomcat7/temp
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.Catalina load
  WARNING: Unable to load server configuration from [/usr/share/tomcat7/conf/server.xml]
  Oct 28, 2016 4:27:32 AM org.apache.catalina.startup.Catalina start
  SEVERE: Cannot start server. Server instance is not configured.
  JProfiler&gt; Keeping VM alive until frontend disconnects.
  </code></pre>
  
  <p>Clearly its not able to view different required directories (strange), Please note I never ran startup.sh to start my tomcat7 but used <code>service tomcat7 start</code>, may be here is the problem. Here is my directory structure for tomcat7</p>
  
  <p><strong>/usr/share/tomcat7/</strong></p>
  
  <pre><code>drwxr-xr-x   2 root root 4.0K Oct 28 04:21 bin
  -rw-r--r--   1 root root   39 Feb 21  2014 defaults.md5sum
  -rw-r--r--   1 root root 2.0K Feb 21  2014 defaults.template
  drwxr-xr-x   2 root root 4.0K Oct 10 06:06 lib
  -rw-r--r--   1 root root   53 Feb 21  2014 logrotate.md5sum
  -rw-r--r--   1 root root  118 Feb 21  2014 logrotate.template
  </code></pre>
  
  <p><strong>/var/lib/tomcat7/</strong></p>
  
  <pre><code>drwxr-xr-x  3 tomcat7 tomcat7 4.0K Apr 21  2016 common
  lrwxrwxrwx  1 root    root      12 Jun 19  2015 conf -&gt; /etc/tomcat7
  lrwxrwxrwx  1 root    root      17 Jun 19  2015 logs -&gt; ../../log/tomcat7
  drwxr-xr-x  3 tomcat7 tomcat7 4.0K Apr 21  2016 server
  drwxr-xr-x  3 tomcat7 tomcat7 4.0K Apr 21  2016 shared
  drwxrwxr-x  6 tomcat7 tomcat7 4.0K Oct 27 06:10 webapps
  lrwxrwxrwx  1 root    root      19 Jun 19  2015 work -&gt; ../../cache/tomcat7
  </code></pre>
  
  <p><strong>Fixed</strong> above exception by adding following line in startup-jp.sh</p>
  
  <pre><code>export CATALINA_BASE="/var/lib/tomcat7/"
  </code></pre>
  
  <p>Now it is able to locate the missing folder</p>
  
  <p><strong>New problem</strong></p>
  
  <p>Now the issue is my local jprofiler gui is taking too much time (like if i restart the script it captures few of the entries but soon after </p>
  
  <blockquote>
    <p>CPU usage for tomcat is 197.5% reveled by top command</p>
  </blockquote>
  
  <p>and hence nothing else get loaded by local jprofiler GUI. I have no way to identify what is causing this much CPU usage.</p>
  
  <pre><code>  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   5496 tomcat    38  18 3005m 675m  17m S 197.5  9.0  21:09.55 java
  </code></pre>