运行jhipster示例应用程序的JMX错误

时间:2014-09-05 07:47:16

标签: spring-boot jhipster

运行jhipster示例应用程序时出错:

[ERROR] org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
javax.management.RuntimeOperationsException: null
    at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:411) ~[na:1.7.0_40]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898) ~[na:1.7.0_40]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:966) ~[na:1.7.0_40]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:900) ~[na:1.7.0_40]
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:324) ~[na:1.7.0_40]
    at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522) ~[na:1.7.0_40]
    at com.codahale.metrics.JmxReporter$JmxListener.onGaugeAdded(JmxReporter.java:494) ~[metrics-core-3.0.2.jar:3.0.2]
    at com.codahale.metrics.MetricRegistry.notifyListenerOfAddedMetric(MetricRegistry.java:344) ~[metrics-core-3.0.2.jar:3.0.2]
    at com.codahale.metrics.MetricRegistry.onMetricAdded(MetricRegistry.java:338) ~[metrics-core-3.0.2.jar:3.0.2]
    at com.codahale.metrics.MetricRegistry.register(MetricRegistry.java:89) ~[metrics-core-3.0.2.jar:3.0.2]
    at org.springframework.boot.actuate.metrics.writer.CodahaleMetricWriter.set(CodahaleMetricWriter.java:107) ~[spring-boot-actuator-1.1.5.RELEASE.jar:1.1.5.RELEASE]
    at org.springframework.boot.actuate.metrics.writer.CompositeMetricWriter.set(CompositeMetricWriter.java:54) ~[spring-boot-actuator-1.1.5.RELEASE.jar:1.1.5.RELEASE]
    at org.springframework.boot.actuate.metrics.writer.DefaultGaugeService.submit(DefaultGaugeService.java:41) ~[spring-boot-actuator-1.1.5.RELEASE.jar:1.1.5.RELEASE]
    at org.springframework.boot.actuate.autoconfigure.MetricFilterAutoConfiguration$MetricsFilter.doFilterInternal(MetricFilterAutoConfiguration.java:103) ~[spring-boot-actuator-1.1.5.RELEASE.jar:1.1.5.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) ~[tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) ~[tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1720) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1679) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_40]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_40]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-7.0.54.jar:7.0.54]
    at java.lang.Thread.run(Thread.java:724) [na:1.7.0_40]
Caused by: java.lang.IllegalArgumentException: Repository: cannot add mbean for pattern name metrics:name=gauge.response.

1 个答案:

答案 0 :(得分:1)

我来晚了,但我遇到了same issue with RESTX,经过进一步调查后,当URL包含在JMX MBean名称中解释为模式的字符时(即*?) 。实际上,当框架(在您的情况下为spring boot)为此URL添加度量标准时,来自Codahale Metrics的JMXReporter将尝试注册具有该名称的MBean,该MBean因该异常而失败(消息不是很有帮助)。

source code for the JMX Repository更能说明问题。

可能的解决方案:

  • 将Metrics升级到v3.1.0或更高版本(名称已从codahale指标更改为dropwizard指标),并注册您自己的ObjectNameFactory修复此问题。这是the approach I've used in RESTX
  • 如果可以的话,至少为此URL禁用JMXReporter(我还没有检查过弹簧启动以查看是否可以)
  • 覆盖指标过滤器以转义导致问题的字符