如何在远程 Glassfish 服务器上激活 JMX 以使用 jconsole 进行访问?

发布于 2024-07-30 08:38:11 字数 4323 浏览 3 评论 0原文

我想监控远程 glassfish 服务器。 我已经在domain.xml中启用了JMX连接:

<jmx-connector accept-all="true" address="0.0.0.0" auth-realm-name="admin-realm" enabled="true" name="system" port="8686" protocol="rmi_jrmp" security-enabled="false">

但这没有帮助。 我仍然无法使用 JConsole 连接到服务器。 然后我找到了解决方案 - 我需要在domain.xml中指定JVM属性以打开8686端口进行远程连接。 所以我将这行添加到 java-config 部分:

<jvm-options>-Dcom.sun.management.jmxremote</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.port=8686</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.local.only=false</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.authenticate=false</jvm-options>

但是现在当我启动服务器时,我收到以下错误:

无法加载日志管理器 “com.sun.enterprise.server.logging.ServerLogManager” java.lang.ClassNotFoundException: com.sun.enterprise.server.logging.ServerLogManager 在 java.net.URLClassLoader$1.run(URLClassLoader.java:200) 在java.security.AccessController.doPrivileged(本机 方法) 在 java.net.URLClassLoader.findClass(URLClassLoader.java:188) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:307) 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:252) 在 java.util.logging.LogManager$1.run(LogManager.java:166) 在java.security.AccessController.doPrivileged(本机 方法) 在 java.util.logging.LogManager.(LogManager.java:156) 在 java.util.logging.Logger.getLogger(Logger.java:273) 在 sun.management.snmp.util.MibLogger。(MibLogger.java:57) 在 sun.management.snmp.util.MibLogger。(MibLogger.java:42) 在sun.management.jmxremote.ConnectorBootstrap。(ConnectorBootstrap.java:760) 在 sun.management.Agent.startAgent(Agent.java:127) 在 sun.management.Agent.startAgent(Agent.java:239) javax.management.JMRuntimeException: 无法加载 MBeanServerBuilder 班级 com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder: java.lang.ClassNotFoundException: com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder 在 javax.management.MBeanServerFactory.checkMBeanServerBuilder(MBeanServerFactory.java:480) 在 javax.management.MBeanServerFactory.getNewMBeanServerBuilder(MBeanServerFactory.java:511) 在 javax.management.MBeanServerFactory.newMBeanServer(MBeanServerFactory.java:298) 在 javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:213) 在 javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:174) 在sun.management.ManagementFactory.createPlatformMBeanServer(ManagementFactory.java:302) 在 java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:504) 在sun.management.jmxremote.ConnectorBootstrap.initialize(ConnectorBootstrap.java:392) 在 sun.management.Agent.startAgent(Agent.java:127) 在 sun.management.Agent.startAgent(Agent.java:239) 造成原因: java.lang.ClassNotFoundException: com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder 在 java.net.URLClassLoader$1.run(URLClassLoader.java:200) 在java.security.AccessController.doPrivileged(本机 方法) 在 java.net.URLClassLoader.findClass(URLClassLoader.java:188) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:307) 在 sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:252) 在 javax.management.MBeanServerFactory.loadBuilderClass(MBeanServerFactory.java:423) 在 javax.management.MBeanServerFactory.checkMBeanServerBuilder(MBeanServerFactory.java:465) ...代理抛出的另外 9 个异常: javax.management.JMRuntimeException: 无法加载 MBeanServerBuilder 班级 com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder: java.lang.ClassNotFoundException: com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder

如何解决该问题?

提前致谢。

I would like to monitor remote glassfish server. I have enabled JMX Connection in domain.xml:

<jmx-connector accept-all="true" address="0.0.0.0" auth-realm-name="admin-realm" enabled="true" name="system" port="8686" protocol="rmi_jrmp" security-enabled="false">

But this didn't help. I still can't connect to server with JConsole. Then I've found solution - I need to specify JVM properties in domain.xml to open 8686 port for remote connection.
So I added this lines into java-config section:

<jvm-options>-Dcom.sun.management.jmxremote</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.port=8686</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.local.only=false</jvm-options>
<jvm-options>-Dcom.sun.management.jmxremote.authenticate=false</jvm-options>

But now when I'm starting server, I'm getting following errors:

Could not load Logmanager
"com.sun.enterprise.server.logging.ServerLogManager"
java.lang.ClassNotFoundException:
com.sun.enterprise.server.logging.ServerLogManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native
Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.util.logging.LogManager$1.run(LogManager.java:166)
at java.security.AccessController.doPrivileged(Native
Method)
at java.util.logging.LogManager.(LogManager.java:156)
at java.util.logging.Logger.getLogger(Logger.java:273)
at sun.management.snmp.util.MibLogger.(MibLogger.java:57)
at sun.management.snmp.util.MibLogger.(MibLogger.java:42)
at sun.management.jmxremote.ConnectorBootstrap.(ConnectorBootstrap.java:760)
at sun.management.Agent.startAgent(Agent.java:127)
at sun.management.Agent.startAgent(Agent.java:239)
javax.management.JMRuntimeException:
Failed to load MBeanServerBuilder
class
com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder:
java.lang.ClassNotFoundException:
com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
at javax.management.MBeanServerFactory.checkMBeanServerBuilder(MBeanServerFactory.java:480)
at javax.management.MBeanServerFactory.getNewMBeanServerBuilder(MBeanServerFactory.java:511)
at javax.management.MBeanServerFactory.newMBeanServer(MBeanServerFactory.java:298)
at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:213)
at javax.management.MBeanServerFactory.createMBeanServer(MBeanServerFactory.java:174)
at sun.management.ManagementFactory.createPlatformMBeanServer(ManagementFactory.java:302)
at java.lang.management.ManagementFactory.getPlatformMBeanServer(ManagementFactory.java:504)
at sun.management.jmxremote.ConnectorBootstrap.initialize(ConnectorBootstrap.java:392)
at sun.management.Agent.startAgent(Agent.java:127)
at sun.management.Agent.startAgent(Agent.java:239)
Caused by:
java.lang.ClassNotFoundException:
com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native
Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at javax.management.MBeanServerFactory.loadBuilderClass(MBeanServerFactory.java:423)
at javax.management.MBeanServerFactory.checkMBeanServerBuilder(MBeanServerFactory.java:465)
... 9 more Exception thrown by the agent :
javax.management.JMRuntimeException:
Failed to load MBeanServerBuilder
class
com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder:
java.lang.ClassNotFoundException:
com.sun.enterprise.admin.server.core.jmx.AppServerMBeanServerBuilder

How can I fix the problem?

Thanks in advance.

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

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

发布评论

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

评论(5

時窥 2024-08-06 08:38:11

仍然是神秘的行为,但通过这 4 个设置,您可以连接到运行 Glassfish 的 JVM(添加到管理控制台中的 domain.xml,需要重新启动)

-Djava.rmi.server.hostname=yourhost
-Dcom.sun.management.jmxremote.port=8686
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

当心! 这是不安全的,因为现在任何人都可以将 jconsole 连接到它!

在我看来,这不是使用 JMX 连接器的 Glassfish 方式。

(以上工作在GF 3.1中)

Still mystical behavior, but with these 4 settings you can connect to the JVM running Glassfish (add to domain.xml in admin console, restart required)

-Djava.rmi.server.hostname=yourhost
-Dcom.sun.management.jmxremote.port=8686
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Beware ! This is not safe, as anyone now can connect a jconsole to it !

IMO this is not the Glassfish way, which is using the JMX connector.

(Above works in GF 3.1)

无边思念无边月 2024-08-06 08:38:11

解决问题的步骤是:
1.使用默认设置
2. 在 GlassFish 实例的 JVM 选项中添加 -Djava.rmi.server.hostname=。

Steps to solve the problem are:
1. use default settings
2. add -Djava.rmi.server.hostname= in the JVM Options of the instance of GlassFish.

七秒鱼° 2024-08-06 08:38:11

我最终设置了以下选项来确保带有 Glassfish 的 JMX 防火墙友好:

<jvm-options>-Dcom.sun.aas.jconsole.server.cbport=XXXX</jvm-options>

其中 XXXX 是您在防火墙中使用的端口号以及应用程序服务器配置的 JMX 端口号(通常为 8686)。

请阅读此博文了解更多信息。 请注意,此功能需要较新版本的 Glassfish。 我已经成功地将它与 Glassfish 2.1.1 一起使用。

I ended up setting the following option to ensure that JMX with Glassfish is firewall friendly:

<jvm-options>-Dcom.sun.aas.jconsole.server.cbport=XXXX</jvm-options>

Where XXXX is the port number that you use in the firewall together with the application server configured JMX port number (usually 8686).

Read more in this blogpost. Note that this feature requires a newer version of Glassfish. I've successfully used it with Glassfish 2.1.1.

萌能量女王 2024-08-06 08:38:11

如果在 Glassfish 应用程序服务器内运行应用程序,只需运行以下 asadmin 命令,您需要重新启动所有正在运行的服务器才能使更改生效。

./asadmin enable-secure-admin

还有额外的 Glassfish 服务器配置可以进一步启用安全性,请参阅 连接通过 JMX 远程连接到 Glassfish

您确实需要遵循 JVM 选项中的步骤,这些是针对 Java 应用程序的一般说明。 对于与 Glassfish 应用程序服务器一起运行的 Java 应用程序,只需使用 asadm 命令即可。 这节省了我很多时间!

** 另请注意,仅使用 JVM 选项的设置,Glassfish 将无法启动并出现上述运行时异常。
** 我使用的是 GF3.1.2 及更高版本和 Java 7。

If run your application inside Glassfish app server, simply run the following asadmin command, you would need to restart all running servers for the change to take affect.

./asadmin enable-secure-admin

There are extra Glassfish server configurations to further enable security, see more at Connecting remotely to Glassfish through JMX.

You do need to follow the steps on JVM options, these are instructions for Java applications in general. For a Java application that runs with Glassfish application server, simply using the asadm command. That saved me lots of time!

** Another note, with only the settings using JVM options, Glassfish would fail to start with the above runtime exceptions.
** I am using GF3.1.2 and above, and Java 7.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文