5

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.

Pavel
  • 1,019
  • 2
  • 10
  • 19

5 Answers5

5

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)

Cuga
  • 17,668
  • 31
  • 111
  • 166
javadude
  • 1,763
  • 1
  • 19
  • 38
  • Thanks so much. This is exactly the answer I've been looking for to remotely connect to a glassfish server running on a VM on my machine! – Cuga Dec 12 '14 at 18:19
  • I add some extra setting: -Dcom.sun.management.jmxremote.local.only=false – Alexey Simonov Nov 04 '19 at 13:37
3

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.

Pavel
  • 1,019
  • 2
  • 10
  • 19
  • Just to be sure: The first step - did that involve removing all the com.sun.management.jmxremote settings from JVM options? – tronda Mar 18 '10 at 12:24
  • It means to keep them the same as they were out-of-the-box. If the JMX settings exists - let them be, if they doesn't - don't add them. – Pavel Mar 19 '10 at 10:28
3

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.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
tronda
  • 3,902
  • 4
  • 33
  • 55
0

Isn't it GlassFish issue 1409?

Grzegorz Oledzki
  • 23,614
  • 16
  • 68
  • 106
0

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.

BJYC
  • 354
  • 2
  • 10