activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidmc <aranman...@gmail.com>
Subject Re: Plugin development question
Date Thu, 05 Apr 2007 06:05:16 GMT

Hello James,

"mvn -o clean install -Dmaven.test.skip=true" did the trick :) Now my plugin
prints "hello" when launching the broker hehe.
This worked even if I don't launch the broker as a .jar, but just executing
"org.apache.activemq.console.Main start" from Eclipse. I actually don't know
very well what the "assembly" is...

Thank you very much for the quick and useful answer :)

David


James.Strachan wrote:
> 
> FWIW you can always use the <spring:bean class="com.acme.MyPlugin"/>
> as an alternative to <myPlugin/>
> 
> I guess your classpath (assembly) must have a jar with an old version
> of the XBean stuff (in the file
> META-INF/services/org/apache/xbean/spring/http/activemq.org/config/1.0
> inside a jar). It might be worth noodling in some of your
> jars/classpath to see if  you've another activemq jar without your
> generated jar.
> 
> e.g. I'd recommend from the activemq directory doing
> 
> mvn -o clean install -Dmaven.test.skip=true
> 
> then trying your assembly, just to make sure maven didn't download
> some newer built snapshot; and to ensure the assembly is properly
> built etc.
> 
> 
> On 4/4/07, davidmc <aranmanoth@gmail.com> wrote:
>>
>> Hello all,
>>
>> I am trying to develop a simple interceptor plugin for ActiveMQ.
>> For now I'm just writing a "dummy plugin" in order to integrate it with
>> the
>> rest of ActiveMQ.
>> In the end I want to do something similar to the LoggingBrokerPlugin
>> class.
>>
>> My code so far is:
>>
>> [java code]
>>
>> package org.apache.activemq.myPlugin;
>>
>> import org.apache.activemq.broker.BrokerPluginSupport;
>> import org.apache.activemq.broker.ProducerBrokerExchange;
>> import org.apache.activemq.command.Message;
>>
>> /**
>>  * Test plugin
>>  *
>>  * @org.apache.xbean.XBean element="myPlugin"
>>  *
>>  */
>> public class MyPlugin extends BrokerPluginSupport{
>>
>>     @Override
>>     public void start() throws Exception {
>>         System.err.println("hello");
>>         super.start();
>>     }
>>
>>     @Override
>>     public void stop() throws Exception {
>>         System.err.println("goodbye");
>>         super.stop();
>>     }
>>
>>     @Override
>>     public void send(ProducerBrokerExchange producerExchange, Message
>> messageSend) throws Exception {
>>         System.err.println("message sent");
>>         super.send(producerExchange, messageSend);
>>     }
>>
>> }
>>
>> [/ java code]
>>
>> I want to load the plugin by writing in the activemq.xml file the
>> following:
>>
>> [activemq.xml file]
>> <!-- START SNIPPET: xbean -->
>> <beans>
>>
>>   <bean
>> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
>>   <broker useJmx="true"  xmlns="http://activemq.org/config/1.0"
>> persistent="false">
>>
>>     <transportConnectors>
>>       <transportConnector uri="tcp://localhost:61616"/>
>>     </transportConnectors>
>>
>>     <plugins>
>>       <myPlugin/>
>>     </plugins>
>>
>>   </broker>
>>
>> </beans>
>> <!-- END SNIPPET: xbean -->
>>
>> [/activemq.xml file]
>>
>> I have run maven on the activemq-core files so that it generates files
>> such
>> as
>> activemq-core/target/xbean/META-INF/services/org/apache/xbean/spring/http/activemq.org/config/1.0
>> , activemq-core/target/xbean/activemq.xsd, etc. from the
>> @org.apache.xbean.XBean tag.
>> My plugin "myPlugin" does indeed appear in the 1.0 file.
>>
>> However, I still get this exception when I launch the broker with
>> activemq-console/src/main/java/org/apache/activemq/console/Main start :
>>
>> [broker log]
>> ACTIVEMQ_HOME: ..\.
>> ACTIVEMQ_BASE: ..\.
>> Loading message broker from: xbean:activemq.xml
>> Now attempting to figure out the type of resource: activemq.xml
>>
>> ( ... usual stuff ... )
>>
>> 2007-04-04 17:54:16,921 [main           ] DEBUG
>> anBeanDefinitionDocumentReader - Loading bean definitions
>> 2007-04-04 17:54:16,968 [main           ] DEBUG
>> anBeanDefinitionParserDelegate - Neither XML 'id' nor 'name' specified -
>> using generated bean name
>> [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]
>> 2007-04-04 17:54:16,984 [main           ] DEBUG XBeanNamespaceHandler
>> - Could not find resource:
>> META-INF/services/org/apache/xbean/spring/http/activemq.org/config/1.0/broker
>> 2007-04-04 17:54:17,046 [main           ] DEBUG
>> anBeanDefinitionParserDelegate - Neither XML 'id' nor 'name' specified -
>> using generated bean name [org.apache.activemq.xbean.XBeanBrokerService]
>> 2007-04-04 17:54:17,046 [main           ] DEBUG XBeanNamespaceHandler
>> - Could not find resource:
>> META-INF/services/org/apache/xbean/spring/http/activemq.org/config/1.0/transportConnector
>> 2007-04-04 17:54:17,062 [main           ] DEBUG
>> anBeanDefinitionParserDelegate - Neither XML 'id' nor 'name' specified -
>> using generated bean name [org.apache.activemq.broker.TransportConnector]
>> 2007-04-04 17:54:17,078 [main           ] DEBUG XBeanNamespaceHandler
>> - Could not find resource:
>> META-INF/services/org/apache/xbean/spring/http/activemq.org/config/1.0/loggingBrokerPlugin
>> 2007-04-04 17:54:17,109 [main           ] DEBUG
>> anBeanDefinitionParserDelegate - Neither XML 'id' nor 'name' specified -
>> using generated bean name
>> [org.apache.activemq.broker.util.LoggingBrokerPlugin]
>> 2007-04-04 17:54:17,109 [main           ] DEBUG XBeanNamespaceHandler
>> - Could not find resource:
>> META-INF/services/org/apache/xbean/spring/http/activemq.org/config/1.0/myPlugin
>> ERROR: java.lang.RuntimeException: Failed to execute start task. Reason:
>> org.springframework.beans.factory.BeanDefinitionStoreException:
>> Unrecognized
>> xbean element mapping: myPlugin in namespace
>> http://activemq.org/config/1.0
>> java.lang.RuntimeException: Failed to execute start task. Reason:
>> org.springframework.beans.factory.BeanDefinitionStoreException:
>> Unrecognized
>> xbean element mapping: myPlugin in namespace
>> http://activemq.org/config/1.0
>>         at
>> org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:70)
>>         at
>> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:50)
>>         at
>> org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:105)
>>         at
>> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:50)
>>         at
>> org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:77)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>         at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>         at org.apache.activemq.console.Main.runTaskClass(Main.java:213)
>>         at org.apache.activemq.console.Main.main(Main.java:102)
>> Caused by:
>> org.springframework.beans.factory.BeanDefinitionStoreException:
>> Unrecognized xbean element mapping: myPlugin in namespace
>> http://activemq.org/config/1.0
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:258)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:152)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1147)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseNestedCustomElement(BeanDefinitionParserDelegate.java:1185)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>         at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanBeanDefinitionParserDelegate.internalParseNestedCustomElement(XBeanBeanDefinitionParserDelegate.java:94)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanBeanDefinitionParserDelegate.parsePropertySubElement(XBeanBeanDefinitionParserDelegate.java:51)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseListElement(BeanDefinitionParserDelegate.java:935)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseListElement(XBeanNamespaceHandler.java:584)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseNestedPropertyViaIntrospection(XBeanNamespaceHandler.java:577)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.tryParseNestedPropertyViaIntrospection(XBeanNamespaceHandler.java:546)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.addNestedPropertyElements(XBeanNamespaceHandler.java:515)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:211)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:256)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:152)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1147)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1137)
>>         at
>> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:145)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanBeanDefinitionDocumentReader.parseBeanDefinitions(XBeanBeanDefinitionDocumentReader.java:63)
>>         at
>> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:89)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:499)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.registerBeanDefinitions(XBeanXmlBeanDefinitionReader.java:79)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:407)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:357)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.loadBeanDefinitions(ResourceXmlApplicationContext.java:111)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.loadBeanDefinitions(ResourceXmlApplicationContext.java:104)
>>         at
>> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:94)
>>         at
>> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:294)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
>>         at
>> org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:91)
>>         at
>> org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:49)
>>         at
>> org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:65)
>>         at
>> org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:51)
>>         at
>> org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:82)
>>         at
>> org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:47)
>>         ... 10 more
>> ERROR: java.lang.Exception:
>> org.springframework.beans.factory.BeanDefinitionStoreException:
>> Unrecognized
>> xbean element mapping: myPlugin in namespace
>> http://activemq.org/config/1.0
>> java.lang.Exception:
>> org.springframework.beans.factory.BeanDefinitionStoreException:
>> Unrecognized
>> xbean element mapping: myPlugin in namespace
>> http://activemq.org/config/1.0
>>         at
>> org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:71)
>>         at
>> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:50)
>>         at
>> org.apache.activemq.console.command.ShellCommand.runTask(ShellCommand.java:105)
>>         at
>> org.apache.activemq.console.command.AbstractCommand.execute(AbstractCommand.java:50)
>>         at
>> org.apache.activemq.console.command.ShellCommand.main(ShellCommand.java:77)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>         at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>         at org.apache.activemq.console.Main.runTaskClass(Main.java:213)
>>         at org.apache.activemq.console.Main.main(Main.java:102)
>> Caused by:
>> org.springframework.beans.factory.BeanDefinitionStoreException:
>> Unrecognized xbean element mapping: myPlugin in namespace
>> http://activemq.org/config/1.0
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:258)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:152)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1147)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseNestedCustomElement(BeanDefinitionParserDelegate.java:1185)
>>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>         at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>         at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>         at java.lang.reflect.Method.invoke(Method.java:585)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanBeanDefinitionParserDelegate.internalParseNestedCustomElement(XBeanBeanDefinitionParserDelegate.java:94)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanBeanDefinitionParserDelegate.parsePropertySubElement(XBeanBeanDefinitionParserDelegate.java:51)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseListElement(BeanDefinitionParserDelegate.java:935)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseListElement(XBeanNamespaceHandler.java:584)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseNestedPropertyViaIntrospection(XBeanNamespaceHandler.java:577)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.tryParseNestedPropertyViaIntrospection(XBeanNamespaceHandler.java:546)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.addNestedPropertyElements(XBeanNamespaceHandler.java:515)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:211)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:256)
>>         at
>> org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:152)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1147)
>>         at
>> org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1137)
>>         at
>> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:145)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanBeanDefinitionDocumentReader.parseBeanDefinitions(XBeanBeanDefinitionDocumentReader.java:63)
>>         at
>> org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:89)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:499)
>>         at
>> org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.registerBeanDefinitions(XBeanXmlBeanDefinitionReader.java:79)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:407)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:357)
>>         at
>> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.loadBeanDefinitions(ResourceXmlApplicationContext.java:111)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.loadBeanDefinitions(ResourceXmlApplicationContext.java:104)
>>         at
>> org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:94)
>>         at
>> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:294)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
>>         at
>> org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
>>         at
>> org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:91)
>>         at
>> org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:49)
>>         at
>> org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:65)
>>         at
>> org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:51)
>>         at
>> org.apache.activemq.console.command.StartCommand.startBroker(StartCommand.java:82)
>>         at
>> org.apache.activemq.console.command.StartCommand.runTask(StartCommand.java:47)
>>         ... 10 more
>>
>> [/broker log]
>>
>> I am using ActiveMQ 4.2 trunk, building from source with maven
>> eclipse:eclipse and eclipse.
>>
>> What am I missing so that my plugin is recognized in the activemq.xml
>> file?
>> I have read the docs at
>> http://activemq.apache.org/developing-plugins.html
>> and http://activemq.apache.org/interceptors.html and others, looked in
>> the
>> forum, but so far no luck :(
>> I would be very grateful if you had some tip :)
>>
>> Thank you in advance for your help :)
>>
>> David
>> --
>> View this message in context:
>> http://www.nabble.com/Plugin-development-question-tf3524712s2354.html#a9833560
>> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/Plugin-development-question-tf3524712s2354.html#a9850511
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message