2014-04-27 47 views
1

最近我向我的Spring Web應用程序添加了JMX支持。MetadataMBeanInfoAssembler不支持JDK動態代理

也能正常工作與@Component豆,但是,對於一些服務似乎有增加@ManagedResource

時是一個問題,我有@Service方法註解彈簧的服務。 我想JMX添加到使用@ManagedResource該服務,但它似乎像彈簧,在遇到問題時註冊豆:

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 [ 
    [email protected]] 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) 

從它就像是春天的異常信息,需要爲這種類的特殊出口國。 我如何直接導出bean而無需編寫自己的導出程序?

回答

0

如果您的服務使用@Transactional,那麼Spring將無法創建ModelBean,因爲該服務是代理的。