【发布时间】:2014-04-27 15:05:25
【问题描述】:
最近我在我的 Spring Web 应用程序中添加了 JMX 支持。
这对于带有@Component 的bean 来说很好,但是,对于某些服务,在添加@ManagedResource 时似乎会出现问题
我有一个使用@Service 方法注释的spring 服务。
我正在尝试使用 @ManagedResource 将 JMX 添加到该服务,但似乎 spring 在注册 bean 时遇到了问题:
org.springframework.beans.factory.BeanCreationException:
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'mbeanExporter': Invocation of init method
failed; nested exception is
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable
to register MBean [...] with key 'appAnalysisServiceImpl'; nested
exception is org.springframework.jmx.export.MBeanExportException:
Could not create ModelMBean for managed resource [
l@6142152] with key 'myservice'; nested exception is java.lang.IllegalArgumentException: MetadataMBeanInfoAssembler does
not support JDK dynamic proxies - export the target beans directly or
use CGLIB proxies instead
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
从异常消息看来,spring 似乎需要一个用于此类类的特殊导出器。 如何在不编写自己的导出器的情况下直接导出 bean?
【问题讨论】:
标签: java spring jakarta-ee jmx