You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Illtud Daniel <il...@llgc.org.uk> on 2010/10/04 21:32:19 UTC

where to put java classes/jars for bean invocation via camel?

I hope you don't mind me posting this to the activemq, rather than
camel, but I'm using the camel that comes with activemq, so the
answer I'm looking for is activemq-specific.

Where should I be putting my (eg) HelloWorld.class so that I can
invoke the code via a bean, declared in camel.xml:

          <bean id="hello" class="HelloWorld"/>

?

I realise this is probably an easy question, and the documentation
(+ Manning books) is very good, but does presuppose that you
understand something of Java, which is where I fall down. I've tried
activemq/lib, but it doesn't find it there.

Be kind...

-- 
Illtud Daniel                                 illtud.daniel@llgc.org.uk
Prif Swyddog Technegol                          Chief Technical Officer
Llyfrgell Genedlaethol Cymru                  National Library of Wales

Re: where to put java classes/jars for bean invocation via camel?

Posted by Illtud Daniel <il...@llgc.org.uk>.
Illtud Daniel wrote:

> $ cd /usr/local/activemq/lib
> $ mkdir -p uk/org/llgc/testing
> $ cp /tmp/HelloWorld.class uk/org/llgc/testing

OK, my friendly java programmer tells me you can't put class
files in lib directories, you have to package them as jars, and
that does indeed appear to work.

-- 
Illtud Daniel                                 illtud.daniel@llgc.org.uk
Prif Swyddog Technegol                          Chief Technical Officer
Llyfrgell Genedlaethol Cymru                  National Library of Wales

Re: where to put java classes/jars for bean invocation via camel?

Posted by Illtud Daniel <il...@llgc.org.uk>.
Hi Timothy,

> try it this way:
>
>     <bean id="hello" class="uk.org.llgc.testing.HelloWorld"/>

Makes sense to me! However:

2010-10-04 21:46:36,751 | WARN  | Nested in 
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot 
find class [uk.org.llgc.testing.HelloWorld] for bean with name 'hello' 
defined in URL [file:/usr/local/activemq/conf/camel.xml]; nested 
exception is java.lang.ClassNotFoundException: 
uk.org.llgc.testing.HelloWorld: | org.eclipse.jetty.util.log | main

:(

-- 
Illtud Daniel                                 illtud.daniel@llgc.org.uk
Prif Swyddog Technegol                          Chief Technical Officer
Llyfrgell Genedlaethol Cymru                  National Library of Wales

Re: where to put java classes/jars for bean invocation via camel?

Posted by Timothy Bish <ta...@gmail.com>.
On Mon, 2010-10-04 at 21:20 +0100, Illtud Daniel wrote:
> Stan, thank you very much for the prompt reply
> 
> On 04/10/10 20:38, Stan Lewis wrote:
> > activemq's lib directory is the right place for it, make sure you
> > either put the class in a directory hierarchy that matches the class's
> > package name or build it into a Jar file.
> 
> Ah, see, now you have already found the bounds of my java
> knowlege (told you it didn't go very far...).
> 
> Here's what I have:
> 
> $ cd /tmp
> $ cat HelloWorld.java
> package uk.org.llgc.testing;
> 
> public class HelloWorld {
> 
>      public String hello(String name) {
>          return "Hello " + name;
>      }
> }
> $ javac HelloWorld.java
> $ cd /usr/local/activemq/lib
> $ mkdir -p uk/org/llgc/testing
> $ cp /tmp/HelloWorld.class uk/org/llgc/testing
> 
> I have that one line defining the bean in camel.xml:
> 
>          <bean id="hello" class="HelloWorld"/>
> 
> 
> ...there must be some other reference to the package that needs
> making somewhere, right?
> 

try it this way:  

   <bean id="hello" class="uk.org.llgc.testing.HelloWorld"/>

Regards

-- 
Tim Bish

Open Source Integration: http://fusesource.com

Follow me on Twitter: http://twitter.com/tabish121
My Blog: http://timbish.blogspot.com/


Re: where to put java classes/jars for bean invocation via camel?

Posted by Illtud Daniel <il...@llgc.org.uk>.
Stan, thank you very much for the prompt reply

On 04/10/10 20:38, Stan Lewis wrote:
> activemq's lib directory is the right place for it, make sure you
> either put the class in a directory hierarchy that matches the class's
> package name or build it into a Jar file.

Ah, see, now you have already found the bounds of my java
knowlege (told you it didn't go very far...).

Here's what I have:

$ cd /tmp
$ cat HelloWorld.java
package uk.org.llgc.testing;

public class HelloWorld {

     public String hello(String name) {
         return "Hello " + name;
     }
}
$ javac HelloWorld.java
$ cd /usr/local/activemq/lib
$ mkdir -p uk/org/llgc/testing
$ cp /tmp/HelloWorld.class uk/org/llgc/testing

I have that one line defining the bean in camel.xml:

         <bean id="hello" class="HelloWorld"/>


...there must be some other reference to the package that needs
making somewhere, right?

-- 
Illtud Daniel                                 illtud.daniel@llgc.org.uk
Prif Swyddog Technegol                          Chief Technical Officer
Llyfrgell Genedlaethol Cymru                  National Library of Wales

Re: where to put java classes/jars for bean invocation via camel?

Posted by Stan Lewis <sl...@fusesource.com>.
activemq's lib directory is the right place for it, make sure you
either put the class in a directory hierarchy that matches the class's
package name or build it into a Jar file.

On Mon, Oct 4, 2010 at 3:32 PM, Illtud Daniel <il...@llgc.org.uk> wrote:
> I hope you don't mind me posting this to the activemq, rather than
> camel, but I'm using the camel that comes with activemq, so the
> answer I'm looking for is activemq-specific.
>
> Where should I be putting my (eg) HelloWorld.class so that I can
> invoke the code via a bean, declared in camel.xml:
>
>         <bean id="hello" class="HelloWorld"/>
>
> ?
>
> I realise this is probably an easy question, and the documentation
> (+ Manning books) is very good, but does presuppose that you
> understand something of Java, which is where I fall down. I've tried
> activemq/lib, but it doesn't find it there.
>
> Be kind...
>
> --
> Illtud Daniel                                 illtud.daniel@llgc.org.uk
> Prif Swyddog Technegol                          Chief Technical Officer
> Llyfrgell Genedlaethol Cymru                  National Library of Wales
>