You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/01 11:50:39 UTC
svn commit: r1498340 - in /tomcat/trunk:
java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
java/org/apache/catalina/mbeans/LocalStrings.properties
webapps/docs/config/listeners.xml
Author: markt
Date: Mon Jul 1 09:50:38 2013
New Revision: 1498340
URL: http://svn.apache.org/r1498340
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55017
Add the ability to configure the RMO bind address when using the JXM remote listener.
Patch provided by Alexey Noskov.
Modified:
tomcat/trunk/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties
tomcat/trunk/webapps/docs/config/listeners.xml
Modified: tomcat/trunk/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java?rev=1498340&r1=1498339&r2=1498340&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java Mon Jul 1 09:50:38 2013
@@ -20,8 +20,11 @@ package org.apache.catalina.mbeans;
import java.io.IOException;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
+import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.ServerSocket;
import java.net.Socket;
+import java.net.UnknownHostException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.RMIClientSocketFactory;
@@ -61,6 +64,7 @@ public class JmxRemoteLifecycleListener
protected static final StringManager sm =
StringManager.getManager(Constants.Package);
+ protected String rmiBindAddress = null;
protected int rmiRegistryPortPlatform = -1;
protected int rmiServerPortPlatform = -1;
protected boolean rmiSSL = true;
@@ -76,6 +80,22 @@ public class JmxRemoteLifecycleListener
protected JMXConnectorServer csPlatform = null;
/**
+ * Get the inet address on which the Platform RMI server is exported.
+ * @return The textual representation of inet address
+ */
+ public String getRmiBindAddress() {
+ return rmiBindAddress;
+ }
+
+ /**
+ * Set the inet address on which the Platform RMI server is exported.
+ * @param theRmiBindAddress The textual representation of inet address
+ */
+ public void setRmiBindAddress(String theRmiBindAddress) {
+ rmiBindAddress = theRmiBindAddress;
+ }
+
+ /**
* Get the port on which the Platform RMI server is exported. This is the
* port that is normally chosen by the RMI stack.
* @return The port number
@@ -189,11 +209,28 @@ public class JmxRemoteLifecycleListener
// Configure SSL for RMI connection if required
if (rmiSSL) {
+ if (rmiBindAddress != null) {
+ throw new IllegalStateException(sm.getString(
+ "jmxRemoteLifecycleListener.sslRmiBindAddress"));
+ }
+
csf = new SslRMIClientSocketFactory();
ssf = new SslRMIServerSocketFactory(ciphers, protocols,
clientAuth);
}
+ // Force server bind address if required
+ if (rmiBindAddress != null) {
+ try {
+ ssf = new RmiServerBindSocketFactory(
+ InetAddress.getByName(rmiBindAddress));
+ } catch (UnknownHostException e) {
+ log.error(sm.getString(
+ "jmxRemoteLifecycleListener.invalidRmiBindAddress",
+ rmiBindAddress), e);
+ }
+ }
+
// Force the use of local ports if required
if (useLocalPorts) {
csf = new RmiClientLocalhostSocketFactory(csf);
@@ -219,7 +256,7 @@ public class JmxRemoteLifecycleListener
// Create the Platform server
csPlatform = createServer("Platform", rmiRegistryPortPlatform,
- rmiServerPortPlatform, env,
+ rmiServerPortPlatform, env, csf, ssf,
ManagementFactory.getPlatformMBeanServer());
} else if (Lifecycle.STOP_EVENT == event.getType()) {
@@ -229,11 +266,12 @@ public class JmxRemoteLifecycleListener
private JMXConnectorServer createServer(String serverName,
int theRmiRegistryPort, int theRmiServerPort,
- HashMap<String,Object> theEnv, MBeanServer theMBeanServer) {
+ HashMap<String,Object> theEnv, RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf, MBeanServer theMBeanServer) {
// Create the RMI registry
try {
- LocateRegistry.createRegistry(theRmiRegistryPort);
+ LocateRegistry.createRegistry(theRmiRegistryPort, csf, ssf);
} catch (RemoteException e) {
log.error(sm.getString(
"jmxRemoteLifecycleListener.createRegistryFailed",
@@ -289,7 +327,8 @@ public class JmxRemoteLifecycleListener
}
public static class RmiClientLocalhostSocketFactory
- implements RMIClientSocketFactory, Serializable {
+ implements RMIClientSocketFactory, Serializable {
+
private static final long serialVersionUID = 1L;
private static final String FORCED_HOST = "localhost";
@@ -308,7 +347,20 @@ public class JmxRemoteLifecycleListener
return factory.createSocket(FORCED_HOST, port);
}
}
+ }
+
+ public static class RmiServerBindSocketFactory
+ implements RMIServerSocketFactory {
+ private final InetAddress bindAddress;
+ public RmiServerBindSocketFactory(InetAddress address) {
+ bindAddress = address;
+ }
+
+ @Override
+ public ServerSocket createServerSocket(int port) throws IOException {
+ return new ServerSocket(port, 0, bindAddress);
+ }
}
}
Modified: tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties?rev=1498340&r1=1498339&r2=1498340&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/mbeans/LocalStrings.properties Mon Jul 1 09:50:38 2013
@@ -18,5 +18,7 @@ jmxRemoteLifecycleListener.createServerF
jmxRemoteLifecycleListener.destroyServerFailed=The JMX connector server could not be stopped for the {0} server
jmxRemoteLifecycleListener.invalidURL=The JMX Service URL requested for the {0} server, "{1}", was invalid
jmxRemoteLifecycleListener.start=The JMX Remote Listener has configured the registry on port {0} and the server on port {1} for the {2} server
+jmxRemoteLifecycleListener.sslRmiBindAddress=rmiBindAddress is incompatible with setting the system property com.sun.management.jmxremote.ssl to true
+jmxRemoteLifecycleListener.invalidRmiBindAddress=Invalid RMI bind address [{0}]
mBeanFactory.managerContext=Manager components may only be added to Contexts.
Modified: tomcat/trunk/webapps/docs/config/listeners.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1498340&r1=1498339&r2=1498340&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/trunk/webapps/docs/config/listeners.xml Mon Jul 1 09:50:38 2013
@@ -434,6 +434,13 @@
<p>The port to be used by the Platform JMX/RMI server.</p>
</attribute>
+ <attribute name="rmiBindAddress" required="false">
+ <p>The address of the interface to be used by JMX/RMI server. Setting
+ this option to <code>true</code> is incompatible with setting the system
+ property <code>com.sun.management.jmxremote.ssl</code> to
+ <code>true</code>.</p>
+ </attribute>
+
<attribute name="useLocalPorts" required="false">
<p>Should any clients using these ports be forced to use local ports to
connect to the the JMX/RMI server. This is useful when tunnelling
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1498340 - in /tomcat/trunk: java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
java/org/apache/catalina/mbeans/LocalStrings.properties webapps/docs/config/listeners.xml
Posted by Mark Thomas <ma...@apache.org>.
On 01/07/2013 11:59, Rainer Jung wrote:
> On 01.07.2013 11:50, markt@apache.org wrote:
>> Add the ability to configure the RMO bind address when using the JXM remote listener.
>
> Coffee to the rescue: RMO points to "Rocky Mountain oysters are bull
> calf testicles used for human consumption" and "JXM is a pure-java
> (SWING) GUI for controlling the XMPCR, which is a USB powered and
> controlled XM radio.". The later is probably a good extension for Tomcat.
>
> Have a nice day
:)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1498340 - in /tomcat/trunk: java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java
java/org/apache/catalina/mbeans/LocalStrings.properties webapps/docs/config/listeners.xml
Posted by Rainer Jung <ra...@kippdata.de>.
On 01.07.2013 11:50, markt@apache.org wrote:
> Add the ability to configure the RMO bind address when using the JXM remote listener.
Coffee to the rescue: RMO points to "Rocky Mountain oysters are bull
calf testicles used for human consumption" and "JXM is a pure-java
(SWING) GUI for controlling the XMPCR, which is a USB powered and
controlled XM radio.". The later is probably a good extension for Tomcat.
Have a nice day
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org