You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by veton <ve...@belgacom.be> on 2007/07/25 10:43:32 UTC

CAMEL and ActiveMQ5 - Integration

I like the idea of having CAMEL integrated out of the box in ActiveMQ5. But
it does not seem straightforward :-[.
The problem I have are related to Spring :-(
Using Camel 1.0, Spring is not able to recognize the namespace
"http://activemq.apache.org/camel/schema/spring"
Using camel 1.1 snapshot, I 've got error of this type:
java.lang.NoSuchMethodError:
org.springframework.beans.factory.xml.ParserContext.registerComponent(Lorg/springframework/beans/factory/parsing/ComponentDefinition;)V
	at
org.apache.camel.spring.xml.CamelNamespaceHandler$1.doParse(CamelNamespaceHandler.java:88)

>From this I guess I have to work with the 1.1 snapshot, but I don't knwow
what is wrong.
Is it related to my activemq.xml config?
Any ideas?
-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a11778671
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by DominicTulley <do...@telelogic.com>.
I'm glad to hear it works for some things - at least that suggests it's just
something I'm doing wrong!

I've been debugging further and found that my jar is being picked up by the
classloader (along with all the others).  When the ResolverUtil iterates
over the URL enumeration, the enumeration skips my jar (and various others)
so I presume there's some sort of filtering going on there - but I haven't
worked out what yet.  The packages vs <package> thing is fine - the correct
package name is being passed into the code.

Are there any subtle requirements on the jar used (something in the manifest
for instance?) which might be causing it to be filtered out?

I'll keep bashing away at it for now - but I'm running out of ideas!

Thanks,

-Dominic


James.Strachan wrote:
> 
> 
> It should work! :)
> 
> So I just did a test to check this really does work. Here's what I did.
> 
> * copied the camel-example-spring.jar into the activemq/lib directory
> (in the binary distro of 5.x).
> * editied the conf/activemq.xml to look like this...
> 
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
>      <package>org.apache.camel.example</package>
>   </camelContext>
> 
> Then I started ActiveMQ and it just worked (I saw the queue
> "test.MyQueue" in the web console - then when I sent a message via the
> web console the camel processing log message appeared in the console).
> 
> I wonder - if the change you hit is the change from the "packages"
> attribute in camel 1.0 to the 0-many <package> elements in Camel 1.1?
> 
> I've just added a little warning to the 1.1 download page in case thats
> it...
> http://cwiki.apache.org/CAMEL/camel-110-release.html
> 
> also I've patched the activemq.xml in trunk with comments to show the
> new syntax etc.
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12143844
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 8/15/07, DominicTulley <do...@telelogic.com> wrote:
>
> That's a pretty freaky one.  However, I have tried it out and I agree that it
> is the cause of the problem.
>
> Thanks for all the effort.
>
> Once again, I can set off to write a real RouteBuilder :-)

Yay! :)

If anyone ever figures out how to detect/process 'bad' jars, we can
patch the code quite easily.

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration

Posted by DominicTulley <do...@telelogic.com>.
That's a pretty freaky one.  However, I have tried it out and I agree that it
is the cause of the problem.

Thanks for all the effort.  

Once again, I can set off to write a real RouteBuilder :-)

-Dominic



James.Strachan wrote:
> 
> On 8/15/07, James Strachan <ja...@gmail.com> wrote:
>> On 8/15/07, DominicTulley <do...@telelogic.com> wrote:
>> >
>> > OK, Here are two jar files.
>> >
>> > The names should make it obvious, but one works and one doesn't..
>> > http://www.nabble.com/file/p12160309/MyRouteBuilder-broken.jar
>> > MyRouteBuilder-broken.jar
>> > http://www.nabble.com/file/p12160309/MyRouteBuilder-works.jar
>> > MyRouteBuilder-works.jar
>> >
>> > The working one is built using "mvn install" from a copy of the
>> camel-spring
>> > example.  Then, I extract the jar and remove all the guff (pom files,
>> xml
>> > files et c) to prove they are not what's making it work and reconstruct
>> the
>> > jar using the jar -cvf .....
>> >
>> > The broken one is compiled and constructed using a batch file (not
>> eclipse)
>> > with the following commands:
>> > del org\dominic\*.class
>> > javac -verbose -classpath
>> >
>> jaxb-api-2.0.jar;camel-core-1.1-SNAPSHOT.jar;camel-spring-1.1-SNAPSHOT.jar;camel-activemq-1.1-SNAPSHOT.jar
>> > org\dominic\*.java
>> > jar cvf MyRouteBuilder.jar org\dominic\*.class
> 
> Ah I think I've got it.
> 
> If you create the jar without naming the .class files explicitly on
> the command line, but just listing the package names...
> 
>  jar cvf MyRouteBuilder.jar org
> 
> then it'll work. I basically took your non-working jar and did...
> 
> mkdir tmp
> cd tmp
> jar xf ../MyRouteBuilder-broken.jar
> jar cf ../MyRouteBuilder-james.jar *
> 
> Then MyRouteBuilder-james.jar works fine.
> 
> I've raised this issue to track its release...
> https://issues.apache.org/activemq/browse/CAMEL-106
> 
> I'm not exactly what we can do about this really. It seems that if you
> create the jar by passing in the actual .class files, doing a
> ClassLoader.getResource("org/dominic") doesn't find a 'directory' in
> the jar to find the .class files to look for. Am still trying to
> figure out how we can get Camel to deal with these 'bad' jars; but at
> least now you know how to make a good jar :)
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12162297
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 8/15/07, James Strachan <ja...@gmail.com> wrote:
> On 8/15/07, DominicTulley <do...@telelogic.com> wrote:
> >
> > OK, Here are two jar files.
> >
> > The names should make it obvious, but one works and one doesn't..
> > http://www.nabble.com/file/p12160309/MyRouteBuilder-broken.jar
> > MyRouteBuilder-broken.jar
> > http://www.nabble.com/file/p12160309/MyRouteBuilder-works.jar
> > MyRouteBuilder-works.jar
> >
> > The working one is built using "mvn install" from a copy of the camel-spring
> > example.  Then, I extract the jar and remove all the guff (pom files, xml
> > files et c) to prove they are not what's making it work and reconstruct the
> > jar using the jar -cvf .....
> >
> > The broken one is compiled and constructed using a batch file (not eclipse)
> > with the following commands:
> > del org\dominic\*.class
> > javac -verbose -classpath
> > jaxb-api-2.0.jar;camel-core-1.1-SNAPSHOT.jar;camel-spring-1.1-SNAPSHOT.jar;camel-activemq-1.1-SNAPSHOT.jar
> > org\dominic\*.java
> > jar cvf MyRouteBuilder.jar org\dominic\*.class

Ah I think I've got it.

If you create the jar without naming the .class files explicitly on
the command line, but just listing the package names...

 jar cvf MyRouteBuilder.jar org

then it'll work. I basically took your non-working jar and did...

mkdir tmp
cd tmp
jar xf ../MyRouteBuilder-broken.jar
jar cf ../MyRouteBuilder-james.jar *

Then MyRouteBuilder-james.jar works fine.

I've raised this issue to track its release...
https://issues.apache.org/activemq/browse/CAMEL-106

I'm not exactly what we can do about this really. It seems that if you
create the jar by passing in the actual .class files, doing a
ClassLoader.getResource("org/dominic") doesn't find a 'directory' in
the jar to find the .class files to look for. Am still trying to
figure out how we can get Camel to deal with these 'bad' jars; but at
least now you know how to make a good jar :)

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration

Posted by DominicTulley <do...@telelogic.com>.
OK, Here are two jar files.

The names should make it obvious, but one works and one doesn't..
http://www.nabble.com/file/p12160309/MyRouteBuilder-broken.jar
MyRouteBuilder-broken.jar 
http://www.nabble.com/file/p12160309/MyRouteBuilder-works.jar
MyRouteBuilder-works.jar 

The working one is built using "mvn install" from a copy of the camel-spring
example.  Then, I extract the jar and remove all the guff (pom files, xml
files et c) to prove they are not what's making it work and reconstruct the
jar using the jar -cvf .....

The broken one is compiled and constructed using a batch file (not eclipse)
with the following commands:
del org\dominic\*.class
javac -verbose -classpath
jaxb-api-2.0.jar;camel-core-1.1-SNAPSHOT.jar;camel-spring-1.1-SNAPSHOT.jar;camel-activemq-1.1-SNAPSHOT.jar
org\dominic\*.java
jar cvf MyRouteBuilder.jar org\dominic\*.class

The jar files are pulled out of Maven's repository with the hope that they
are the same ones that Maven uses (but I haven't managed to decipher the
results of mvn -X yet!).

What's left to worry about?  Well, is maven using javac or plexus (I saw
plaxus in the logs but don't know anything about it other than that it looks
like an alternative javac implementation).

I hope this helps!

-Dominic

James.Strachan wrote:
> 
> On 8/15/07, DominicTulley <do...@telelogic.com> wrote:
> 
>> I rebuilt my eclipse projects to be a bit more organised and then it
>> wouldn't work any more.
>>
>> What I have now is that if I set up an example and build it through the
>> maven mechanism that comes with the camel source tree, then I get a
>> working
>> deployment (for instance, if I copy the spring example that works so that
>> I
>> have a working POM file, then replace all the code and resources with my
>> own, then I can build it through maven and get a jar that Camel likes). 
>> If
>> I get some java files, manually compile and jar them, I get a broken jar
>> that won't work...
>>
>> Maven is yet another new tool for me.  Is there a way to see verbose
>> messages (so I can see precisely what commands it's using to build the
>> project)?
> 
> its kinda verbose - but mvn -X does the trick
> 
> 
>> Both methods appear to be using Java 1.5.0_09.
>>
>> Does the maven setup do anything in particular that might be different?
> 
> Not really. I wonder do you have a created-via-eclipse-jar that
> doesn't work for you that you could send us so we can try it out and
> see whats wrong with our eclipse-generated jars?
> 
> The java code is in the jar right? :) I wonder if there's something
> wonky about the manifest or something?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12160309
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 8/15/07, DominicTulley <do...@telelogic.com> wrote:
> It stopped working again!

Damn!

> I rebuilt my eclipse projects to be a bit more organised and then it
> wouldn't work any more.
>
> What I have now is that if I set up an example and build it through the
> maven mechanism that comes with the camel source tree, then I get a working
> deployment (for instance, if I copy the spring example that works so that I
> have a working POM file, then replace all the code and resources with my
> own, then I can build it through maven and get a jar that Camel likes).  If
> I get some java files, manually compile and jar them, I get a broken jar
> that won't work...
>
> Maven is yet another new tool for me.  Is there a way to see verbose
> messages (so I can see precisely what commands it's using to build the
> project)?

its kinda verbose - but mvn -X does the trick


> Both methods appear to be using Java 1.5.0_09.
>
> Does the maven setup do anything in particular that might be different?

Not really. I wonder do you have a created-via-eclipse-jar that
doesn't work for you that you could send us so we can try it out and
see whats wrong with our eclipse-generated jars?

The java code is in the jar right? :) I wonder if there's something
wonky about the manifest or something?

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration

Posted by DominicTulley <do...@telelogic.com>.
It stopped working again!

I rebuilt my eclipse projects to be a bit more organised and then it
wouldn't work any more.

What I have now is that if I set up an example and build it through the
maven mechanism that comes with the camel source tree, then I get a working
deployment (for instance, if I copy the spring example that works so that I
have a working POM file, then replace all the code and resources with my
own, then I can build it through maven and get a jar that Camel likes).  If
I get some java files, manually compile and jar them, I get a broken jar
that won't work...

Maven is yet another new tool for me.  Is there a way to see verbose
messages (so I can see precisely what commands it's using to build the
project)?

Both methods appear to be using Java 1.5.0_09.

Does the maven setup do anything in particular that might be different?

Thanks,

-Dominic


Sadly not - all it did was a println.  I didn't get any more ambitious than
that until I could get it to deploy..


James.Strachan wrote:
> 
> On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
>> I'm going to carry on and see if I can write a real RouteBuilder now - if
>> you want me to check or try anything else then just let me know.
> 
> Will do - still pondering what could be going wrong. If you get any
> other ideas of what could be causing issues do let us know.
> 
> e.g. I was wondering if it could be that your RouteBuilder
> imports/uses some class thats not on the classpath?
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12159901
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by DominicTulley <do...@telelogic.com>.
Sadly not - all it did was a println.  I didn't get any more ambitious than
that until I could get it to deploy..


On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
> I'm going to carry on and see if I can write a real RouteBuilder now - if
> you want me to check or try anything else then just let me know.

Will do - still pondering what could be going wrong. If you get any
other ideas of what could be causing issues do let us know.

e.g. I was wondering if it could be that your RouteBuilder
imports/uses some class thats not on the classpath?




-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12145683
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by James Strachan <ja...@gmail.com>.
On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
>
> Quite frustrating really but it looks like whatever I was doing wrong has
> "evaporated".

Damn! I hate it when that happens :)


> I'm going to carry on and see if I can write a real RouteBuilder now - if
> you want me to check or try anything else then just let me know.

Will do - still pondering what could be going wrong. If you get any
other ideas of what could be causing issues do let us know.

e.g. I was wondering if it could be that your RouteBuilder
imports/uses some class thats not on the classpath?


> I appreciate your help.

You're most welcome!

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by DominicTulley <do...@telelogic.com>.
Quite frustrating really but it looks like whatever I was doing wrong has
"evaporated".
I'm going to carry on and see if I can write a real RouteBuilder now - if
you want me to check or try anything else then just let me know.

I appreciate your help.

Thanks,

-Dominic


James.Strachan wrote:
> 
> On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
>>
>> I'm using the standard bin/activemq.bat script to start it all up.
>>
>> I have been popping around between versions 4.1.1 and 5 a bit, but the
>> comments are checked against version 5.
>>
>> The only possible explanation I have so far is that I compiled my custom
>> RouteBuilder against a version of Camel that didn't quite match that
>> which
>> is included in 5 (I suppose this could lead to it being filtered out of
>> the
>> dynamic loading).  This is possible since I've been juggling camel 1.0,
>> camel 1.1, amq 4.1.1 and amq 5.0 source trees and may not have been as
>> methodical as I should have.
> 
> Hmm - I wonder if the 'extends RouteBuilder' check somehow fails if
> you're using an older Camel or something? Am kinda grapsing at straws
> now :). AFAIK the RouteBuilder hasn't ever changed package or API...
> 
> 
>> However, this occurred to me some time ago and
>> I have extracted my source configurations more than once to ensure this
>> wasn't the case.  This also doesn't explain the wacky enumeration over
>> URLs
>> that I saw in ResolverUtil.
>>
>> Is anything known about the CompoundEnumeration class (it's a sun.misc
>> class
>> and there doesn't seem to be any source available for it).  As far as I
>> can
>> tell, its just an enumeration with no fancy filtering features but
>> perhaps
>> that's not true...
> 
> No idea!
> 
> So sorry this is causing so much pain/confusion! Am hunting around the
> code to see if I can get any kind of inspriation to explain this
> wierdness!
> 
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12145342
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by James Strachan <ja...@gmail.com>.
On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
>
> I'm using the standard bin/activemq.bat script to start it all up.
>
> I have been popping around between versions 4.1.1 and 5 a bit, but the
> comments are checked against version 5.
>
> The only possible explanation I have so far is that I compiled my custom
> RouteBuilder against a version of Camel that didn't quite match that which
> is included in 5 (I suppose this could lead to it being filtered out of the
> dynamic loading).  This is possible since I've been juggling camel 1.0,
> camel 1.1, amq 4.1.1 and amq 5.0 source trees and may not have been as
> methodical as I should have.

Hmm - I wonder if the 'extends RouteBuilder' check somehow fails if
you're using an older Camel or something? Am kinda grapsing at straws
now :). AFAIK the RouteBuilder hasn't ever changed package or API...


> However, this occurred to me some time ago and
> I have extracted my source configurations more than once to ensure this
> wasn't the case.  This also doesn't explain the wacky enumeration over URLs
> that I saw in ResolverUtil.
>
> Is anything known about the CompoundEnumeration class (it's a sun.misc class
> and there doesn't seem to be any source available for it).  As far as I can
> tell, its just an enumeration with no fancy filtering features but perhaps
> that's not true...

No idea!

So sorry this is causing so much pain/confusion! Am hunting around the
code to see if I can get any kind of inspriation to explain this
wierdness!


-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by DominicTulley <do...@telelogic.com>.
I'm using the standard bin/activemq.bat script to start it all up.

I have been popping around between versions 4.1.1 and 5 a bit, but the
comments are checked against version 5.

The only possible explanation I have so far is that I compiled my custom
RouteBuilder against a version of Camel that didn't quite match that which
is included in 5 (I suppose this could lead to it being filtered out of the
dynamic loading).  This is possible since I've been juggling camel 1.0,
camel 1.1, amq 4.1.1 and amq 5.0 source trees and may not have been as
methodical as I should have.  However, this occurred to me some time ago and
I have extracted my source configurations more than once to ensure this
wasn't the case.  This also doesn't explain the wacky enumeration over URLs
that I saw in ResolverUtil.

Is anything known about the CompoundEnumeration class (it's a sun.misc class
and there doesn't seem to be any source available for it).  As far as I can
tell, its just an enumeration with no fancy filtering features but perhaps
that's not true...

-Dominic


James.Strachan wrote:
> 
> On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
>> This is a bit bizarre now...
>>
>> I duplicated your experiment with the examples jar and sure enough it all
>> worked.
>>
>> So, I looked at my jar and the only significant difference I could see
>> was
>> that I didn't have a META-INF/spring/camel-context.xml in it.  So, I put
>> one
>> in (copied from the example that worked) and it started working.
>>
>> So,  do I need to have camel-context.xml in the jar (and if so, does it
>> have
>> to be in a spring subdirectory of META-INF)?
> 
> Definitely not. Basically all the discover-by-package code does is use
> the classloaders to get the Package and iterate through them looking
> for RouteBuilder.
> 
> The only use of a META-INF/spring/camel-context.xml is if you're using
> Spring-OSGi - or you're using the camel:run maven plugin...
> http://activemq.apache.org/camel/camel-maven-plugin.html
> 
> 
> 
>> Now, the really bizarre bit is that I took the camel-context.xml out
>> again
>> (to prove it really was the thing that mattered) and it still worked!
>>
>> So, I now have a jar which contains a RouteBuilder and the RouteBuilder
>> is
>> loaded and configured as it should be.  I just don't understand why.
>> Perhaps ActiveMQ is caching something that's letting it work
>> subsequently..
>>
>> I'd really like to get to the bottom of this - mainly so that this
>> discussion thread can contain the solution for anyone else that
>> encounters
>> it..
> 
> Whoah thats really bizarre!
> 
> I'm at a bit of a loss to understand this. Just to double check I
> understand whats going on - you're just using a binary ActiveMQ 5.x
> distro - and popping your jar in activemq/lib and having this grief
> right? And you're running ActiveMQ using bin/activemq? (or java -jar
> run.jar).
> 
> Both are the same - and run this class...
> https://svn.apache.org/repos/asf/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java
> 
> which doesn't seem to have any kinda wacky code in it that I can see -
> it just basically adds the URLs of all the files it finds to the
> ClassLoader.
> 
> I wonder if rather than using the bin/activemq or run.jar, using some
> kinda shell script to set the classpath works?
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12145052
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by James Strachan <ja...@gmail.com>.
On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
> This is a bit bizarre now...
>
> I duplicated your experiment with the examples jar and sure enough it all
> worked.
>
> So, I looked at my jar and the only significant difference I could see was
> that I didn't have a META-INF/spring/camel-context.xml in it.  So, I put one
> in (copied from the example that worked) and it started working.
>
> So,  do I need to have camel-context.xml in the jar (and if so, does it have
> to be in a spring subdirectory of META-INF)?

Definitely not. Basically all the discover-by-package code does is use
the classloaders to get the Package and iterate through them looking
for RouteBuilder.

The only use of a META-INF/spring/camel-context.xml is if you're using
Spring-OSGi - or you're using the camel:run maven plugin...
http://activemq.apache.org/camel/camel-maven-plugin.html



> Now, the really bizarre bit is that I took the camel-context.xml out again
> (to prove it really was the thing that mattered) and it still worked!
>
> So, I now have a jar which contains a RouteBuilder and the RouteBuilder is
> loaded and configured as it should be.  I just don't understand why.
> Perhaps ActiveMQ is caching something that's letting it work subsequently..
>
> I'd really like to get to the bottom of this - mainly so that this
> discussion thread can contain the solution for anyone else that encounters
> it..

Whoah thats really bizarre!

I'm at a bit of a loss to understand this. Just to double check I
understand whats going on - you're just using a binary ActiveMQ 5.x
distro - and popping your jar in activemq/lib and having this grief
right? And you're running ActiveMQ using bin/activemq? (or java -jar
run.jar).

Both are the same - and run this class...
https://svn.apache.org/repos/asf/activemq/trunk/activemq-console/src/main/java/org/apache/activemq/console/Main.java

which doesn't seem to have any kinda wacky code in it that I can see -
it just basically adds the URLs of all the files it finds to the
ClassLoader.

I wonder if rather than using the bin/activemq or run.jar, using some
kinda shell script to set the classpath works?
-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration - Progress!

Posted by DominicTulley <do...@telelogic.com>.
This is a bit bizarre now...

I duplicated your experiment with the examples jar and sure enough it all
worked.

So, I looked at my jar and the only significant difference I could see was
that I didn't have a META-INF/spring/camel-context.xml in it.  So, I put one
in (copied from the example that worked) and it started working.

So,  do I need to have camel-context.xml in the jar (and if so, does it have
to be in a spring subdirectory of META-INF)?

Now, the really bizarre bit is that I took the camel-context.xml out again
(to prove it really was the thing that mattered) and it still worked!

So, I now have a jar which contains a RouteBuilder and the RouteBuilder is
loaded and configured as it should be.  I just don't understand why. 
Perhaps ActiveMQ is caching something that's letting it work subsequently..

I'd really like to get to the bottom of this - mainly so that this
discussion thread can contain the solution for anyone else that encounters
it..

Thanks,

-Dominic


James.Strachan wrote:
> 
> On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
>> This is also the problem I am now facing (I started another thread on it,
>> but
>> this one is also good).
>>
>> I have debugged through the point where the loading appears to occur
>> (org.apache.camel.util.ResolverUtil) and the class loader is not
>> returning a
>> URL to the jarfile that contains my builder (in fact the call to the
>> class
>> loader returns an empty Enumeration of URLs irrespective of what package
>> name is provided - and the package name IS being passed incorrectly to
>> this
>> method).   For instance, even if I provide a package of "org", the
>> classloader returns an empty enumeration.  This suggests to me there is
>> an
>> issue with the state of the classpath at the point when this is running
>> (no
>> doubt ActiveMQ and Spring do their own terribly clever things during
>> this).
>>
>> If I run a simple test case of the code (copy and paste bits of the code
>> and
>> run it in eclipse) then it works just fine.  It's definitely something to
>> do
>> with when it's running within ActiveMQ.
>>
>> I'm wondering if dynamic loading of RouteBuilders has ever been observed
>> to
>> work in ActiveMQ (do I stand a chance of making it work?) or is this a
>> significant issue that will need investigating and resolving?
> 
> It should work! :)
> 
> So I just did a test to check this really does work. Here's what I did.
> 
> * copied the camel-example-spring.jar into the activemq/lib directory
> (in the binary distro of 5.x).
> * editied the conf/activemq.xml to look like this...
> 
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring">
>      <package>org.apache.camel.example</package>
>   </camelContext>
> 
> Then I started ActiveMQ and it just worked (I saw the queue
> "test.MyQueue" in the web console - then when I sent a message via the
> web console the camel processing log message appeared in the console).
> 
> I wonder - if the change you hit is the change from the "packages"
> attribute in camel 1.0 to the 0-many <package> elements in Camel 1.1?
> 
> I've just added a little warning to the 1.1 download page in case thats
> it...
> http://cwiki.apache.org/CAMEL/camel-110-release.html
> 
> also I've patched the activemq.xml in trunk with comments to show the
> new syntax etc.
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12144599
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 8/14/07, DominicTulley <do...@telelogic.com> wrote:
> This is also the problem I am now facing (I started another thread on it, but
> this one is also good).
>
> I have debugged through the point where the loading appears to occur
> (org.apache.camel.util.ResolverUtil) and the class loader is not returning a
> URL to the jarfile that contains my builder (in fact the call to the class
> loader returns an empty Enumeration of URLs irrespective of what package
> name is provided - and the package name IS being passed incorrectly to this
> method).   For instance, even if I provide a package of "org", the
> classloader returns an empty enumeration.  This suggests to me there is an
> issue with the state of the classpath at the point when this is running (no
> doubt ActiveMQ and Spring do their own terribly clever things during this).
>
> If I run a simple test case of the code (copy and paste bits of the code and
> run it in eclipse) then it works just fine.  It's definitely something to do
> with when it's running within ActiveMQ.
>
> I'm wondering if dynamic loading of RouteBuilders has ever been observed to
> work in ActiveMQ (do I stand a chance of making it work?) or is this a
> significant issue that will need investigating and resolving?

It should work! :)

So I just did a test to check this really does work. Here's what I did.

* copied the camel-example-spring.jar into the activemq/lib directory
(in the binary distro of 5.x).
* editied the conf/activemq.xml to look like this...

  <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
     <package>org.apache.camel.example</package>
  </camelContext>

Then I started ActiveMQ and it just worked (I saw the queue
"test.MyQueue" in the web console - then when I sent a message via the
web console the camel processing log message appeared in the console).

I wonder - if the change you hit is the change from the "packages"
attribute in camel 1.0 to the 0-many <package> elements in Camel 1.1?

I've just added a little warning to the 1.1 download page in case thats it...
http://cwiki.apache.org/CAMEL/camel-110-release.html

also I've patched the activemq.xml in trunk with comments to show the
new syntax etc.

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration

Posted by DominicTulley <do...@telelogic.com>.
This is also the problem I am now facing (I started another thread on it, but
this one is also good).

I have debugged through the point where the loading appears to occur
(org.apache.camel.util.ResolverUtil) and the class loader is not returning a
URL to the jarfile that contains my builder (in fact the call to the class
loader returns an empty Enumeration of URLs irrespective of what package
name is provided - and the package name IS being passed incorrectly to this
method).   For instance, even if I provide a package of "org", the
classloader returns an empty enumeration.  This suggests to me there is an
issue with the state of the classpath at the point when this is running (no
doubt ActiveMQ and Spring do their own terribly clever things during this).

If I run a simple test case of the code (copy and paste bits of the code and
run it in eclipse) then it works just fine.  It's definitely something to do
with when it's running within ActiveMQ.

I'm wondering if dynamic loading of RouteBuilders has ever been observed to
work in ActiveMQ (do I stand a chance of making it work?) or is this a
significant issue that will need investigating and resolving?

Thanks,

-Dominic


On 7/27/07, veton <ve...@belgacom.be> wrote:
> a) Is there a specific path where to put this libraries? (classpath
> definition is not that clear with ActiveMQ)

If you drop your jar in the lib/ directory it should work. We should
be recursively finding all jars inside the lib directory - but I"ve
seen that not quite work in the past so am not sure its true...


-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a12141298
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 7/27/07, veton <ve...@belgacom.be> wrote:
>
> In my quest to have Camel integrate within Activemq, I'm now able to define
> route via xml spring

Yay!

> but not able to load my RouteBuilder defined in Java.

Damn! Did you tell Camel the package(s) to search for your RouteBuilder?

Using trunk of camel, you add a <package> element inside the <camelContext>

Using 1.0 of Camel you add a packages="" attribute.


> a) Is there a specific path where to put this libraries? (classpath
> definition is not that clear with ActiveMQ)

If you drop your jar in the lib/ directory it should work. We should
be recursively finding all jars inside the lib directory - but I"ve
seen that not quite work in the past so am not sure its true...


> b) Is there a way to see in the logs what routes have been loaded (no clue
> reading the source code, no "trace-enter/exit") or in the future .... a  JMX
> interface ;-D)  ?

We're working on JMX :)

Using the web console shows what JMS destinations are being consumed.
Another option is to turn on debug logging :)

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration

Posted by veton <ve...@belgacom.be>.
In my quest to have Camel integrate within Activemq, I'm now able to define
route via xml spring but not able to load my RouteBuilder defined in Java.
a) Is there a specific path where to put this libraries? (classpath
definition is not that clear with ActiveMQ)
b) Is there a way to see in the logs what routes have been loaded (no clue
reading the source code, no "trace-enter/exit") or in the future .... a  JMX
interface ;-D)  ?

Thanks,
Veton.

James.Strachan wrote:
> 
> On 7/26/07, veton <ve...@belgacom.be> wrote:
>>
>> Thanks James,
>> Problem solved. I needed the latest snapshot of ActiveMQ5. Previous
>> versions
>> did not have camel included.
>> I can play now! :-)
> 
> Great! :)
> 
> BTW I added to Camel trunk the ability to create CameDestination
> objects, using Camel URIs which work just like normal JMS destinations
> - so can be used with the regular ActiveMQ JMS client to interact with
> Camel's EIP routes.
> 
> e.g.
> 
> // JMS client code
> Destination dest = new CamelDestination("xmpp://host:port/room");
> MessageProducer producer = session.createProducer(dest);
> producer.send(session.createTextMessage("<hello>world!</hello>"));
> 
> To avoid maven cyclic dependencies, we should probably move this
> Camel-ActiveMQ integration into the ActiveMQ trunk soon...
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a11827680
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 7/26/07, veton <ve...@belgacom.be> wrote:
>
> Thanks James,
> Problem solved. I needed the latest snapshot of ActiveMQ5. Previous versions
> did not have camel included.
> I can play now! :-)

Great! :)

BTW I added to Camel trunk the ability to create CameDestination
objects, using Camel URIs which work just like normal JMS destinations
- so can be used with the regular ActiveMQ JMS client to interact with
Camel's EIP routes.

e.g.

// JMS client code
Destination dest = new CamelDestination("xmpp://host:port/room");
MessageProducer producer = session.createProducer(dest);
producer.send(session.createTextMessage("<hello>world!</hello>"));

To avoid maven cyclic dependencies, we should probably move this
Camel-ActiveMQ integration into the ActiveMQ trunk soon...

-- 
James
-------
http://macstrac.blogspot.com/

Re: CAMEL and ActiveMQ5 - Integration

Posted by veton <ve...@belgacom.be>.
Thanks James,
Problem solved. I needed the latest snapshot of ActiveMQ5. Previous versions
did not have camel included.
I can play now! :-)
Veton.


James.Strachan wrote:
> 
> On 7/25/07, veton <ve...@belgacom.be> wrote:
>> I like the idea of having CAMEL integrated out of the box in ActiveMQ5.
> 
> Great! :)
> 
>> But
>> it does not seem straightforward :-[.
>> The problem I have are related to Spring :-(
>> Using Camel 1.0, Spring is not able to recognize the namespace
>> "http://activemq.apache.org/camel/schema/spring"
> 
> If you boot up the broker from the binary distro (via the 'activemq'
> script), it should have a sample Camel route configured doesn't it? It
> certainly works for me at least. Am wondering if its some kind of
> classpath issue you've got?
> 
> 
>> Using camel 1.1 snapshot, I 've got error of this type:
>> java.lang.NoSuchMethodError:
>> org.springframework.beans.factory.xml.ParserContext.registerComponent(Lorg/springframework/beans/factory/parsing/ComponentDefinition;)V
>>         at
>> org.apache.camel.spring.xml.CamelNamespaceHandler$1.doParse(CamelNamespaceHandler.java:88)
> 
> That looks like a Spring version issue - I think you'll need 2.0.5 or
> later of Spring.
> 
> Incidentally, 1.1 of Camel uses JAXB2 to do the parsing of the XML, so
> you may need this dependency on your classpath as well if you're using
> Java 5.
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/CAMEL-and-ActiveMQ5---Integration-tf4140859s22882.html#a11808601
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: CAMEL and ActiveMQ5 - Integration

Posted by James Strachan <ja...@gmail.com>.
On 7/25/07, veton <ve...@belgacom.be> wrote:
> I like the idea of having CAMEL integrated out of the box in ActiveMQ5.

Great! :)

> But
> it does not seem straightforward :-[.
> The problem I have are related to Spring :-(
> Using Camel 1.0, Spring is not able to recognize the namespace
> "http://activemq.apache.org/camel/schema/spring"

If you boot up the broker from the binary distro (via the 'activemq'
script), it should have a sample Camel route configured doesn't it? It
certainly works for me at least. Am wondering if its some kind of
classpath issue you've got?


> Using camel 1.1 snapshot, I 've got error of this type:
> java.lang.NoSuchMethodError:
> org.springframework.beans.factory.xml.ParserContext.registerComponent(Lorg/springframework/beans/factory/parsing/ComponentDefinition;)V
>         at
> org.apache.camel.spring.xml.CamelNamespaceHandler$1.doParse(CamelNamespaceHandler.java:88)

That looks like a Spring version issue - I think you'll need 2.0.5 or
later of Spring.

Incidentally, 1.1 of Camel uses JAXB2 to do the parsing of the XML, so
you may need this dependency on your classpath as well if you're using
Java 5.

-- 
James
-------
http://macstrac.blogspot.com/