4
无法连接到Tomcat JMX实例连接到Tomcat JMX服务器无法
好吧,我现在我坚持 - 我试着与Tomcat的配置JMX如下
$CATALINA_BASE/setenv.sh
:
CATALINA_OPTS="-Dcom.sun.management.jmxremote.port=18070 -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access"
export CATALINA_OPTS
$CATALINA_BASE/conf/jmxremote.password
monitorRole monitorpass
controlRole controlpass
$CATALINA_BASE/conf/jmxremote.access
monitorRole readonly
controlRole readwrite
我用来访问Tomcat JMX服务器的客户端工具与Tomcat实例在同一台机器上运行。当我启动tomcat我可以看到,也有一些是在听端口18070,但是当我尝试连接,我收到以下错误
Exception in thread "main" java.lang.SecurityException: Authentication failed! Credentials required
at com.sun.jmx.remote.security.JMXPluggableAuthenticator.authenticationFailure(JMXPluggableAuthenticator.java:193)
at com.sun.jmx.remote.security.JMXPluggableAuthenticator.authenticate(JMXPluggableAuthenticator.java:145)
at sun.management.jmxremote.ConnectorBootstrap$AccessFileCheckerAuthenticator.authenticate(ConnectorBootstrap.java:185)
at javax.management.remote.rmi.RMIServerImpl.doNewClient(RMIServerImpl.java:213)
我连接使用下面的代码位
try {
url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:18070/jmxrmi");
jmxc = JMXConnectorFactory.connect(url,null);
mbsc = jmxc.getMBeanServerConnection();
} catch (MalformedURLException e) {
throw new Exception(methodName + ":" + e);
} catch (IOException e) {
throw new Exception(methodName + ":" + "Failed to connect to the Tomcat Server " + e);
}
它的工作原理很好,如果我设置com.sun.management.jmxremote.authenticate = true为false。除此之外,它只是失败。客户端工具与tomcat实例在同一台机器上运行,因此防火墙不应该存在任何问题。任何线索
哦,我不知道,我不得不提供从客户端的凭据。我认为Tomcat会从密码文件中读取它们。我会尝试上面的例子谢谢。 – ziggy 2011-01-13 14:00:28