且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

由于权限错误无法启动jstatd

更新时间:2022-01-07 17:55:58

这对我有用:


  1. 确保tools.jar文件存在,并且运行jstatd命令的用户有权读取它。

  1. Make sure that tools.jar file exists and the user running the jstatd command has permissions to read it.

确保URL在 jstatd.all.policy 中,指向tools.jar是正确的并声明协议(在本例中为文件)。例如,根据 java.home 变量指向的位置,您可能需要删除 ../ 部分就像这样(我不得不):

Make sure that the URL in the jstatd.all.policy that points to the tools.jar is correct and declares the protocol (file in this case). For example, depending on where the java.home variable points to, you may need to remove the ../ part in the path just like this (I had to):

grant codebase "file:${java.home}/lib/tools.jar" {
   permission java.security.AllPermission;
};


  • 从Java 1.4开始,策略文件需要以UTF-8编码没有BOM 。 EOL(CRLF vs LF)应该不重要。请参阅Oracle的默认策略实施和策略文件语法文档,在更改部分下获取更多信息(链接未提供,因为我没有足够的信誉点来发布超过2个链接,但我确定你' ll能够找到该文档)。

  • Starting from Java 1.4 the policy file needs to be encoded in UTF-8 without BOM. The EOL (CRLF vs LF) shouldn't really matter. Please see "Default Policy Implementation and Policy File Syntax" document from Oracle, under "Changes" section for more information (link not provided because I don't have enough reputation points to post more than 2 links, but I'm sure you'll be able to find that document).

    运行jstatd命令时使用策略文件的绝对路径,例如

    Use an absolute path to the policy file when running the jstatd command, e.g.

    jstatd -p 12345 -J-Djava.security.policy=/absolute-path-to/jstatd.all.policy
    

    编辑:Java 1.8中可能不再需要或不支持 -J 参数这个命令将改为:

    The -J parameter may no longer be required or supported in Java 1.8 so this command would be instead:

    jstatd -p 12345 -Djava.security.policy=/absolute-path-to/jstatd.all.policy
    

    (感谢@lisak指出这一点)

    (thanks @lisak for pointing this out)

    最后,一旦你通过这一点,你可能会发现其他问题(我做过),这些帖子指出了我正确的方向:使用VisualVM监视远程JBoss实例使用VisualVM对JBoss进行远程分析。基本上你可能需要使用-p参数来使用不同的端口,如果1099已经在使用,并在JBoss run.conf 中通过 JAVA_OPTS (假设您正在监视JBoss实例)。所有链接中都有更详细的解释。

    Finally, once you pass this point you may find other problems (I did) and these posts pointed me in the right direction: Using VisualVM to monitor a remote JBoss instance and Remote Profiling of JBoss using VisualVM. Basically you may need to use the -p parameter to use a different port if 1099 is already in use and add some java options in the JBoss run.conf via JAVA_OPTS (assuming you are monitoring JBoss instance). All explained in more detail in the links provided.

    编辑:
    - 指向死链接使用VisualVM监视远程JBoss实例到具有相同内容的另一个页面。

    - Pointed dead link Using VisualVM to monitor a remote JBoss instance to another page with the same content.