.
Local and Remote JMX Connections
There are two ways to connect to Nexus using JMX - locally and remotely.
Local connections are possible without any extra configuration as long as the following conditions are met:
- VisualVM and Nexus are running as the same user id
- VisualVM and Nexus use the exact same Java version and architecture: Example 64 bit Java 7 for both.
Remote connections require explicit configuration changes.
Locally Connecting with VisualVM on Windows
Nexus usually runs as a Windows Service. Connecting to a Windows service using a local VisualVM install is particularly challenging. Here are some resources to help:
Monitoring Java Processes Running As a Windows Service
Configure JMX in the Standard Nexus Bundle zip/tar.gz
Below are steps for Nexus Repository versions 2.8 and higher.
1. Add the following property to NEXUS_HOME/bin/jsw/conf/wrapper.conf
wrapper.app.parameter.3=./conf/jetty-jmx.xml
Adjust the sequence number (shown here as "3") to be in line with the other wrapper.app.parameter lines.
2. Add the following properties to NEXUS_HOME/conf/nexus.properties
jmx-host=192.168.10.12 jmx-port=1099
Ensure that a remotely accessible IP address is set for jmx-host to allow remote jmx access. It is important to ensure that the port is not blocked by any network setup, when connecting remotely. The value of 1099 is the default port used for JMX, but any other available port can be used as well.
3. Restart Nexus.
Below are steps for Nexus versions older than 2.8
Newer versions of Nexus have a <installation_dir>/conf/examples/jetty-jmx.xml file which can be used to configure JMX. Simply copy the differences from jetty-jmx.xml into <installation_dir>/conf/jetty.xml while nexus is stopped.
Note: If you want to be able to connect to JMX from a remote host you will need to add this line to <nexus_root>/bin/jsw/conf/wrapper.conf:
wrapper.java.additional.4=-Djava.rmi.server.hostname=<hostname-or-ip-address>
Adjust the sequence number (shown here as "4") to be in line with the other wrapper.java.additional lines.
Tip: To enable Mbeans for the JSW watchdog process add the following line to the wrapper.conf file:
wrapper.java.additional.5=-Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true
Configure JMX with the Nexus Professional Trial Installer
The trial installation uses an Install4j installer and not Java Service Wrapper, therefore configuring JMX via JVM properties is slightly different from the regular bundles.
Find the Nexus installation directory. An easy way to do this is using the Nexus Control application - look for the "Installation" directory.
Edit the "<installation_directory>/bin/nexus.vmoptions" file and add the following lines:
-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
Restart nexus for the settings to take effect.
Important: For ease of use, we turn off the requirement to authenticate or use SSL when making the connection. Understand that some environments may treat this as a security risk. Since the aim of these instructions are to get you going as quickly as possible, we turn these options off here.
Important: Choose a port that is not already in use and can be accessed through firewalls. Ask your IT staff for guidance.
Remotely Connecting with VisualVM
Download Visual VM or launch jvisualvm from your JDK's bin directory. Click on "add jmx connection", and enter the IP address of the nexus host and the port you configured above. Example: "192.168.2.1:1099"
Problems?
Failed to start Port already in use: 1099
Startup of Nexus Repo 2 may fail with a message like this is in the wrapper.log/nexus.log:
WARN [WrapperListener_start_runner] org.eclipse.jetty.xml.XmlConfiguration - Config error at <Call name="start"/> WARN [WrapperListener_start_runner] org.eclipse.jetty.xml.XmlConfiguration - Config error at <New id="ConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer"><Arg> <New class="javax.management.remote.JMXServiceURL"><Arg type="java.lang.String">rmi</Arg><Arg type="java.lang.String"><Property name="jmx-host" default="0.0.0.0"/></Arg><Arg type="java.lang.Integer"><Property name="jmx-port" default="1099"/></Arg><Arg type="java.lang.String">/jndi/rmi://<Property name="jmx-host" default="0.0.0.0"/>:<Property name="jmx-port" default="1099"/>/jmxrmi</Arg></New> </Arg><Arg>org.eclipse.jetty:name=rmiconnectorserver</Arg><Call name="start"/></New> ERROR [WrapperListener_start_runner] org.sonatype.nexus.bootstrap.jetty.JettyServer - Start failed java.lang.reflect.InvocationTargetException: null at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.invokeMethod(XmlConfiguration.java:765) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.invokeMethod(XmlConfiguration.java:760) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:979) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:942) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:515) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:1022) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:521) at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:468) at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:380) at org.sonatype.nexus.bootstrap.jetty.JettyServer.doStart(JettyServer.java:145) at org.sonatype.nexus.bootstrap.jetty.JettyServer.access$000(JettyServer.java:41) at org.sonatype.nexus.bootstrap.jetty.JettyServer$1.run(JettyServer.java:93) at java.security.AccessController.doPrivileged(Native Method) at org.sonatype.nexus.bootstrap.jetty.JettyServer.start(JettyServer.java:89) at org.sonatype.nexus.bootstrap.Launcher.start(Launcher.java:123) at org.sonatype.nexus.bootstrap.jsw.JswLauncher.doStart(JswLauncher.java:64) at org.sonatype.nexus.bootstrap.jsw.WrapperListenerSupport.start(WrapperListenerSupport.java:36) at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788) Caused by: java.rmi.server.ExportException: Port already in use: 1099; nested exception is: java.net.BindException: Address already in use (Bind failed) at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:346) at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:254) at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:412) at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:147) at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:237) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:383) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:346) at javax.management.remote.rmi.RMIJRMPServerImpl.export(RMIJRMPServerImpl.java:148) at javax.management.remote.rmi.RMIJRMPServerImpl.export(RMIJRMPServerImpl.java:124) at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:404) at org.eclipse.jetty.jmx.ConnectorServer.doStart(ConnectorServer.java:152) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73) ... 22 common frames omitted Caused by: java.net.BindException: Address already in use (Bind failed) at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.ServerSocket.bind(ServerSocket.java:390) at java.net.ServerSocket.bind(ServerSocket.java:344) at org.eclipse.jetty.jmx.ConnectorServer$JMXRMIServerSocketFactory.createServerSocket(ConnectorServer.java:249) at org.eclipse.jetty.jmx.ConnectorServer$JMXRMIServerSocketFactory.createServerSocket(ConnectorServer.java:236) at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:670) at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:335) ... 33 common frames omitted
First ensure that no other application is using the port reflected in the message ( in the example, port 1099 ).
If no other application is using this port, then the problem is encountered when step 2 from the instructions in Configure JMX in the Standard Nexus Bundle zip/tar.gz is not followed. In that case be sure to actually configure the properties specified - this will resolve the issue.