当从 VisualVM 通过 JMX 远程连接到 JBoss AS 时,如何避免此 NullPointerException?

发布于 2024-12-28 22:36:35 字数 3851 浏览 1 评论 0原文

问题:

当我通过 VisualVM 连接并提供正确的凭据时,程序似乎等待了一会儿(处理或等待连接),然后出现错误并出现异常。抛出此异常后,连接似乎未正确添加:

java.lang.NullPointerException: Illegal null argument
    at javax.management.remote.JMXConnectionNotification.<init>(JMXConnectionNotification.java:152)
    at javax.management.remote.rmi.RMIConnector$RMIClientCommunicatorAdmin.gotIOException(RMIConnector.java:1444)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.isInstanceOf(RMIConnector.java:1062)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$CheckerInvocationHandler.invoke(JmxModelImpl.java:598)
    at $Proxy7.isInstanceOf(Unknown Source)
    at java.lang.management.ManagementFactory.newPlatformMXBeanProxy(ManagementFactory.java:616)
    at com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory$JvmMXBeansImpl.getMXBean(JvmMXBeansFactory.java:383)
    at com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory$JvmMXBeansImpl.getRuntimeMXBean(JvmMXBeansFactory.java:356)
    at com.sun.tools.visualvm.jmx.impl.JmxApplication.getPid(JmxApplication.java:84)
    at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.getMonitoredVm(JvmstatModelProvider.java:49)
    at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.createModelFor(JvmstatModelProvider.java:71)
    at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.createModelFor(JvmstatModelProvider.java:45)
    at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:111)
    at com.sun.tools.visualvm.tools.jvmstat.JvmstatModelFactory.getJvmstatFor(JvmstatModelFactory.java:65)
    at com.sun.tools.visualvm.jvm.JRockitJvmProvider.createModelFor(JRockitJvmProvider.java:49)
    at com.sun.tools.visualvm.jvm.JRockitJvmProvider.createModelFor(JRockitJvmProvider.java:42)
    at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:111)
    at com.sun.tools.visualvm.application.jvm.JvmFactory.getJVMFor(JvmFactory.java:65)
    at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.addJmxApplication(JmxApplicationProvider.java:292)
    at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.access$100(JmxApplicationProvider.java:73)
    at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider$3$1.run(JmxApplicationProvider.java:408)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1968)

背景:

我正在使用 VisualVM 进行一些简单的分析工作。我在 Windows 上运行 jboss-4.2.2.GA。

在我的 run.bat 文件中,我有:

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=<myport>
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.local.only=false
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false

在我创建的 JMX 密码文件中,我启用了具有只读访问权限的角色,并确保在该文件上正确设置了读取访问权限。

我可以通过 JMX 连接到 localhost: 上的服务器。用户名和密码与我的 JMX 密码配置文件中的角色和密码匹配。使用不同的凭据或不同的密码是行不通的,所以这绝对是正确设置的。

我已在我的域中为 java.exe 设置了常规防火墙例外。当我没有这个异常时,我根本无法连接到服务器。启用后,我可以通过 telnet 远程连接到 myport,并且当我尝试通过 VisualVM 远程连接时,我会看到一个密码对话框。

我尝试查看异常堆栈跟踪中引用的代码。据我所知,在构造 JMXConnectionNotification 时,connectionId 可能为 null。我不知道为什么,因为我没有费心尝试在调试器中运行它。

我是否有什么配置不正确的地方?我该如何克服这个错误?


编辑:

我刚刚尝试使用 JConsole 进行远程连接,但遇到了完全不同的错误:

java.rmi.ConnectException: Connection refused to host: 127.0.0.1;

我在客户端计算机上的主机文件中没有任何条目,正如网上的一些内容所建议的那样写入此错误。这是否表明存在不同的问题,或者它们是否相关?

Problem:

When I connect via VisualVM and supply the correct credentials, the program seems to wait a bit (either processing or waiting for the connection), then errors out with this an exception. The connection does not seem to get added correctly after this exception is throw:

java.lang.NullPointerException: Illegal null argument
    at javax.management.remote.JMXConnectionNotification.<init>(JMXConnectionNotification.java:152)
    at javax.management.remote.rmi.RMIConnector$RMIClientCommunicatorAdmin.gotIOException(RMIConnector.java:1444)
    at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.isInstanceOf(RMIConnector.java:1062)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.tools.visualvm.jmx.impl.JmxModelImpl$CheckerInvocationHandler.invoke(JmxModelImpl.java:598)
    at $Proxy7.isInstanceOf(Unknown Source)
    at java.lang.management.ManagementFactory.newPlatformMXBeanProxy(ManagementFactory.java:616)
    at com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory$JvmMXBeansImpl.getMXBean(JvmMXBeansFactory.java:383)
    at com.sun.tools.visualvm.tools.jmx.JvmMXBeansFactory$JvmMXBeansImpl.getRuntimeMXBean(JvmMXBeansFactory.java:356)
    at com.sun.tools.visualvm.jmx.impl.JmxApplication.getPid(JmxApplication.java:84)
    at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.getMonitoredVm(JvmstatModelProvider.java:49)
    at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.createModelFor(JvmstatModelProvider.java:71)
    at com.sun.tools.visualvm.jvmstat.JvmstatModelProvider.createModelFor(JvmstatModelProvider.java:45)
    at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:111)
    at com.sun.tools.visualvm.tools.jvmstat.JvmstatModelFactory.getJvmstatFor(JvmstatModelFactory.java:65)
    at com.sun.tools.visualvm.jvm.JRockitJvmProvider.createModelFor(JRockitJvmProvider.java:49)
    at com.sun.tools.visualvm.jvm.JRockitJvmProvider.createModelFor(JRockitJvmProvider.java:42)
    at com.sun.tools.visualvm.core.model.ModelFactory.getModel(ModelFactory.java:111)
    at com.sun.tools.visualvm.application.jvm.JvmFactory.getJVMFor(JvmFactory.java:65)
    at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.addJmxApplication(JmxApplicationProvider.java:292)
    at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider.access$100(JmxApplicationProvider.java:73)
    at com.sun.tools.visualvm.jmx.impl.JmxApplicationProvider$3$1.run(JmxApplicationProvider.java:408)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1424)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1968)

Background:

I am using VisualVM to do some simple profiling work. I am running jboss-4.2.2.GA on Windows.

In my run.bat file I have:

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=<myport>
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.local.only=false
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false

In the JMX password file I created, I have enabled a role with read only access, and have made sure read access is set appropriately on that file.

I can connect to the server on localhost:<myport> via JMX. The username and password match the role and password in my JMX password config file. Using different credentials or a different password doesn't work, so this is definitely set up correctly.

I have set up a general firewall exception in my domain for java.exe. When I don't have this exception, I cannot connect at all to the server. When I have it enabled, I can connect remotely to myport via telnet, and I get a password dialog when I try to connect remotely via VisualVM.

I tried looking through the code referenced in the exception stack trace. As far as I can tell, connectionId is probably null when constructing JMXConnectionNotification. I can't tell why because I haven't bothered trying to run this in a debugger.

Is there anything I have configured incorrectly? How do I get past this error?


Edit:

I just tried connecting remotely with JConsole and I'm getting a totally different error:

java.rmi.ConnectException: Connection refused to host: 127.0.0.1;

I don't have any entries in my hosts file on the client machine, as some things on the net have suggested WRT this error. Is this indicative of a different problem, or are they related?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小女人ら 2025-01-04 22:36:35

在我们的例子中,设置以下属性很有帮助:

set JAVA_OPTS=%JAVA_OPTS% -Djava.rmi.server.hostname=192.168.1.2

其中192.168.1.2是受监控服务器的实际IP地址。

In our case, it was helpful to set following property:

set JAVA_OPTS=%JAVA_OPTS% -Djava.rmi.server.hostname=192.168.1.2

where 192.168.1.2 is actual IP address of monitored server.

物价感观 2025-01-04 22:36:35

这些是我在 run.bat 中的条目,它工作正常。可能缺少authenticate=true 导致问题。

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=<myport>
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=true
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false

These are the entries I have in run.bat and it is working fine. May be missing authenticate=true causing the issue.

set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=<myport>
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.authenticate=true
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.ssl=false
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文