由于权限错误无法启动jstatd [英] cannot start jstatd due to permission error

查看:228
本文介绍了由于权限错误无法启动jstatd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在linux机器上运行jstatd jvm监视工具

I try to run jstatd jvm monitoring tool on linux machine

jboss@hostAddr:/usr/java/jdk1.6.0_18/bin> uname -a
Linux hostAddr 2.6.16.60-0.34-smp #1 SMP Fri Jan 16 14:59:01 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux

使用以下命令:

jstatd -J-Djava.security.policy=~/jstatd.all.policy

jstatd.all.policy contents

jstatd.all.policy contents

grant codebase "file:${java.home}/../lib/tools.jar" {

   permission java.security.AllPermission;

};

不幸的是我得到以下输出:

Unfortunately I get following output:

Could not create remote object
access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)
java.security.AccessControlException: access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
        at java.security.AccessController.checkPermission(AccessController.java:546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.System.setProperty(System.java:725)
        at sun.tools.jstatd.Jstatd.main(Jstatd.java:122)

由于某种原因,jstatd在具有相同命令的Windows上成功运行和策略文件。

For some reason jstatd runs successfully on windows with the same command and policy file.

Linux java版本:

Linux java version:

java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)

Windows java版本:

Windows java version:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)


推荐答案

这对我有用:


  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 中通过<$ c $添加一些java选项c> 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.

    这篇关于由于权限错误无法启动jstatd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆