1

我正在尝试按照此处http://camel.apache.org/file2.html的描述实现 jpa 幂等存储库,但我遇到了 Mbean 导出错误。

在我的 application-context.xml 我有以下部分。

<bean id="mvStore" class="org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository" lazy-init="false">
        <!-- Here we refer to the spring jpaTemplate -->
        <constructor-arg index="0" ref="jpaTemplate" />
        <!-- This 2nd parameter is the name (= a cateogry name). You can have different repositories with different names -->
        <constructor-arg index="1" value="FileConsumer" />
    </bean>
<context:mbean-server id="mbeanServer" />
<context:mbean-export server="mbeanServer" registration="replaceExisting" default-domain="br.com.touchtec"/>

如果我删除上述部分,则服务器(tomcat)启动就好了。有人可以帮我吗?

这是堆栈:

Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository@6df960c4] with key 'mvStore'; nested exception is javax.management.MalformedObjectNameException: Key properties cannot be empty
    at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:602)
    at org.springframework.jmx.export.MBeanExporter.registerBeans(MBeanExporter.java:527)
    at org.springframework.jmx.export.MBeanExporter.afterPropertiesSet(MBeanExporter.java:413)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 50 more

Caused by: javax.management.MalformedObjectNameException: Key properties cannot be empty
    at javax.management.ObjectName.construct(ObjectName.java:467)
    at javax.management.ObjectName.<init>(ObjectName.java:1403)
    at javax.management.ObjectName.getInstance(ObjectName.java:1285)
    at org.springframework.jmx.support.ObjectNameManager.getInstance(ObjectNameManager.java:62)
    at org.springframework.jmx.export.naming.MetadataNamingStrategy.getObjectName(MetadataNamingStrategy.java:114)
    at org.springframework.jmx.export.MBeanExporter.getObjectName(MBeanExporter.java:728)
    at org.springframework.jmx.export.MBeanExporter.registerBeanInstance(MBeanExporter.java:631)
    at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:592)
    ... 54 more
4

1 回答 1

0

首先,我希望您清楚 jmx 部分不是使 Idempotent Repository 工作所必需的事实。您的错误是纯 JMX/Spring 错误,与 Camel 无关。

如果您想使用 MBeanExporter,您应该阅读Spring JMX的官方文档以更好地了解这件事。

您的 MBeanExporter 定义可能看起来像

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
    <property name="beans">
      <map>
        <entry key="bean:name=mvStore" value-ref="mvStore"/>
      </map>
    </property>
    <property name="server" ref="mbeanServer"/>
  </bean>
于 2012-08-24T07:57:03.667 回答