{"id":106,"date":"2013-11-21T23:35:21","date_gmt":"2013-11-21T22:35:21","guid":{"rendered":"http:\/\/www.iplumbing.nl\/blog\/?p=106"},"modified":"2013-11-21T23:39:46","modified_gmt":"2013-11-21T22:39:46","slug":"remote-debugging-of-java-applications","status":"publish","type":"post","link":"https:\/\/www.iplumbing.nl\/blog\/2013\/11\/21\/remote-debugging-of-java-applications\/","title":{"rendered":"Remote Debugging of Java Applications"},"content":{"rendered":"<p>At work I tried to debug the Java application that we provide to our customers. A nasty performance problem had developed in the course of time. To analyze this, I can recommend using VisualVM. It&#8217;s part of Oracle&#8217;s JDK (version 6 and up) but is also available as a <a title=\"VisualVM Home Page\" href=\"http:\/\/visualvm.java.net\/\" target=\"_blank\">stand alone download<\/a>.<\/p>\n<p>VisualVM also allows for remote debugging an application. To this end you can use the &#8220;jstatd&#8221; application, also part of Oracle&#8217;s JDK. When I used this app for some testing, I encountered the following exception at start up:<\/p>\n<p><small>Could not create remote object<br \/>\naccess denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)<br \/>\njava.security.AccessControlException: access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)<br \/>\nat java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)<br \/>\nat java.security.AccessController.checkPermission(AccessController.java:427)<br \/>\nat java.lang.SecurityManager.checkPermission(SecurityManager.java:536)<br \/>\nat java.lang.System.setProperty(System.java:699)<br \/>\nat sun.tools.jstatd.Jstatd.main(Jstatd.java:122)<\/small><\/p>\n<p>Vinay Singla has the answer on his blog. He explains that to run the application requires some permissions before it can run:<\/p>\n<blockquote><p>Cause :- The &#8220;access denied&#8221; error is expected, because &#8220;jstatd&#8221; requires a security policy file specified with the &#8220;java.security.policy&#8221; system property, if there is no security manager running on the machine.<\/p><\/blockquote>\n<p>His solution (as &#8217;translated to a Windows environment&#8217;, by me):<\/p>\n<ol>\n<li>Inside a DOS-box\/Console, change to the bin directory, inside the JDK directory. (e.g. c:\\program files\\java\\jdk7\\bin)<\/li>\n<li>Check if a file exists with the name &#8220;jstatd.all.policy&#8221;. If not, create it with Notepad. If so, edit it with Notepad.<\/li>\n<li>Add this information to the file:<br \/>\ngrant codebase &#8220;file:${java.home}\/..\/lib\/tools.jar&#8221; {<br \/>\npermission java.security.AllPermission;<br \/>\n};<\/li>\n<li>Run this command:\u00a0jstatd -J-Djava.security.policy=jstatd.all.policy<\/li>\n<li>Now you can connect to this machine via VisualVM.<\/li>\n<\/ol>\n<p>Via\u00a0<a href=\"http:\/\/dbafusion.blogspot.nl\/2010\/05\/jstad-error-could-not-create-remote.html\" target=\"_blank\">http:\/\/dbafusion.blogspot.nl\/2010\/05\/jstad-error-could-not-create-remote.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>At work I tried to debug the Java application that we provide to our customers. A nasty performance problem had developed in the course of time. To analyze this, I can recommend using VisualVM. It&#8217;s part of Oracle&#8217;s JDK (version 6 and up) but is also available as a stand<\/p>\n","protected":false},"author":1,"featured_media":110,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"jetpack_featured_media_url":"https:\/\/www.iplumbing.nl\/blog\/wp-content\/uploads\/2013\/11\/java.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":5,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":114,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/posts\/106\/revisions\/114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/media\/110"}],"wp:attachment":[{"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iplumbing.nl\/blog\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}