尝试使用Java中的插件配置活动MQ代理,<bean class =“...”>属性应该指向哪个?</bean>

时间:2012-04-12 09:43:38

标签: plugins jms activemq

我正在尝试配置一个安装了插件的activemq代理,但似乎无法在代理配置文件中获取插件类的限定名称。 我已经粘贴了下面的代理配置后面的错误消息。基本上在我指定的元素中 类= “文件:C:/马库斯/ JavaProjects /项目/建造/ PROD /类/ COM /富/ JMS / amqplugin / XmlValidationPlugin” 这是XmlValidationPlugin.class文件的绝对路径(尝试将.class附加到上面的路径但我得到相同的错误)。 最初我假设class属性应该指向.class文件但是已经尝试将其指向.java但仍然无效。 我已经阅读了有关开发插件,常见问题解答,弹簧文档等的活动MQ常见问题解答。

我的班级路径是 ; JAVA_HOME \ lib中; C:\马库斯\ JavaProjects \项目; C:\马库斯\ JavaProjects \项目\构建\ PROD \类 和JAVA_HOME是: C:\ Program Files \ Java \ jdk1.7.0_03

所有java源都驻留在 C:\马库斯\ JavaProjects \项目\ SRC 并且.class文件在 C:\马库斯\ JavaProjects \项目\编译\ PROD \班 (例如,类中的文件结构镜像src中的文件结构 com.foo.jms.amqplugin.XmlValidationPlugin 将有.class文件 classes / com / foo / jms / amqplugin)

有问题的插件是XmlValidationPlugin.java,位于包中的src文件夹中: com.foo.jms.amqplugin

我已经尝试将XmlValidationPlugin.class放在JAR中并将JAR放在activemqinstalldir / lib中(正如其他有类似问题的人所推荐的那样),但这没有帮助。

我已经花了一天半的时间,如果有人知道插件类属性的值应该是什么,我会非常感激,因为我已经尝试了所有的东西......提前谢谢!

错误输出:

C:\Program Files\apache-activemq-5.5.1>bin\activemq xbean:file:C:/Marcus/JavaProjects/Project/config/custom-broker.xml
Java Runtime: Oracle Corporation 1.7.0_03 C:\Program Files\Java\jdk1.7.0_03\jre
  Heap sizes: current=15872k  free=14246k  max=506816k
    JVM args: -Dcom.sun.management.jmxremote -Xmx512M -Dorg.apache.activemq.UseDedicatedTaskRunner=true -Djava.util.logging.config.file=logging.properties -Dactivemq.classpath=C:\Program Files\apache-
activemq-5.5.1\bin\../conf;C:\Program Files\apache-activemq-5.5.1\bin\../conf; -Dactivemq.home=C:\Program Files\apache-activemq-5.5.1\bin\.. -Dactivemq.base=C:\Program Files\apache-activemq-5.5.1\bin\
..
ACTIVEMQ_HOME: C:\Program Files\apache-activemq-5.5.1\bin\..
ACTIVEMQ_BASE: C:\Program Files\apache-activemq-5.5.1\bin\..
Loading message broker from: xbean:file:C:/Marcus/JavaProjects/Project/config/custom-broker.xml
 INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@7a8ba4: startup date [Thu Apr 12 10:38:26 CEST 2012]; root of context hierarchy
ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load type: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin. Reason: java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin; nested exception is java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin
java.lang.RuntimeException: Failed to execute start task. Reason: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to load type: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin. 
Reason: java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin; nested exception is java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin
        at org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:98)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:143)
        at org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:57)
        at org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    ...

BROKER CONFIG FILE:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this configuration file -->
  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <value>file:${activemq.base}/conf/credentials.properties</value>
    </property>
  </bean>

  <!--The <broker> element is used to configure the ActiveMQ broker. -->
  <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost"
    dataDirectory="${activemq.base}/data">

        ...


    <!--plugin-->
    <plugins>
      <bean xmlns="http://www.springframework.org/schema/beans" 
            id="xmlValidationPlugin"  
            class="com.foo.jms.amqplugin.XmlValidationPlugin"/>
    </plugins>


  </broker>


</beans>

1 个答案:

答案 0 :(得分:1)

  

在元素中基本上我指定了class =“file:C:/ Marcus / JavaProjects / Project / build / prod / classes / com / foo / jms / amqplugin / XmlValidationPlugin”,它是XmlValidationPlugin.class的绝对路径文件(尝试将.class附加到上面的路径但我得到相同的错误)。最初我假设class属性应该指向.class文件,但是尝试将它指向.java并且仍然不起作用。

您看到的错误似乎来自于类加载器。

Reason: java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin; nested exception is java.lang.ClassNotFoundException: file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin

Classloader需要一个完全限定的类名而不是类文件的路径。尝试指定完全限定的类名,而不是类文件的路径。

而不是:

file:C:/Marcus/JavaProjects/Project/build/prod/classes/com/foo/jms/amqplugin/XmlValidationPlugin

使用:

com.foo.jms.amqplugin.XmlValidationPlugin

并确保CLASSPATH环境变量将包含:C:/ Marcus / JavaProjects / Project / build / prod / classes

如果ActiveMQ使用一些自定义类加载器来加载插件(我不知道详细信息),您可能需要以某种特定于ActivemMQ的方式指定类路径。