English 中文(简体)
能否让JMX 进入嵌入的7号托姆卡特?
原标题:Is it possible to enable JMX in embedded Tomcat 7?

我想在我的网络应用程序中访问 Server Connector 。 此外,我还需要从嵌入的Tomcat 启动这个网络应用程序。 下面是我如何启动Tomcat:

Tomcat tomcat = new Tomcat();
tomcat.setPort(port);
StandardServer server = (StandardServer) tomcat.getServer();
server.addLifecycleListener(new AprLifecycleListener());
tomcat.addWebapp("/", webapp.getAbsolutePath());
tomcat.start();
tomcat.getServer().await();

当我使用"> 通过JMX访问服务器的典型例子 1 :

import javax.management.*;
import org.apache.catalina.Server;

MBeanServer mBeanServer = MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName name = new ObjectName("Catalina", "type", "Server");
Server server = (Server) mBeanServer.getAttribute(name, "managedResource");

我理解: 我理解: I get: I get::

Caused by: javax.management.InstanceNotFoundException: Catalina:type=Server
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:662)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:638)

我猜是因为我不知怎的 没能成功诱杀JMX

最佳回答

JMX似乎运行正常, 问题就在于我用来查查的这个名字。 问题应该是:

ObjectName name = new ObjectName("Tomcat", "type", "Server");

取而代之。

问题回答

使用 PR_JVMOTIONS 就可以了。 我用我嵌入的 Tomcat 安装服务文件中的以下配置参数解决了这个问题。

set PR_JVMOPTIONS=-Dcom.sun.management.jmxremote.authenticate=false;-Dcom.sun.management.jmxremote.ssl=false;-Dcom.sun.management.jmxremote.port=9111




相关问题
Tomcat´s server.xml dynamic configuration

My web application uses the same database configuration as the application XYZ. I have a resource declaration for a context in server.xml, so I have a duplicated configuration (once for web ...

session transfer issue from Tomcat to ASP.Net

I am using Tomcat to host JSP and using IIS 7.0 to host aspx (C# + .Net 3.5 + VSTS 2008), and I have some session transfer issue from JSP page to ASPX page. JSP page is in one domain and all other ...

JSP exception - class not found (tomcat)

I m setting up an existing application on a new Tomcat 5.5 server connecting to a Postgres database (running on Debian Lenny). When I access it I get a series of stack traces with the following root ...

热门标签