使用activemq的BrokerViewMBean时出现异常

时间:2012-10-25 17:46:17

标签: activemq jmx

我正在尝试从运行activemq代理的同一进程中访问jmx功能,并通过Web服务公开某些属性。代码如下:

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    try {
        ObjectName name = new ObjectName("org.apache.activemq:BrokerName=locahost,Type=Broker");
        BrokerViewMBean brokerViewMBean = JMX.newMBeanProxy(mbs, name, BrokerViewMBean.class);
        ObjectName[] queues = brokerViewMBean.getQueues();
        .
        .
        .
    } catch (Exception e) {
        e.printStackTrace();
    }

当我运行此代码时,我得到以下异常:

  

java.lang.reflect.UndeclaredThrowableException at   $ Proxy51.getQueues(未知来源)at   com.myinc.MyObject.getAllQueues(MyObject.java:37)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)     在java.lang.reflect.Method.invoke(Method.java:597)at   org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)     在   org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)     在   org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)     在   org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64)     在   org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:75)     在   org.apache.cxf.interceptor.ServiceInvokerInterceptor $ 1.run(ServiceInvokerInterceptor.java:58)     在   java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:441)     at java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303)     在java.util.concurrent.FutureTask.run(FutureTask.java:138)at   org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)     在   org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)     在   org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)     在   org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)     在   org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:211)     在   org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213)     在   org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:193)     在   org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:130)     在   org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:221)     在   org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:141)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:637)at   org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:197)     在   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)     在   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)     在   org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:602)     在   org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:489)     在java.lang.Thread.run(Thread.java:662)引起:   javax.management.InstanceNotFoundException:   org.apache.activemq:BrokerName = locahost,Type = Broker at   com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1094)     在   com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(DefaultMBeanServerInterceptor.java:662)     在   com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.java:638)     在   javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:263)     ... 39更多

任何人都可以让我知道我做错了什么,试图说这个例外是什么?

感谢。

1 个答案:

答案 0 :(得分:3)

线索是由部分例外引起的:

Caused by: javax.management.InstanceNotFoundException: org.apache.activemq:BrokerName=locahost,Type=Broker at 

您使用的对象名称必须不正确或代理尚未运行。您可以使用jconsole附加到进程并查看有效的ObjectNames是什么。