You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Joe San <co...@gmail.com> on 2012/08/16 14:32:39 UTC

Re: JAXB Data Format

I have decided to use JAXB instead of xStream. My route definition looks
like this:

        final JaxbDataFormat jaxb = new
JaxbDataFormat("com.example.filexml");
        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("file://my.xml").unmarshal(jaxb).bean(new
ProcessorBean()).to("file://my.xml");
            }
        });

How do I get hold of the UnMarshalled Java Object (say Person.java) in my
ProcessorBean. Also, when I use a bean for Processing, how does Camel know
which method to invoke in that bean?

Regards,
Jothi

On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com> wrote:

> Guys,
>
> I have a route which is defined as below:
>
> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> ProcessorBean()).to("file://my.xml");
>
> All I want to do is access the my.xml in my ProcessorBean. Where and how
> do I specify the Java object which will be filled with the values in the
> xml file?
>
> Regards,
> Jothi
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 16, 2012 at 2:32 PM, Joe San <co...@gmail.com> wrote:
> I have decided to use JAXB instead of xStream. My route definition looks
> like this:
>
>         final JaxbDataFormat jaxb = new
> JaxbDataFormat("com.example.filexml");
>         context.addRoutes(new RouteBuilder() {
>             public void configure() {
>                 from("file://my.xml").unmarshal(jaxb).bean(new
> ProcessorBean()).to("file://my.xml");
>             }
>         });
>
> How do I get hold of the UnMarshalled Java Object (say Person.java) in my
> ProcessorBean. Also, when I use a bean for Processing, how does Camel know
> which method to invoke in that bean?
>

If you use the Camel Processor, then you get it from the Exchange, eg
the input message. On the message body.
http://camel.apache.org/processor.html

For invoking pojos (beans) instead, then read through the Camel docs
about bean component / bean parameter binding / etc.
http://camel.apache.org/bean-binding.html

If you have a copy of Camel in Action book, then chapter 3 and 4 is a
great source for all this kind of stuff. And explained in much detail.



> Regards,
> Jothi
>
> On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com> wrote:
>
>> Guys,
>>
>> I have a route which is defined as below:
>>
>> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> ProcessorBean()).to("file://my.xml");
>>
>> All I want to do is access the my.xml in my ProcessorBean. Where and how
>> do I specify the Java object which will be filled with the values in the
>> xml file?
>>
>> Regards,
>> Jothi
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Wondering how you had the patience to go through this entire mail thread
that helped you resolve your issue.

The Camel Riders are awesome!

Regards,
Jothi

On Wed, Sep 5, 2012 at 2:32 PM, Naveen Raj <na...@gmail.com> wrote:

> Thanks,
>
> This helped me with the same issue i faced.
>
> thanks,
> Naveen Raj Balasubramaniam
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Re-JAXB-Data-Format-tp5717522p5718669.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: JAXB Data Format

Posted by Naveen Raj <na...@gmail.com>.
Thanks,

This helped me with the same issue i faced.

thanks,
Naveen Raj Balasubramaniam 



--
View this message in context: http://camel.465427.n5.nabble.com/Re-JAXB-Data-Format-tp5717522p5718669.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Finally, I got this working. I had my folders in the same location where my
java source files were located and I gave it a relative path. But now I
moved them to a seperate folder and gave an absolute path which seemed to
work.

from("file://C:/folders/inbox").to("file://C:/folders/outbox");

Regards,
Jothi

On Fri, Aug 24, 2012 at 10:33 AM, Joe San <co...@gmail.com> wrote:

> Thanks Claus.
>
> I have the following lines being shown in the console.
>
> [                          main] DefaultCamelContext            INFO
> Route: route1 started and consuming from: Endpoint[file://.?fileName=my.xml]
> [                          main] DefaultCamelContext            INFO
> Total 1 routes, of which 1 is started.
> [                          main] DefaultCamelContext            INFO
> Apache Camel 2.10.0 (CamelContext: camel-1) started in 0.641 seconds
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.015 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.016 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.015 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.016 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.016 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.015 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
> [(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
> 0.000 seconds to poll: .
>
> I can see that the route is started as well. But why wouldn't the output
> file be written be written? Also why does it poll those many times as above?
>
> Here is how my route looks like:
>
> from("file:.?fileName=my.xml").to("file:.?fileName=my1.xml")
>
> Regards,
> Jothi
>

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Thanks Claus.

I have the following lines being shown in the console.

[                          main] DefaultCamelContext            INFO
Route: route1 started and consuming from: Endpoint[file://.?fileName=my.xml]
[                          main] DefaultCamelContext            INFO  Total
1 routes, of which 1 is started.
[                          main] DefaultCamelContext            INFO
Apache Camel 2.10.0 (CamelContext: camel-1) started in 0.641 seconds
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.015 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.016 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.015 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.016 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.016 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.015 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .
[(camel-1) thread #1 - file://.] FileConsumer                   DEBUG Took
0.000 seconds to poll: .

I can see that the route is started as well. But why wouldn't the output
file be written be written? Also why does it poll those many times as above?

Here is how my route looks like:

from("file:.?fileName=my.xml").to("file:.?fileName=my1.xml")

Regards,
Jothi

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Aug 19, 2012 at 6:29 PM, Joe San <co...@gmail.com> wrote:
> Adding the Tracer seems to have no effect on the logging.
>
> log4j:WARN No appenders could be found for logger
> (org.apache.camel.impl.DefaultCamelContext).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
> more info.
>
> I see the above in my log. I don't think this is a good sign. Do I have to
> configure log4j.properties myself?
>

Yes you need to configure log4j. Add a log4j.properties file in the
src/main/resources directory.
You can copy a file from one of the Camel examples and use that file
as a base line.

For example this file will log to the console only
https://svn.apache.org/repos/asf/camel/trunk/examples/camel-example-console/src/main/resources/log4j.properties

If you want to log to a file then you would need to use a file
appender in the log4j configuration. For example from a log4j file in
one of the Camel components we use when testing the component
https://svn.apache.org/repos/asf/camel/trunk/components/camel-beanio/src/test/resources/log4j.properties


Also try remove the fileName option, then Camel should pickup any file
you drop in that directory.


> This is how I added the Tracer to my route's configure method. (Just
> followed what was said in the Tracer documentation)
>
>             context.addRoutes(new RouteBuilder() {
>                 @Override
>                 public void configure() throws Exception {
>                     Tracer tracer = new Tracer();
>                     tracer.setTraceOutExchanges(true);
>
>                     // we configure the default trace formatter where we can
>                     // specify which fields we want in the output
>                     DefaultTraceFormatter formatter = new
> DefaultTraceFormatter();
>                     formatter.setShowOutBody(true);
>                     formatter.setShowOutBodyType(true);
>
>                     // set to use our formatter
>                     tracer.setFormatter(formatter);
>
>                     context.addInterceptStrategy(tracer);
>
>
> from("file://Users/jothi/Desktop/inbox?fileName=person.xml").to("file://Users/jothi/Desktop/outbox");
>                 }
>             });
>
> Regards,
> Jothi
>
> On Sun, Aug 19, 2012 at 6:19 PM, Joe San <co...@gmail.com> wrote:
>
>> Just wanted to mention that in the example given in the following page,
>> the formatter should be a tracer I guess??
>>
>> http://camel.apache.org/tracer
>>
>>     public void configure() throws Exception {
>>         // add tracer as an interceptor so it will log the exchange executions at runtime        // this can aid us to understand/see how the exchanges is routed etc.        Tracer tracer = new Tracer();
>>         formatter.getDefaultTraceFormatter().setShowBreadCrumb(false);
>>         formatter.getDefaultTraceFormatter().setShowNode(false);
>>         ...
>>         getContext().addInterceptStrategy(tracer);
>>
>>
>> Regards,
>> Jothi
>>
>>
>> On Sun, Aug 19, 2012 at 6:10 PM, Joe San <co...@gmail.com> wrote:
>>
>>> That was a typo in my email but in my original route I have them
>>> correctly configured. Like you mentioned I already tried breaking up the
>>> route to just pick it from Inbox and write it to the Outbox. Surprisingly,
>>> it seems like the file is never picked up.
>>>
>>>
>>> from("file://Users/jothi/Desktop/inbox?fileName=my.xml").to("file://Users/jothi/Desktop/outbox");
>>>
>>> Will have to use the Tracer to see what's happening. Thanks for pointing
>>> the Tracer.
>>>
>>> Well, actually this simple example is just doing good to my learning by
>>> not producing the desired result for such a simple of the simplest example
>>> in Camel. I'm enjoying it!
>>>
>>> Regards,
>>> Jothi
>>>
>>>
>>> On Sun, Aug 19, 2012 at 1:09 PM, Claus Ibsen <cl...@gmail.com>wrote:
>>>
>>>> On Sun, Aug 19, 2012 at 12:14 PM, Joe San <co...@gmail.com>
>>>> wrote:
>>>> > What is wondering me is that I do not see any exception at all.
>>>> > Thread.sleep(10000) sleeps for 10 seconds and I think that is ample
>>>> time to
>>>> > copy a simple 4 line xml to the outbox. Is there a way that I could
>>>> debug a
>>>> > bit here to understand what is happening behind the scenes?
>>>> >
>>>>
>>>> It does not copy to the outbox directory. You have configured the
>>>> route to write the file to the same input file.
>>>> If you want to write to a different directory.
>>>>
>>>> Then this
>>>> to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>>>>
>>>> Should possible be changed to
>>>> to("file://Users/jothi/Desktop/outbox/filename=my.xml");
>>>>
>>>> And you dont have to specify file name as Camel can reuse the input name
>>>>
>>>> to("file://Users/jothi/Desktop/outbox");
>>>>
>>>> Also you have a typo in the option. Its fileName, with a capital N.
>>>>
>>>> See the options names here
>>>> http://camel.apache.org/file2
>>>>
>>>> They must be spelled in the right case.
>>>>
>>>> > Regards,
>>>> > Jothi
>>>> >
>>>> > On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com>
>>>> wrote:
>>>> >
>>>> >> After being unsuccessful at my effort to make the above route to
>>>> work, I
>>>> >> created the necessary inbox and outbox folders and my new route looks
>>>> like
>>>> >> below:
>>>> >>
>>>> >>
>>>> >>
>>>> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
>>>> >>
>>>> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>>>> >>
>>>> >> Why does this not work either? What else should I tell Camel so that
>>>> he
>>>> >> writes the my.xml to the outbox?
>>>> >>
>>>> >> Regards,
>>>> >> Jothi
>>>> >>
>>>> >>
>>>> >> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com>
>>>> wrote:
>>>> >>
>>>> >>> Thanks for the pointer. I made the necessary changes to my route but
>>>> >>> still unable to make it work!
>>>> >>>
>>>> >>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
>>>> >>> ProcessorBean()).to("file:.?fileName=my1.xml");
>>>> >>>
>>>> >>> For convenient sake, I changed the name of the target file
>>>> (my1.xml). Why
>>>> >>> would my ProcessorBean not invoked? Also how can I see that my.xml
>>>> was
>>>> >>> picked up by Camel in the from clause?
>>>> >>>
>>>> >>> Regards,
>>>> >>> Jothi
>>>> >>>
>>>> >>>
>>>> >>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <claus.ibsen@gmail.com
>>>> >wrote:
>>>> >>>
>>>> >>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>>>> >>>> wrote:
>>>> >>>> > Thanks! That solved the problem.
>>>> >>>> >
>>>> >>>> > Now I'm able to successfully get my example running. But I'm not
>>>> >>>> getting
>>>> >>>> > Camel do what I wanted. Here is how my route definition looks
>>>> like!
>>>> >>>> >
>>>> >>>> >                 context.addRoutes(new RouteBuilder() {
>>>> >>>> >                     public void configure() {
>>>> >>>> >
>>>> from("file:my.xml").unmarshal(jaxb).bean(new
>>>> >>>> > ProcessorBean()).to("file:my.xml");
>>>> >>>> >                     }
>>>> >>>> >                 });
>>>> >>>> >
>>>> >>>> > The my.xml is in the same folder where the class containing the
>>>> above
>>>> >>>> route
>>>> >>>> > definition exists. What I'm trying to do is to read the xml,
>>>> change the
>>>> >>>> > value for the name attribute using a processor and write the new
>>>> xml
>>>> >>>> to the
>>>> >>>> > same file.
>>>> >>>> >
>>>> >>>>
>>>> >>>> The file component in Camel
>>>> >>>> http://camel.apache.org/file2
>>>> >>>>
>>>> >>>> Requires to be configured with a *starting directory*. If you want
>>>> to
>>>> >>>> pickup a single file by its name, you need to use the fileName
>>>> option
>>>> >>>> for that
>>>> >>>>
>>>> >>>> from("file:startingDir?fileName=my.xml")...
>>>> >>>>
>>>> >>>> You may use dot as starting directory to say current dir (a bit odd
>>>> >>>> though)
>>>> >>>> from("file:.?fileName=my.xml")...
>>>> >>>>
>>>> >>>>
>>>> >>>> > Regards,
>>>> >>>> > Jothi
>>>> >>>> >
>>>> >>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <
>>>> claus.ibsen@gmail.com>
>>>> >>>> wrote:
>>>> >>>> >
>>>> >>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <
>>>> codeintheopen@gmail.com>
>>>> >>>> wrote:
>>>> >>>> >> > So here comes the next bump!
>>>> >>>> >> >
>>>> >>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt
>>>> contain
>>>> >>>> >> > ObjectFactory.class or jaxb.index
>>>> >>>> >> >
>>>> >>>> >> > Do I have to add a jaxb.index file to my package?
>>>> >>>> >> >
>>>> >>>> >>
>>>> >>>> >> Yes, see for example p77 in Camel in Action book.
>>>> >>>> >> Or google a bit on how to use JAXB with Java.
>>>> >>>> >>
>>>> >>>> >> Basically you need to drop a jaxb.index file in the JAR with
>>>> your JAXB
>>>> >>>> >> annotated classes.
>>>> >>>> >> The file should contain a line per class that has JAXB
>>>> annotations.
>>>> >>>> >>
>>>> >>>> >>
>>>> >>>> >>
>>>> >>>> >> > Regards,
>>>> >>>> >> > Jothi
>>>> >>>> >> >
>>>> >>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <
>>>> codeintheopen@gmail.com>
>>>> >>>> >> wrote:
>>>> >>>> >> >
>>>> >>>> >> >> Just managed to get rid of this issue and I was about to post
>>>> my
>>>> >>>> >> solution
>>>> >>>> >> >> and saw your message. Added the following as a dependency and
>>>> it
>>>> >>>> worked!
>>>> >>>> >> >>
>>>> >>>> >> >>     <dependency>
>>>> >>>> >> >>         <groupId>org.slf4j</groupId>
>>>> >>>> >> >>         <artifactId>slf4j-api</artifactId>
>>>> >>>> >> >>         <version>1.6.6</version>
>>>> >>>> >> >>     </dependency>
>>>> >>>> >> >>
>>>> >>>> >> >> Regards,
>>>> >>>> >> >> Jothi
>>>> >>>> >> >>
>>>> >>>> >> >>
>>>> >>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>>>> >>>> claus.ibsen@gmail.com
>>>> >>>> >> >wrote:
>>>> >>>> >> >>
>>>> >>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <
>>>> >>>> codeintheopen@gmail.com>
>>>> >>>> >> >>> wrote:
>>>> >>>> >> >>> > I've tried to get rid of this issue but unfortunately
>>>> could not.
>>>> >>>> >> What I
>>>> >>>> >> >>> do
>>>> >>>> >> >>> > not understand is the following:
>>>> >>>> >> >>> >
>>>> >>>> >> >>> > The Error says:
>>>> >>>> >> >>> >
>>>> >>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>>> >>>> >> >>> > org/slf4j/LoggerFactory
>>>> >>>> >> >>> >     at
>>>> >>>> >> >>> >
>>>> >>>> >>
>>>> >>>>
>>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>>> >>>> >> >>> >     at
>>>> >>>> >> >>> >
>>>> >>>> >> >>>
>>>> >>>> >>
>>>> >>>>
>>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>>> >>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>>>> >>>> org.slf4j.LoggerFactory
>>>> >>>> >> >>> >
>>>> >>>> >> >>> > I have a dependency as:
>>>> >>>> >> >>> >
>>>> >>>> >> >>> >     <dependency>
>>>> >>>> >> >>> >         <groupId>org.slf4j</groupId>
>>>> >>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>>>> >>>> >> >>> >         <version>1.6.6</version>
>>>> >>>> >> >>> >     </dependency>
>>>> >>>> >> >>> >
>>>> >>>> >> >>> > When I checked the slf4j jar file, the package structure is
>>>> >>>> different
>>>> >>>> >> >>> from
>>>> >>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory
>>>> but
>>>> >>>> rather
>>>> >>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong
>>>> libraries?
>>>> >>>> >> >>> >
>>>> >>>> >> >>>
>>>> >>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>>>> >>>> >> >>>
>>>> >>>> >> >>> > Regards,
>>>> >>>> >> >>> > Jothi
>>>> >>>> >> >>> >
>>>> >>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>>>> >>>> claus.ibsen@gmail.com>
>>>> >>>> >> >>> wrote:
>>>> >>>> >> >>> >
>>>> >>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>>>> >>>> codeintheopen@gmail.com>
>>>> >>>> >> >>> wrote:
>>>> >>>> >> >>> >> > Even with the al4j-log4j dependecy added in the
>>>> libraries, I
>>>> >>>> get
>>>> >>>> >> this
>>>> >>>> >> >>> >> error.
>>>> >>>> >> >>> >> >
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >> Are you sure they are on the classpath when you run the
>>>> app
>>>> >>>> form
>>>> >>>> >> within
>>>> >>>> >> >>> >> Eclipse.
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >> And you may want to add slf4j-log4j12 or some other
>>>> logging
>>>> >>>> bridge
>>>> >>>> >> so
>>>> >>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>>>> >>>> >> >>> >> Then you can see logs in the console in eclipse etc, if
>>>> you
>>>> >>>> >> configure
>>>> >>>> >> >>> >> logging to output to std out.
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >> If you create a new Camel project using the maven
>>>> archetypes
>>>> >>>> it does
>>>> >>>> >> >>> that.
>>>> >>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >> Or see some of the Camel examples in the examples dir
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >> > Regards,
>>>> >>>> >> >>> >> > Jothi
>>>> >>>> >> >>> >> >
>>>> >>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>>>> >>>> >> claus.ibsen@gmail.com>
>>>> >>>> >> >>> >> wrote:
>>>> >>>> >> >>> >> >
>>>> >>>> >> >>> >> >> Hi
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >> See this FAQ
>>>> >>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>>>> >>>> >> codeintheopen@gmail.com>
>>>> >>>> >> >>> >> wrote:
>>>> >>>> >> >>> >> >> > Exception in thread "main"
>>>> java.lang.NoClassDefFoundError:
>>>> >>>> >> >>> >> >> > org/slf4j/LoggerFactory
>>>> >>>> >> >>> >> >> >     at
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >>
>>>> >>>> >> >>>
>>>> >>>> >>
>>>> >>>>
>>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>>> >>>> >> >>> >> >> >     at
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >>
>>>> >>>> >> >>>
>>>> >>>> >>
>>>> >>>>
>>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>>> >>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>>>> >>>> >> >>> org.slf4j.LoggerFactory
>>>> >>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>>>> >>>> >> >>> >> >> >     at
>>>> java.security.AccessController.doPrivileged(Native
>>>> >>>> >> Method)
>>>> >>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown
>>>> Source)
>>>> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown
>>>> Source)
>>>> >>>> >> >>> >> >> >     at
>>>> sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>>>> >>>> >> Source)
>>>> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown
>>>> Source)
>>>> >>>> >> >>> >> >> >     ... 2 more
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >> >> > My simple route fails with the above exception. All I
>>>> >>>> have in
>>>> >>>> >> my
>>>> >>>> >> >>> >> pom.xml
>>>> >>>> >> >>> >> >> > defined is:
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >> >> >     <dependency>
>>>> >>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>>>> >>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>>>> >>>> >> >>> >> >> >         <version>2.9.2</version>
>>>> >>>> >> >>> >> >> >     </dependency>
>>>> >>>> >> >>> >> >> >     <dependency>
>>>> >>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>>>> >>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>>>> >>>> >> >>> >> >> >       <version>2.9.2</version>
>>>> >>>> >> >>> >> >> >     </dependency>
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >> >> > Do I need additional dependencies to be added other
>>>> than
>>>> >>>> this?
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >> >> > Regards,
>>>> >>>> >> >>> >> >> > Jothi
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>>>> >>>> >> codeintheopen@gmail.com
>>>> >>>> >> >>> >
>>>> >>>> >> >>> >> >> wrote:
>>>> >>>> >> >>> >> >> >
>>>> >>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>>>> >>>> expected
>>>> >>>> >> this
>>>> >>>> >> >>> hint
>>>> >>>> >> >>> >> >> that
>>>> >>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>>>> >>>> >> >>> automagically
>>>> >>>> >> >>> >> >> without
>>>> >>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3
>>>> itself.
>>>> >>>> >> >>> >> >> >>
>>>> >>>> >> >>> >> >> >> Regards,
>>>> >>>> >> >>> >> >> >> Jothi
>>>> >>>> >> >>> >> >> >>
>>>> >>>> >> >>> >> >> >>
>>>> >>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>>>> >>>> >> >>> claus.ibsen@gmail.com
>>>> >>>> >> >>> >> >> >wrote:
>>>> >>>> >> >>> >> >> >>
>>>> >>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>>>> >>>> >> >>> codeintheopen@gmail.com>
>>>> >>>> >> >>> >> >> wrote:
>>>> >>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My
>>>> actual
>>>> >>>> >> >>> question
>>>> >>>> >> >>> >> got
>>>> >>>> >> >>> >> >> >>> > clarified once I had a look into the
>>>> documentation.
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>> >> >> >>> > From the Camel in Action book:
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>>>> >>>> >> >>> >> >> >>> > .to("
>>>> >>>> http://riders.com/orders/cmd=received&date=yesterday
>>>> >>>> >> ")
>>>> >>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>>
>>>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>> >> >> >>> > How does Camel know which method in the
>>>> >>>> OrderToCsvBean()
>>>> >>>> >> >>> class to
>>>> >>>> >> >>> >> >> >>> invoke.
>>>> >>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>>>> >>>> Chapter 3.
>>>> >>>> >> >>> Not
>>>> >>>> >> >>> >> sure
>>>> >>>> >> >>> >> >> if
>>>> >>>> >> >>> >> >> >>> it
>>>> >>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start
>>>> with
>>>> >>>> Chapter
>>>> >>>> >> 4.
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with
>>>> >>>> Camel; see
>>>> >>>> >> for
>>>> >>>> >> >>> >> >> >>> example page 105.
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then
>>>> Camel
>>>> >>>> knows
>>>> >>>> >> >>> that
>>>> >>>> >> >>> >> it
>>>> >>>> >> >>> >> >> >>> should invoke that method.
>>>> >>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more
>>>> complicated.
>>>> >>>> You
>>>> >>>> >> can
>>>> >>>> >> >>> of
>>>> >>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well
>>>> you
>>>> >>>> can
>>>> >>>> >> find
>>>> >>>> >> >>> >> pieces
>>>> >>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>> > Regards,
>>>> >>>> >> >>> >> >> >>> > Jothi
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>>> >>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>>>> >>>> >> >>> >> >> >>> >
>>>> >>>> >> >>> >> >> >>> >> Check the documentation for this:
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>> >> Babak
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>>>> >>>> >> >>> >> codeintheopen@gmail.com
>>>> >>>> >> >>> >> >> >:
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream.
>>>> My
>>>> >>>> route
>>>> >>>> >> >>> >> definition
>>>> >>>> >> >>> >> >> >>> looks
>>>> >>>> >> >>> >> >> >>> >> >like this:
>>>> >>>> >> >>> >> >> >>> >> >
>>>> >>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>>>> >>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>>>> >>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>>>> >>>> >> >>> >> >> >>> >> >            public void configure() {
>>>> >>>> >> >>> >> >> >>> >> >
>>>> >>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>>>> >>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>>>> >>>> >> >>> >> >> >>> >> >            }
>>>> >>>> >> >>> >> >> >>> >> >        });
>>>> >>>> >> >>> >> >> >>> >> >
>>>> >>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java
>>>> Object
>>>> >>>> (say
>>>> >>>> >> >>> >> Person.java)
>>>> >>>> >> >>> >> >> >>> in my
>>>> >>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>>>> >>>> Processing,
>>>> >>>> >> how
>>>> >>>> >> >>> does
>>>> >>>> >> >>> >> >> Camel
>>>> >>>> >> >>> >> >> >>> know
>>>> >>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>>>> >>>> >> >>> >> >> >>> >> >
>>>> >>>> >> >>> >> >> >>> >> >Regards,
>>>> >>>> >> >>> >> >> >>> >> >Jothi
>>>> >>>> >> >>> >> >> >>> >> >
>>>> >>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>>>> >>>> >> >>> >> codeintheopen@gmail.com>
>>>> >>>> >> >>> >> >> >>> wrote:
>>>> >>>> >> >>> >> >> >>> >> >
>>>> >>>> >> >>> >> >> >>> >> >> Guys,
>>>> >>>> >> >>> >> >> >>> >> >>
>>>> >>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>>>> >>>> >> >>> >> >> >>> >> >>
>>>> >>>> >> >>> >> >> >>> >> >>
>>>> >>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>>> >>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>>>> >>>> >> >>> >> >> >>> >> >>
>>>> >>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>>>> >>>> >> ProcessorBean.
>>>> >>>> >> >>> >> Where
>>>> >>>> >> >>> >> >> >>> and how
>>>> >>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be
>>>> filled
>>>> >>>> with
>>>> >>>> >> the
>>>> >>>> >> >>> >> values
>>>> >>>> >> >>> >> >> >>> in the
>>>> >>>> >> >>> >> >> >>> >> >> xml file?
>>>> >>>> >> >>> >> >> >>> >> >>
>>>> >>>> >> >>> >> >> >>> >> >> Regards,
>>>> >>>> >> >>> >> >> >>> >> >> Jothi
>>>> >>>> >> >>> >> >> >>> >> >>
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>> >>
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>> --
>>>> >>>> >> >>> >> >> >>> Claus Ibsen
>>>> >>>> >> >>> >> >> >>> -----------------
>>>> >>>> >> >>> >> >> >>> FuseSource
>>>> >>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>>>> >>>> >> >>> >> >> >>> Web: http://fusesource.com
>>>> >>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>>>> >>>> >> >>> >> >> >>> Blog: http://davsclaus.com
>>>> >>>> >> >>> >> >> >>> Author of Camel in Action:
>>>> http://www.manning.com/ibsen
>>>> >>>> >> >>> >> >> >>>
>>>> >>>> >> >>> >> >> >>
>>>> >>>> >> >>> >> >> >>
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >> >> --
>>>> >>>> >> >>> >> >> Claus Ibsen
>>>> >>>> >> >>> >> >> -----------------
>>>> >>>> >> >>> >> >> FuseSource
>>>> >>>> >> >>> >> >> Email: cibsen@fusesource.com
>>>> >>>> >> >>> >> >> Web: http://fusesource.com
>>>> >>>> >> >>> >> >> Twitter: davsclaus, fusenews
>>>> >>>> >> >>> >> >> Blog: http://davsclaus.com
>>>> >>>> >> >>> >> >> Author of Camel in Action:
>>>> http://www.manning.com/ibsen
>>>> >>>> >> >>> >> >>
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >>
>>>> >>>> >> >>> >> --
>>>> >>>> >> >>> >> Claus Ibsen
>>>> >>>> >> >>> >> -----------------
>>>> >>>> >> >>> >> FuseSource
>>>> >>>> >> >>> >> Email: cibsen@fusesource.com
>>>> >>>> >> >>> >> Web: http://fusesource.com
>>>> >>>> >> >>> >> Twitter: davsclaus, fusenews
>>>> >>>> >> >>> >> Blog: http://davsclaus.com
>>>> >>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >>>> >> >>> >>
>>>> >>>> >> >>>
>>>> >>>> >> >>>
>>>> >>>> >> >>>
>>>> >>>> >> >>> --
>>>> >>>> >> >>> Claus Ibsen
>>>> >>>> >> >>> -----------------
>>>> >>>> >> >>> FuseSource
>>>> >>>> >> >>> Email: cibsen@fusesource.com
>>>> >>>> >> >>> Web: http://fusesource.com
>>>> >>>> >> >>> Twitter: davsclaus, fusenews
>>>> >>>> >> >>> Blog: http://davsclaus.com
>>>> >>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >>>> >> >>>
>>>> >>>> >> >>
>>>> >>>> >> >>
>>>> >>>> >>
>>>> >>>> >>
>>>> >>>> >>
>>>> >>>> >> --
>>>> >>>> >> Claus Ibsen
>>>> >>>> >> -----------------
>>>> >>>> >> FuseSource
>>>> >>>> >> Email: cibsen@fusesource.com
>>>> >>>> >> Web: http://fusesource.com
>>>> >>>> >> Twitter: davsclaus, fusenews
>>>> >>>> >> Blog: http://davsclaus.com
>>>> >>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >>>> >>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>> --
>>>> >>>> Claus Ibsen
>>>> >>>> -----------------
>>>> >>>> FuseSource
>>>> >>>> Email: cibsen@fusesource.com
>>>> >>>> Web: http://fusesource.com
>>>> >>>> Twitter: davsclaus, fusenews
>>>> >>>> Blog: http://davsclaus.com
>>>> >>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >>>>
>>>> >>>
>>>> >>>
>>>> >>
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> -----------------
>>>> FuseSource
>>>> Email: cibsen@fusesource.com
>>>> Web: http://fusesource.com
>>>> Twitter: davsclaus, fusenews
>>>> Blog: http://davsclaus.com
>>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>>
>>>
>>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Adding the Tracer seems to have no effect on the logging.

log4j:WARN No appenders could be found for logger
(org.apache.camel.impl.DefaultCamelContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.

I see the above in my log. I don't think this is a good sign. Do I have to
configure log4j.properties myself?

This is how I added the Tracer to my route's configure method. (Just
followed what was said in the Tracer documentation)

            context.addRoutes(new RouteBuilder() {
                @Override
                public void configure() throws Exception {
                    Tracer tracer = new Tracer();
                    tracer.setTraceOutExchanges(true);

                    // we configure the default trace formatter where we can
                    // specify which fields we want in the output
                    DefaultTraceFormatter formatter = new
DefaultTraceFormatter();
                    formatter.setShowOutBody(true);
                    formatter.setShowOutBodyType(true);

                    // set to use our formatter
                    tracer.setFormatter(formatter);

                    context.addInterceptStrategy(tracer);


from("file://Users/jothi/Desktop/inbox?fileName=person.xml").to("file://Users/jothi/Desktop/outbox");
                }
            });

Regards,
Jothi

On Sun, Aug 19, 2012 at 6:19 PM, Joe San <co...@gmail.com> wrote:

> Just wanted to mention that in the example given in the following page,
> the formatter should be a tracer I guess??
>
> http://camel.apache.org/tracer
>
>     public void configure() throws Exception {
>         // add tracer as an interceptor so it will log the exchange executions at runtime        // this can aid us to understand/see how the exchanges is routed etc.        Tracer tracer = new Tracer();
>         formatter.getDefaultTraceFormatter().setShowBreadCrumb(false);
>         formatter.getDefaultTraceFormatter().setShowNode(false);
>         ...
>         getContext().addInterceptStrategy(tracer);
>
>
> Regards,
> Jothi
>
>
> On Sun, Aug 19, 2012 at 6:10 PM, Joe San <co...@gmail.com> wrote:
>
>> That was a typo in my email but in my original route I have them
>> correctly configured. Like you mentioned I already tried breaking up the
>> route to just pick it from Inbox and write it to the Outbox. Surprisingly,
>> it seems like the file is never picked up.
>>
>>
>> from("file://Users/jothi/Desktop/inbox?fileName=my.xml").to("file://Users/jothi/Desktop/outbox");
>>
>> Will have to use the Tracer to see what's happening. Thanks for pointing
>> the Tracer.
>>
>> Well, actually this simple example is just doing good to my learning by
>> not producing the desired result for such a simple of the simplest example
>> in Camel. I'm enjoying it!
>>
>> Regards,
>> Jothi
>>
>>
>> On Sun, Aug 19, 2012 at 1:09 PM, Claus Ibsen <cl...@gmail.com>wrote:
>>
>>> On Sun, Aug 19, 2012 at 12:14 PM, Joe San <co...@gmail.com>
>>> wrote:
>>> > What is wondering me is that I do not see any exception at all.
>>> > Thread.sleep(10000) sleeps for 10 seconds and I think that is ample
>>> time to
>>> > copy a simple 4 line xml to the outbox. Is there a way that I could
>>> debug a
>>> > bit here to understand what is happening behind the scenes?
>>> >
>>>
>>> It does not copy to the outbox directory. You have configured the
>>> route to write the file to the same input file.
>>> If you want to write to a different directory.
>>>
>>> Then this
>>> to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>>>
>>> Should possible be changed to
>>> to("file://Users/jothi/Desktop/outbox/filename=my.xml");
>>>
>>> And you dont have to specify file name as Camel can reuse the input name
>>>
>>> to("file://Users/jothi/Desktop/outbox");
>>>
>>> Also you have a typo in the option. Its fileName, with a capital N.
>>>
>>> See the options names here
>>> http://camel.apache.org/file2
>>>
>>> They must be spelled in the right case.
>>>
>>> > Regards,
>>> > Jothi
>>> >
>>> > On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com>
>>> wrote:
>>> >
>>> >> After being unsuccessful at my effort to make the above route to
>>> work, I
>>> >> created the necessary inbox and outbox folders and my new route looks
>>> like
>>> >> below:
>>> >>
>>> >>
>>> >>
>>> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
>>> >>
>>> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>>> >>
>>> >> Why does this not work either? What else should I tell Camel so that
>>> he
>>> >> writes the my.xml to the outbox?
>>> >>
>>> >> Regards,
>>> >> Jothi
>>> >>
>>> >>
>>> >> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com>
>>> wrote:
>>> >>
>>> >>> Thanks for the pointer. I made the necessary changes to my route but
>>> >>> still unable to make it work!
>>> >>>
>>> >>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
>>> >>> ProcessorBean()).to("file:.?fileName=my1.xml");
>>> >>>
>>> >>> For convenient sake, I changed the name of the target file
>>> (my1.xml). Why
>>> >>> would my ProcessorBean not invoked? Also how can I see that my.xml
>>> was
>>> >>> picked up by Camel in the from clause?
>>> >>>
>>> >>> Regards,
>>> >>> Jothi
>>> >>>
>>> >>>
>>> >>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <claus.ibsen@gmail.com
>>> >wrote:
>>> >>>
>>> >>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>>> >>>> wrote:
>>> >>>> > Thanks! That solved the problem.
>>> >>>> >
>>> >>>> > Now I'm able to successfully get my example running. But I'm not
>>> >>>> getting
>>> >>>> > Camel do what I wanted. Here is how my route definition looks
>>> like!
>>> >>>> >
>>> >>>> >                 context.addRoutes(new RouteBuilder() {
>>> >>>> >                     public void configure() {
>>> >>>> >
>>> from("file:my.xml").unmarshal(jaxb).bean(new
>>> >>>> > ProcessorBean()).to("file:my.xml");
>>> >>>> >                     }
>>> >>>> >                 });
>>> >>>> >
>>> >>>> > The my.xml is in the same folder where the class containing the
>>> above
>>> >>>> route
>>> >>>> > definition exists. What I'm trying to do is to read the xml,
>>> change the
>>> >>>> > value for the name attribute using a processor and write the new
>>> xml
>>> >>>> to the
>>> >>>> > same file.
>>> >>>> >
>>> >>>>
>>> >>>> The file component in Camel
>>> >>>> http://camel.apache.org/file2
>>> >>>>
>>> >>>> Requires to be configured with a *starting directory*. If you want
>>> to
>>> >>>> pickup a single file by its name, you need to use the fileName
>>> option
>>> >>>> for that
>>> >>>>
>>> >>>> from("file:startingDir?fileName=my.xml")...
>>> >>>>
>>> >>>> You may use dot as starting directory to say current dir (a bit odd
>>> >>>> though)
>>> >>>> from("file:.?fileName=my.xml")...
>>> >>>>
>>> >>>>
>>> >>>> > Regards,
>>> >>>> > Jothi
>>> >>>> >
>>> >>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <
>>> claus.ibsen@gmail.com>
>>> >>>> wrote:
>>> >>>> >
>>> >>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <
>>> codeintheopen@gmail.com>
>>> >>>> wrote:
>>> >>>> >> > So here comes the next bump!
>>> >>>> >> >
>>> >>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt
>>> contain
>>> >>>> >> > ObjectFactory.class or jaxb.index
>>> >>>> >> >
>>> >>>> >> > Do I have to add a jaxb.index file to my package?
>>> >>>> >> >
>>> >>>> >>
>>> >>>> >> Yes, see for example p77 in Camel in Action book.
>>> >>>> >> Or google a bit on how to use JAXB with Java.
>>> >>>> >>
>>> >>>> >> Basically you need to drop a jaxb.index file in the JAR with
>>> your JAXB
>>> >>>> >> annotated classes.
>>> >>>> >> The file should contain a line per class that has JAXB
>>> annotations.
>>> >>>> >>
>>> >>>> >>
>>> >>>> >>
>>> >>>> >> > Regards,
>>> >>>> >> > Jothi
>>> >>>> >> >
>>> >>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <
>>> codeintheopen@gmail.com>
>>> >>>> >> wrote:
>>> >>>> >> >
>>> >>>> >> >> Just managed to get rid of this issue and I was about to post
>>> my
>>> >>>> >> solution
>>> >>>> >> >> and saw your message. Added the following as a dependency and
>>> it
>>> >>>> worked!
>>> >>>> >> >>
>>> >>>> >> >>     <dependency>
>>> >>>> >> >>         <groupId>org.slf4j</groupId>
>>> >>>> >> >>         <artifactId>slf4j-api</artifactId>
>>> >>>> >> >>         <version>1.6.6</version>
>>> >>>> >> >>     </dependency>
>>> >>>> >> >>
>>> >>>> >> >> Regards,
>>> >>>> >> >> Jothi
>>> >>>> >> >>
>>> >>>> >> >>
>>> >>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>>> >>>> claus.ibsen@gmail.com
>>> >>>> >> >wrote:
>>> >>>> >> >>
>>> >>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <
>>> >>>> codeintheopen@gmail.com>
>>> >>>> >> >>> wrote:
>>> >>>> >> >>> > I've tried to get rid of this issue but unfortunately
>>> could not.
>>> >>>> >> What I
>>> >>>> >> >>> do
>>> >>>> >> >>> > not understand is the following:
>>> >>>> >> >>> >
>>> >>>> >> >>> > The Error says:
>>> >>>> >> >>> >
>>> >>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> >>>> >> >>> > org/slf4j/LoggerFactory
>>> >>>> >> >>> >     at
>>> >>>> >> >>> >
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >>>> >> >>> >     at
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>>> >>>> org.slf4j.LoggerFactory
>>> >>>> >> >>> >
>>> >>>> >> >>> > I have a dependency as:
>>> >>>> >> >>> >
>>> >>>> >> >>> >     <dependency>
>>> >>>> >> >>> >         <groupId>org.slf4j</groupId>
>>> >>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>>> >>>> >> >>> >         <version>1.6.6</version>
>>> >>>> >> >>> >     </dependency>
>>> >>>> >> >>> >
>>> >>>> >> >>> > When I checked the slf4j jar file, the package structure is
>>> >>>> different
>>> >>>> >> >>> from
>>> >>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory
>>> but
>>> >>>> rather
>>> >>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong
>>> libraries?
>>> >>>> >> >>> >
>>> >>>> >> >>>
>>> >>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>>> >>>> >> >>>
>>> >>>> >> >>> > Regards,
>>> >>>> >> >>> > Jothi
>>> >>>> >> >>> >
>>> >>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>>> >>>> claus.ibsen@gmail.com>
>>> >>>> >> >>> wrote:
>>> >>>> >> >>> >
>>> >>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>>> >>>> codeintheopen@gmail.com>
>>> >>>> >> >>> wrote:
>>> >>>> >> >>> >> > Even with the al4j-log4j dependecy added in the
>>> libraries, I
>>> >>>> get
>>> >>>> >> this
>>> >>>> >> >>> >> error.
>>> >>>> >> >>> >> >
>>> >>>> >> >>> >>
>>> >>>> >> >>> >> Are you sure they are on the classpath when you run the
>>> app
>>> >>>> form
>>> >>>> >> within
>>> >>>> >> >>> >> Eclipse.
>>> >>>> >> >>> >>
>>> >>>> >> >>> >> And you may want to add slf4j-log4j12 or some other
>>> logging
>>> >>>> bridge
>>> >>>> >> so
>>> >>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>>> >>>> >> >>> >> Then you can see logs in the console in eclipse etc, if
>>> you
>>> >>>> >> configure
>>> >>>> >> >>> >> logging to output to std out.
>>> >>>> >> >>> >>
>>> >>>> >> >>> >> If you create a new Camel project using the maven
>>> archetypes
>>> >>>> it does
>>> >>>> >> >>> that.
>>> >>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>>> >>>> >> >>> >>
>>> >>>> >> >>> >> Or see some of the Camel examples in the examples dir
>>> >>>> >> >>> >>
>>> >>>> >> >>> >>
>>> >>>> >> >>> >>
>>> >>>> >> >>> >> > Regards,
>>> >>>> >> >>> >> > Jothi
>>> >>>> >> >>> >> >
>>> >>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>>> >>>> >> claus.ibsen@gmail.com>
>>> >>>> >> >>> >> wrote:
>>> >>>> >> >>> >> >
>>> >>>> >> >>> >> >> Hi
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >> See this FAQ
>>> >>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>>> >>>> >> codeintheopen@gmail.com>
>>> >>>> >> >>> >> wrote:
>>> >>>> >> >>> >> >> > Exception in thread "main"
>>> java.lang.NoClassDefFoundError:
>>> >>>> >> >>> >> >> > org/slf4j/LoggerFactory
>>> >>>> >> >>> >> >> >     at
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >>
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >>>> >> >>> >> >> >     at
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >>
>>> >>>> >> >>>
>>> >>>> >>
>>> >>>>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>>> >>>> >> >>> org.slf4j.LoggerFactory
>>> >>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>>> >>>> >> >>> >> >> >     at
>>> java.security.AccessController.doPrivileged(Native
>>> >>>> >> Method)
>>> >>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown
>>> Source)
>>> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown
>>> Source)
>>> >>>> >> >>> >> >> >     at
>>> sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>>> >>>> >> Source)
>>> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown
>>> Source)
>>> >>>> >> >>> >> >> >     ... 2 more
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >> >> > My simple route fails with the above exception. All I
>>> >>>> have in
>>> >>>> >> my
>>> >>>> >> >>> >> pom.xml
>>> >>>> >> >>> >> >> > defined is:
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >> >> >     <dependency>
>>> >>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>>> >>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>>> >>>> >> >>> >> >> >         <version>2.9.2</version>
>>> >>>> >> >>> >> >> >     </dependency>
>>> >>>> >> >>> >> >> >     <dependency>
>>> >>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>>> >>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>>> >>>> >> >>> >> >> >       <version>2.9.2</version>
>>> >>>> >> >>> >> >> >     </dependency>
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >> >> > Do I need additional dependencies to be added other
>>> than
>>> >>>> this?
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >> >> > Regards,
>>> >>>> >> >>> >> >> > Jothi
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>>> >>>> >> codeintheopen@gmail.com
>>> >>>> >> >>> >
>>> >>>> >> >>> >> >> wrote:
>>> >>>> >> >>> >> >> >
>>> >>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>>> >>>> expected
>>> >>>> >> this
>>> >>>> >> >>> hint
>>> >>>> >> >>> >> >> that
>>> >>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>>> >>>> >> >>> automagically
>>> >>>> >> >>> >> >> without
>>> >>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3
>>> itself.
>>> >>>> >> >>> >> >> >>
>>> >>>> >> >>> >> >> >> Regards,
>>> >>>> >> >>> >> >> >> Jothi
>>> >>>> >> >>> >> >> >>
>>> >>>> >> >>> >> >> >>
>>> >>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>>> >>>> >> >>> claus.ibsen@gmail.com
>>> >>>> >> >>> >> >> >wrote:
>>> >>>> >> >>> >> >> >>
>>> >>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>>> >>>> >> >>> codeintheopen@gmail.com>
>>> >>>> >> >>> >> >> wrote:
>>> >>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My
>>> actual
>>> >>>> >> >>> question
>>> >>>> >> >>> >> got
>>> >>>> >> >>> >> >> >>> > clarified once I had a look into the
>>> documentation.
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>> >> >> >>> > From the Camel in Action book:
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>>> >>>> >> >>> >> >> >>> > .to("
>>> >>>> http://riders.com/orders/cmd=received&date=yesterday
>>> >>>> >> ")
>>> >>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>>
>>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>> >> >> >>> > How does Camel know which method in the
>>> >>>> OrderToCsvBean()
>>> >>>> >> >>> class to
>>> >>>> >> >>> >> >> >>> invoke.
>>> >>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>>> >>>> Chapter 3.
>>> >>>> >> >>> Not
>>> >>>> >> >>> >> sure
>>> >>>> >> >>> >> >> if
>>> >>>> >> >>> >> >> >>> it
>>> >>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start
>>> with
>>> >>>> Chapter
>>> >>>> >> 4.
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with
>>> >>>> Camel; see
>>> >>>> >> for
>>> >>>> >> >>> >> >> >>> example page 105.
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then
>>> Camel
>>> >>>> knows
>>> >>>> >> >>> that
>>> >>>> >> >>> >> it
>>> >>>> >> >>> >> >> >>> should invoke that method.
>>> >>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more
>>> complicated.
>>> >>>> You
>>> >>>> >> can
>>> >>>> >> >>> of
>>> >>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well
>>> you
>>> >>>> can
>>> >>>> >> find
>>> >>>> >> >>> >> pieces
>>> >>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>> > Regards,
>>> >>>> >> >>> >> >> >>> > Jothi
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>> >>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>>> >>>> >> >>> >> >> >>> >
>>> >>>> >> >>> >> >> >>> >> Check the documentation for this:
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>> >> Babak
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>>> >>>> >> >>> >> codeintheopen@gmail.com
>>> >>>> >> >>> >> >> >:
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream.
>>> My
>>> >>>> route
>>> >>>> >> >>> >> definition
>>> >>>> >> >>> >> >> >>> looks
>>> >>>> >> >>> >> >> >>> >> >like this:
>>> >>>> >> >>> >> >> >>> >> >
>>> >>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>>> >>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>>> >>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>>> >>>> >> >>> >> >> >>> >> >            public void configure() {
>>> >>>> >> >>> >> >> >>> >> >
>>> >>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>>> >>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>>> >>>> >> >>> >> >> >>> >> >            }
>>> >>>> >> >>> >> >> >>> >> >        });
>>> >>>> >> >>> >> >> >>> >> >
>>> >>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java
>>> Object
>>> >>>> (say
>>> >>>> >> >>> >> Person.java)
>>> >>>> >> >>> >> >> >>> in my
>>> >>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>>> >>>> Processing,
>>> >>>> >> how
>>> >>>> >> >>> does
>>> >>>> >> >>> >> >> Camel
>>> >>>> >> >>> >> >> >>> know
>>> >>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>>> >>>> >> >>> >> >> >>> >> >
>>> >>>> >> >>> >> >> >>> >> >Regards,
>>> >>>> >> >>> >> >> >>> >> >Jothi
>>> >>>> >> >>> >> >> >>> >> >
>>> >>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>>> >>>> >> >>> >> codeintheopen@gmail.com>
>>> >>>> >> >>> >> >> >>> wrote:
>>> >>>> >> >>> >> >> >>> >> >
>>> >>>> >> >>> >> >> >>> >> >> Guys,
>>> >>>> >> >>> >> >> >>> >> >>
>>> >>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>>> >>>> >> >>> >> >> >>> >> >>
>>> >>>> >> >>> >> >> >>> >> >>
>>> >>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>> >>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>>> >>>> >> >>> >> >> >>> >> >>
>>> >>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>>> >>>> >> ProcessorBean.
>>> >>>> >> >>> >> Where
>>> >>>> >> >>> >> >> >>> and how
>>> >>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be
>>> filled
>>> >>>> with
>>> >>>> >> the
>>> >>>> >> >>> >> values
>>> >>>> >> >>> >> >> >>> in the
>>> >>>> >> >>> >> >> >>> >> >> xml file?
>>> >>>> >> >>> >> >> >>> >> >>
>>> >>>> >> >>> >> >> >>> >> >> Regards,
>>> >>>> >> >>> >> >> >>> >> >> Jothi
>>> >>>> >> >>> >> >> >>> >> >>
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>> >>
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>> --
>>> >>>> >> >>> >> >> >>> Claus Ibsen
>>> >>>> >> >>> >> >> >>> -----------------
>>> >>>> >> >>> >> >> >>> FuseSource
>>> >>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>>> >>>> >> >>> >> >> >>> Web: http://fusesource.com
>>> >>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>>> >>>> >> >>> >> >> >>> Blog: http://davsclaus.com
>>> >>>> >> >>> >> >> >>> Author of Camel in Action:
>>> http://www.manning.com/ibsen
>>> >>>> >> >>> >> >> >>>
>>> >>>> >> >>> >> >> >>
>>> >>>> >> >>> >> >> >>
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >> >> --
>>> >>>> >> >>> >> >> Claus Ibsen
>>> >>>> >> >>> >> >> -----------------
>>> >>>> >> >>> >> >> FuseSource
>>> >>>> >> >>> >> >> Email: cibsen@fusesource.com
>>> >>>> >> >>> >> >> Web: http://fusesource.com
>>> >>>> >> >>> >> >> Twitter: davsclaus, fusenews
>>> >>>> >> >>> >> >> Blog: http://davsclaus.com
>>> >>>> >> >>> >> >> Author of Camel in Action:
>>> http://www.manning.com/ibsen
>>> >>>> >> >>> >> >>
>>> >>>> >> >>> >>
>>> >>>> >> >>> >>
>>> >>>> >> >>> >>
>>> >>>> >> >>> >> --
>>> >>>> >> >>> >> Claus Ibsen
>>> >>>> >> >>> >> -----------------
>>> >>>> >> >>> >> FuseSource
>>> >>>> >> >>> >> Email: cibsen@fusesource.com
>>> >>>> >> >>> >> Web: http://fusesource.com
>>> >>>> >> >>> >> Twitter: davsclaus, fusenews
>>> >>>> >> >>> >> Blog: http://davsclaus.com
>>> >>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>>> >> >>> >>
>>> >>>> >> >>>
>>> >>>> >> >>>
>>> >>>> >> >>>
>>> >>>> >> >>> --
>>> >>>> >> >>> Claus Ibsen
>>> >>>> >> >>> -----------------
>>> >>>> >> >>> FuseSource
>>> >>>> >> >>> Email: cibsen@fusesource.com
>>> >>>> >> >>> Web: http://fusesource.com
>>> >>>> >> >>> Twitter: davsclaus, fusenews
>>> >>>> >> >>> Blog: http://davsclaus.com
>>> >>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>>> >> >>>
>>> >>>> >> >>
>>> >>>> >> >>
>>> >>>> >>
>>> >>>> >>
>>> >>>> >>
>>> >>>> >> --
>>> >>>> >> Claus Ibsen
>>> >>>> >> -----------------
>>> >>>> >> FuseSource
>>> >>>> >> Email: cibsen@fusesource.com
>>> >>>> >> Web: http://fusesource.com
>>> >>>> >> Twitter: davsclaus, fusenews
>>> >>>> >> Blog: http://davsclaus.com
>>> >>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>>> >>
>>> >>>>
>>> >>>>
>>> >>>>
>>> >>>> --
>>> >>>> Claus Ibsen
>>> >>>> -----------------
>>> >>>> FuseSource
>>> >>>> Email: cibsen@fusesource.com
>>> >>>> Web: http://fusesource.com
>>> >>>> Twitter: davsclaus, fusenews
>>> >>>> Blog: http://davsclaus.com
>>> >>>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>>>
>>> >>>
>>> >>>
>>> >>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: cibsen@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>
>>
>>
>

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Just wanted to mention that in the example given in the following page, the
formatter should be a tracer I guess??

http://camel.apache.org/tracer

    public void configure() throws Exception {
        // add tracer as an interceptor so it will log the exchange
executions at runtime        // this can aid us to understand/see how
the exchanges is routed etc.        Tracer tracer = new Tracer();
        formatter.getDefaultTraceFormatter().setShowBreadCrumb(false);
        formatter.getDefaultTraceFormatter().setShowNode(false);
        ...
        getContext().addInterceptStrategy(tracer);


Regards,
Jothi

On Sun, Aug 19, 2012 at 6:10 PM, Joe San <co...@gmail.com> wrote:

> That was a typo in my email but in my original route I have them correctly
> configured. Like you mentioned I already tried breaking up the route to
> just pick it from Inbox and write it to the Outbox. Surprisingly, it seems
> like the file is never picked up.
>
>
> from("file://Users/jothi/Desktop/inbox?fileName=my.xml").to("file://Users/jothi/Desktop/outbox");
>
> Will have to use the Tracer to see what's happening. Thanks for pointing
> the Tracer.
>
> Well, actually this simple example is just doing good to my learning by
> not producing the desired result for such a simple of the simplest example
> in Camel. I'm enjoying it!
>
> Regards,
> Jothi
>
>
> On Sun, Aug 19, 2012 at 1:09 PM, Claus Ibsen <cl...@gmail.com>wrote:
>
>> On Sun, Aug 19, 2012 at 12:14 PM, Joe San <co...@gmail.com>
>> wrote:
>> > What is wondering me is that I do not see any exception at all.
>> > Thread.sleep(10000) sleeps for 10 seconds and I think that is ample
>> time to
>> > copy a simple 4 line xml to the outbox. Is there a way that I could
>> debug a
>> > bit here to understand what is happening behind the scenes?
>> >
>>
>> It does not copy to the outbox directory. You have configured the
>> route to write the file to the same input file.
>> If you want to write to a different directory.
>>
>> Then this
>> to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>>
>> Should possible be changed to
>> to("file://Users/jothi/Desktop/outbox/filename=my.xml");
>>
>> And you dont have to specify file name as Camel can reuse the input name
>>
>> to("file://Users/jothi/Desktop/outbox");
>>
>> Also you have a typo in the option. Its fileName, with a capital N.
>>
>> See the options names here
>> http://camel.apache.org/file2
>>
>> They must be spelled in the right case.
>>
>> > Regards,
>> > Jothi
>> >
>> > On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com>
>> wrote:
>> >
>> >> After being unsuccessful at my effort to make the above route to work,
>> I
>> >> created the necessary inbox and outbox folders and my new route looks
>> like
>> >> below:
>> >>
>> >>
>> >>
>> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
>> >>
>> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>> >>
>> >> Why does this not work either? What else should I tell Camel so that he
>> >> writes the my.xml to the outbox?
>> >>
>> >> Regards,
>> >> Jothi
>> >>
>> >>
>> >> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com>
>> wrote:
>> >>
>> >>> Thanks for the pointer. I made the necessary changes to my route but
>> >>> still unable to make it work!
>> >>>
>> >>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
>> >>> ProcessorBean()).to("file:.?fileName=my1.xml");
>> >>>
>> >>> For convenient sake, I changed the name of the target file (my1.xml).
>> Why
>> >>> would my ProcessorBean not invoked? Also how can I see that my.xml was
>> >>> picked up by Camel in the from clause?
>> >>>
>> >>> Regards,
>> >>> Jothi
>> >>>
>> >>>
>> >>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <claus.ibsen@gmail.com
>> >wrote:
>> >>>
>> >>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>> >>>> wrote:
>> >>>> > Thanks! That solved the problem.
>> >>>> >
>> >>>> > Now I'm able to successfully get my example running. But I'm not
>> >>>> getting
>> >>>> > Camel do what I wanted. Here is how my route definition looks like!
>> >>>> >
>> >>>> >                 context.addRoutes(new RouteBuilder() {
>> >>>> >                     public void configure() {
>> >>>> >
>> from("file:my.xml").unmarshal(jaxb).bean(new
>> >>>> > ProcessorBean()).to("file:my.xml");
>> >>>> >                     }
>> >>>> >                 });
>> >>>> >
>> >>>> > The my.xml is in the same folder where the class containing the
>> above
>> >>>> route
>> >>>> > definition exists. What I'm trying to do is to read the xml,
>> change the
>> >>>> > value for the name attribute using a processor and write the new
>> xml
>> >>>> to the
>> >>>> > same file.
>> >>>> >
>> >>>>
>> >>>> The file component in Camel
>> >>>> http://camel.apache.org/file2
>> >>>>
>> >>>> Requires to be configured with a *starting directory*. If you want to
>> >>>> pickup a single file by its name, you need to use the fileName option
>> >>>> for that
>> >>>>
>> >>>> from("file:startingDir?fileName=my.xml")...
>> >>>>
>> >>>> You may use dot as starting directory to say current dir (a bit odd
>> >>>> though)
>> >>>> from("file:.?fileName=my.xml")...
>> >>>>
>> >>>>
>> >>>> > Regards,
>> >>>> > Jothi
>> >>>> >
>> >>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <
>> claus.ibsen@gmail.com>
>> >>>> wrote:
>> >>>> >
>> >>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <
>> codeintheopen@gmail.com>
>> >>>> wrote:
>> >>>> >> > So here comes the next bump!
>> >>>> >> >
>> >>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt
>> contain
>> >>>> >> > ObjectFactory.class or jaxb.index
>> >>>> >> >
>> >>>> >> > Do I have to add a jaxb.index file to my package?
>> >>>> >> >
>> >>>> >>
>> >>>> >> Yes, see for example p77 in Camel in Action book.
>> >>>> >> Or google a bit on how to use JAXB with Java.
>> >>>> >>
>> >>>> >> Basically you need to drop a jaxb.index file in the JAR with your
>> JAXB
>> >>>> >> annotated classes.
>> >>>> >> The file should contain a line per class that has JAXB
>> annotations.
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >> > Regards,
>> >>>> >> > Jothi
>> >>>> >> >
>> >>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <
>> codeintheopen@gmail.com>
>> >>>> >> wrote:
>> >>>> >> >
>> >>>> >> >> Just managed to get rid of this issue and I was about to post
>> my
>> >>>> >> solution
>> >>>> >> >> and saw your message. Added the following as a dependency and
>> it
>> >>>> worked!
>> >>>> >> >>
>> >>>> >> >>     <dependency>
>> >>>> >> >>         <groupId>org.slf4j</groupId>
>> >>>> >> >>         <artifactId>slf4j-api</artifactId>
>> >>>> >> >>         <version>1.6.6</version>
>> >>>> >> >>     </dependency>
>> >>>> >> >>
>> >>>> >> >> Regards,
>> >>>> >> >> Jothi
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>> >>>> claus.ibsen@gmail.com
>> >>>> >> >wrote:
>> >>>> >> >>
>> >>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <
>> >>>> codeintheopen@gmail.com>
>> >>>> >> >>> wrote:
>> >>>> >> >>> > I've tried to get rid of this issue but unfortunately could
>> not.
>> >>>> >> What I
>> >>>> >> >>> do
>> >>>> >> >>> > not understand is the following:
>> >>>> >> >>> >
>> >>>> >> >>> > The Error says:
>> >>>> >> >>> >
>> >>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >>>> >> >>> > org/slf4j/LoggerFactory
>> >>>> >> >>> >     at
>> >>>> >> >>> >
>> >>>> >>
>> >>>>
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >>>> >> >>> >     at
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>> >>>> org.slf4j.LoggerFactory
>> >>>> >> >>> >
>> >>>> >> >>> > I have a dependency as:
>> >>>> >> >>> >
>> >>>> >> >>> >     <dependency>
>> >>>> >> >>> >         <groupId>org.slf4j</groupId>
>> >>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>> >>>> >> >>> >         <version>1.6.6</version>
>> >>>> >> >>> >     </dependency>
>> >>>> >> >>> >
>> >>>> >> >>> > When I checked the slf4j jar file, the package structure is
>> >>>> different
>> >>>> >> >>> from
>> >>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
>> >>>> rather
>> >>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong
>> libraries?
>> >>>> >> >>> >
>> >>>> >> >>>
>> >>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>> >>>> >> >>>
>> >>>> >> >>> > Regards,
>> >>>> >> >>> > Jothi
>> >>>> >> >>> >
>> >>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>> >>>> claus.ibsen@gmail.com>
>> >>>> >> >>> wrote:
>> >>>> >> >>> >
>> >>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>> >>>> codeintheopen@gmail.com>
>> >>>> >> >>> wrote:
>> >>>> >> >>> >> > Even with the al4j-log4j dependecy added in the
>> libraries, I
>> >>>> get
>> >>>> >> this
>> >>>> >> >>> >> error.
>> >>>> >> >>> >> >
>> >>>> >> >>> >>
>> >>>> >> >>> >> Are you sure they are on the classpath when you run the app
>> >>>> form
>> >>>> >> within
>> >>>> >> >>> >> Eclipse.
>> >>>> >> >>> >>
>> >>>> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
>> >>>> bridge
>> >>>> >> so
>> >>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>> >>>> >> >>> >> Then you can see logs in the console in eclipse etc, if you
>> >>>> >> configure
>> >>>> >> >>> >> logging to output to std out.
>> >>>> >> >>> >>
>> >>>> >> >>> >> If you create a new Camel project using the maven
>> archetypes
>> >>>> it does
>> >>>> >> >>> that.
>> >>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>> >>>> >> >>> >>
>> >>>> >> >>> >> Or see some of the Camel examples in the examples dir
>> >>>> >> >>> >>
>> >>>> >> >>> >>
>> >>>> >> >>> >>
>> >>>> >> >>> >> > Regards,
>> >>>> >> >>> >> > Jothi
>> >>>> >> >>> >> >
>> >>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>> >>>> >> claus.ibsen@gmail.com>
>> >>>> >> >>> >> wrote:
>> >>>> >> >>> >> >
>> >>>> >> >>> >> >> Hi
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >> See this FAQ
>> >>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>> >>>> >> codeintheopen@gmail.com>
>> >>>> >> >>> >> wrote:
>> >>>> >> >>> >> >> > Exception in thread "main"
>> java.lang.NoClassDefFoundError:
>> >>>> >> >>> >> >> > org/slf4j/LoggerFactory
>> >>>> >> >>> >> >> >     at
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >>
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >>>> >> >>> >> >> >     at
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >>
>> >>>> >> >>>
>> >>>> >>
>> >>>>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>> >>>> >> >>> org.slf4j.LoggerFactory
>> >>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>> >>>> >> >>> >> >> >     at
>> java.security.AccessController.doPrivileged(Native
>> >>>> >> Method)
>> >>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown
>> Source)
>> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >>>> >> >>> >> >> >     at
>> sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>> >>>> >> Source)
>> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >>>> >> >>> >> >> >     ... 2 more
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >> >> > My simple route fails with the above exception. All I
>> >>>> have in
>> >>>> >> my
>> >>>> >> >>> >> pom.xml
>> >>>> >> >>> >> >> > defined is:
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >> >> >     <dependency>
>> >>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>> >>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>> >>>> >> >>> >> >> >         <version>2.9.2</version>
>> >>>> >> >>> >> >> >     </dependency>
>> >>>> >> >>> >> >> >     <dependency>
>> >>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>> >>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>> >>>> >> >>> >> >> >       <version>2.9.2</version>
>> >>>> >> >>> >> >> >     </dependency>
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >> >> > Do I need additional dependencies to be added other
>> than
>> >>>> this?
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >> >> > Regards,
>> >>>> >> >>> >> >> > Jothi
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>> >>>> >> codeintheopen@gmail.com
>> >>>> >> >>> >
>> >>>> >> >>> >> >> wrote:
>> >>>> >> >>> >> >> >
>> >>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>> >>>> expected
>> >>>> >> this
>> >>>> >> >>> hint
>> >>>> >> >>> >> >> that
>> >>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>> >>>> >> >>> automagically
>> >>>> >> >>> >> >> without
>> >>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3
>> itself.
>> >>>> >> >>> >> >> >>
>> >>>> >> >>> >> >> >> Regards,
>> >>>> >> >>> >> >> >> Jothi
>> >>>> >> >>> >> >> >>
>> >>>> >> >>> >> >> >>
>> >>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>> >>>> >> >>> claus.ibsen@gmail.com
>> >>>> >> >>> >> >> >wrote:
>> >>>> >> >>> >> >> >>
>> >>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>> >>>> >> >>> codeintheopen@gmail.com>
>> >>>> >> >>> >> >> wrote:
>> >>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My
>> actual
>> >>>> >> >>> question
>> >>>> >> >>> >> got
>> >>>> >> >>> >> >> >>> > clarified once I had a look into the
>> documentation.
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>> >> >> >>> > From the Camel in Action book:
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>> >>>> >> >>> >> >> >>> > .to("
>> >>>> http://riders.com/orders/cmd=received&date=yesterday
>> >>>> >> ")
>> >>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>>
>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>> >> >> >>> > How does Camel know which method in the
>> >>>> OrderToCsvBean()
>> >>>> >> >>> class to
>> >>>> >> >>> >> >> >>> invoke.
>> >>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>> >>>> Chapter 3.
>> >>>> >> >>> Not
>> >>>> >> >>> >> sure
>> >>>> >> >>> >> >> if
>> >>>> >> >>> >> >> >>> it
>> >>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
>> >>>> Chapter
>> >>>> >> 4.
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with
>> >>>> Camel; see
>> >>>> >> for
>> >>>> >> >>> >> >> >>> example page 105.
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then
>> Camel
>> >>>> knows
>> >>>> >> >>> that
>> >>>> >> >>> >> it
>> >>>> >> >>> >> >> >>> should invoke that method.
>> >>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more
>> complicated.
>> >>>> You
>> >>>> >> can
>> >>>> >> >>> of
>> >>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well
>> you
>> >>>> can
>> >>>> >> find
>> >>>> >> >>> >> pieces
>> >>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>> > Regards,
>> >>>> >> >>> >> >> >>> > Jothi
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> >>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>> >>>> >> >>> >> >> >>> >
>> >>>> >> >>> >> >> >>> >> Check the documentation for this:
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>> >> Babak
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>> >>>> >> >>> >> codeintheopen@gmail.com
>> >>>> >> >>> >> >> >:
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream.
>> My
>> >>>> route
>> >>>> >> >>> >> definition
>> >>>> >> >>> >> >> >>> looks
>> >>>> >> >>> >> >> >>> >> >like this:
>> >>>> >> >>> >> >> >>> >> >
>> >>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>> >>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>> >>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>> >>>> >> >>> >> >> >>> >> >            public void configure() {
>> >>>> >> >>> >> >> >>> >> >
>> >>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>> >>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>> >>>> >> >>> >> >> >>> >> >            }
>> >>>> >> >>> >> >> >>> >> >        });
>> >>>> >> >>> >> >> >>> >> >
>> >>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java
>> Object
>> >>>> (say
>> >>>> >> >>> >> Person.java)
>> >>>> >> >>> >> >> >>> in my
>> >>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>> >>>> Processing,
>> >>>> >> how
>> >>>> >> >>> does
>> >>>> >> >>> >> >> Camel
>> >>>> >> >>> >> >> >>> know
>> >>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>> >>>> >> >>> >> >> >>> >> >
>> >>>> >> >>> >> >> >>> >> >Regards,
>> >>>> >> >>> >> >> >>> >> >Jothi
>> >>>> >> >>> >> >> >>> >> >
>> >>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>> >>>> >> >>> >> codeintheopen@gmail.com>
>> >>>> >> >>> >> >> >>> wrote:
>> >>>> >> >>> >> >> >>> >> >
>> >>>> >> >>> >> >> >>> >> >> Guys,
>> >>>> >> >>> >> >> >>> >> >>
>> >>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>> >>>> >> >>> >> >> >>> >> >>
>> >>>> >> >>> >> >> >>> >> >>
>> >>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>> >>>> >> >>> >> >> >>> >> >>
>> >>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>> >>>> >> ProcessorBean.
>> >>>> >> >>> >> Where
>> >>>> >> >>> >> >> >>> and how
>> >>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be
>> filled
>> >>>> with
>> >>>> >> the
>> >>>> >> >>> >> values
>> >>>> >> >>> >> >> >>> in the
>> >>>> >> >>> >> >> >>> >> >> xml file?
>> >>>> >> >>> >> >> >>> >> >>
>> >>>> >> >>> >> >> >>> >> >> Regards,
>> >>>> >> >>> >> >> >>> >> >> Jothi
>> >>>> >> >>> >> >> >>> >> >>
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>> >>
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>> --
>> >>>> >> >>> >> >> >>> Claus Ibsen
>> >>>> >> >>> >> >> >>> -----------------
>> >>>> >> >>> >> >> >>> FuseSource
>> >>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>> >>>> >> >>> >> >> >>> Web: http://fusesource.com
>> >>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>> >>>> >> >>> >> >> >>> Blog: http://davsclaus.com
>> >>>> >> >>> >> >> >>> Author of Camel in Action:
>> http://www.manning.com/ibsen
>> >>>> >> >>> >> >> >>>
>> >>>> >> >>> >> >> >>
>> >>>> >> >>> >> >> >>
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >>
>> >>>> >> >>> >> >> --
>> >>>> >> >>> >> >> Claus Ibsen
>> >>>> >> >>> >> >> -----------------
>> >>>> >> >>> >> >> FuseSource
>> >>>> >> >>> >> >> Email: cibsen@fusesource.com
>> >>>> >> >>> >> >> Web: http://fusesource.com
>> >>>> >> >>> >> >> Twitter: davsclaus, fusenews
>> >>>> >> >>> >> >> Blog: http://davsclaus.com
>> >>>> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>> >> >>> >> >>
>> >>>> >> >>> >>
>> >>>> >> >>> >>
>> >>>> >> >>> >>
>> >>>> >> >>> >> --
>> >>>> >> >>> >> Claus Ibsen
>> >>>> >> >>> >> -----------------
>> >>>> >> >>> >> FuseSource
>> >>>> >> >>> >> Email: cibsen@fusesource.com
>> >>>> >> >>> >> Web: http://fusesource.com
>> >>>> >> >>> >> Twitter: davsclaus, fusenews
>> >>>> >> >>> >> Blog: http://davsclaus.com
>> >>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>> >> >>> >>
>> >>>> >> >>>
>> >>>> >> >>>
>> >>>> >> >>>
>> >>>> >> >>> --
>> >>>> >> >>> Claus Ibsen
>> >>>> >> >>> -----------------
>> >>>> >> >>> FuseSource
>> >>>> >> >>> Email: cibsen@fusesource.com
>> >>>> >> >>> Web: http://fusesource.com
>> >>>> >> >>> Twitter: davsclaus, fusenews
>> >>>> >> >>> Blog: http://davsclaus.com
>> >>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>> >> >>>
>> >>>> >> >>
>> >>>> >> >>
>> >>>> >>
>> >>>> >>
>> >>>> >>
>> >>>> >> --
>> >>>> >> Claus Ibsen
>> >>>> >> -----------------
>> >>>> >> FuseSource
>> >>>> >> Email: cibsen@fusesource.com
>> >>>> >> Web: http://fusesource.com
>> >>>> >> Twitter: davsclaus, fusenews
>> >>>> >> Blog: http://davsclaus.com
>> >>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>> >>
>> >>>>
>> >>>>
>> >>>>
>> >>>> --
>> >>>> Claus Ibsen
>> >>>> -----------------
>> >>>> FuseSource
>> >>>> Email: cibsen@fusesource.com
>> >>>> Web: http://fusesource.com
>> >>>> Twitter: davsclaus, fusenews
>> >>>> Blog: http://davsclaus.com
>> >>>> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>>
>> >>>
>> >>>
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
That was a typo in my email but in my original route I have them correctly
configured. Like you mentioned I already tried breaking up the route to
just pick it from Inbox and write it to the Outbox. Surprisingly, it seems
like the file is never picked up.


from("file://Users/jothi/Desktop/inbox?fileName=my.xml").to("file://Users/jothi/Desktop/outbox");

Will have to use the Tracer to see what's happening. Thanks for pointing
the Tracer.

Well, actually this simple example is just doing good to my learning by not
producing the desired result for such a simple of the simplest example in
Camel. I'm enjoying it!

Regards,
Jothi

On Sun, Aug 19, 2012 at 1:09 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Sun, Aug 19, 2012 at 12:14 PM, Joe San <co...@gmail.com> wrote:
> > What is wondering me is that I do not see any exception at all.
> > Thread.sleep(10000) sleeps for 10 seconds and I think that is ample time
> to
> > copy a simple 4 line xml to the outbox. Is there a way that I could
> debug a
> > bit here to understand what is happening behind the scenes?
> >
>
> It does not copy to the outbox directory. You have configured the
> route to write the file to the same input file.
> If you want to write to a different directory.
>
> Then this
> to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>
> Should possible be changed to
> to("file://Users/jothi/Desktop/outbox/filename=my.xml");
>
> And you dont have to specify file name as Camel can reuse the input name
>
> to("file://Users/jothi/Desktop/outbox");
>
> Also you have a typo in the option. Its fileName, with a capital N.
>
> See the options names here
> http://camel.apache.org/file2
>
> They must be spelled in the right case.
>
> > Regards,
> > Jothi
> >
> > On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com>
> wrote:
> >
> >> After being unsuccessful at my effort to make the above route to work, I
> >> created the necessary inbox and outbox folders and my new route looks
> like
> >> below:
> >>
> >>
> >>
> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
> >> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
> >>
> >> Why does this not work either? What else should I tell Camel so that he
> >> writes the my.xml to the outbox?
> >>
> >> Regards,
> >> Jothi
> >>
> >>
> >> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com>
> wrote:
> >>
> >>> Thanks for the pointer. I made the necessary changes to my route but
> >>> still unable to make it work!
> >>>
> >>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
> >>> ProcessorBean()).to("file:.?fileName=my1.xml");
> >>>
> >>> For convenient sake, I changed the name of the target file (my1.xml).
> Why
> >>> would my ProcessorBean not invoked? Also how can I see that my.xml was
> >>> picked up by Camel in the from clause?
> >>>
> >>> Regards,
> >>> Jothi
> >>>
> >>>
> >>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <claus.ibsen@gmail.com
> >wrote:
> >>>
> >>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
> >>>> wrote:
> >>>> > Thanks! That solved the problem.
> >>>> >
> >>>> > Now I'm able to successfully get my example running. But I'm not
> >>>> getting
> >>>> > Camel do what I wanted. Here is how my route definition looks like!
> >>>> >
> >>>> >                 context.addRoutes(new RouteBuilder() {
> >>>> >                     public void configure() {
> >>>> >                         from("file:my.xml").unmarshal(jaxb).bean(new
> >>>> > ProcessorBean()).to("file:my.xml");
> >>>> >                     }
> >>>> >                 });
> >>>> >
> >>>> > The my.xml is in the same folder where the class containing the
> above
> >>>> route
> >>>> > definition exists. What I'm trying to do is to read the xml, change
> the
> >>>> > value for the name attribute using a processor and write the new xml
> >>>> to the
> >>>> > same file.
> >>>> >
> >>>>
> >>>> The file component in Camel
> >>>> http://camel.apache.org/file2
> >>>>
> >>>> Requires to be configured with a *starting directory*. If you want to
> >>>> pickup a single file by its name, you need to use the fileName option
> >>>> for that
> >>>>
> >>>> from("file:startingDir?fileName=my.xml")...
> >>>>
> >>>> You may use dot as starting directory to say current dir (a bit odd
> >>>> though)
> >>>> from("file:.?fileName=my.xml")...
> >>>>
> >>>>
> >>>> > Regards,
> >>>> > Jothi
> >>>> >
> >>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <
> claus.ibsen@gmail.com>
> >>>> wrote:
> >>>> >
> >>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <codeintheopen@gmail.com
> >
> >>>> wrote:
> >>>> >> > So here comes the next bump!
> >>>> >> >
> >>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt
> contain
> >>>> >> > ObjectFactory.class or jaxb.index
> >>>> >> >
> >>>> >> > Do I have to add a jaxb.index file to my package?
> >>>> >> >
> >>>> >>
> >>>> >> Yes, see for example p77 in Camel in Action book.
> >>>> >> Or google a bit on how to use JAXB with Java.
> >>>> >>
> >>>> >> Basically you need to drop a jaxb.index file in the JAR with your
> JAXB
> >>>> >> annotated classes.
> >>>> >> The file should contain a line per class that has JAXB annotations.
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> > Regards,
> >>>> >> > Jothi
> >>>> >> >
> >>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <
> codeintheopen@gmail.com>
> >>>> >> wrote:
> >>>> >> >
> >>>> >> >> Just managed to get rid of this issue and I was about to post my
> >>>> >> solution
> >>>> >> >> and saw your message. Added the following as a dependency and it
> >>>> worked!
> >>>> >> >>
> >>>> >> >>     <dependency>
> >>>> >> >>         <groupId>org.slf4j</groupId>
> >>>> >> >>         <artifactId>slf4j-api</artifactId>
> >>>> >> >>         <version>1.6.6</version>
> >>>> >> >>     </dependency>
> >>>> >> >>
> >>>> >> >> Regards,
> >>>> >> >> Jothi
> >>>> >> >>
> >>>> >> >>
> >>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
> >>>> claus.ibsen@gmail.com
> >>>> >> >wrote:
> >>>> >> >>
> >>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <
> >>>> codeintheopen@gmail.com>
> >>>> >> >>> wrote:
> >>>> >> >>> > I've tried to get rid of this issue but unfortunately could
> not.
> >>>> >> What I
> >>>> >> >>> do
> >>>> >> >>> > not understand is the following:
> >>>> >> >>> >
> >>>> >> >>> > The Error says:
> >>>> >> >>> >
> >>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >>>> >> >>> > org/slf4j/LoggerFactory
> >>>> >> >>> >     at
> >>>> >> >>> >
> >>>> >>
> >>>>
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >>>> >> >>> >     at
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >>
> >>>>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
> >>>> org.slf4j.LoggerFactory
> >>>> >> >>> >
> >>>> >> >>> > I have a dependency as:
> >>>> >> >>> >
> >>>> >> >>> >     <dependency>
> >>>> >> >>> >         <groupId>org.slf4j</groupId>
> >>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
> >>>> >> >>> >         <version>1.6.6</version>
> >>>> >> >>> >     </dependency>
> >>>> >> >>> >
> >>>> >> >>> > When I checked the slf4j jar file, the package structure is
> >>>> different
> >>>> >> >>> from
> >>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
> >>>> rather
> >>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong
> libraries?
> >>>> >> >>> >
> >>>> >> >>>
> >>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
> >>>> >> >>>
> >>>> >> >>> > Regards,
> >>>> >> >>> > Jothi
> >>>> >> >>> >
> >>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
> >>>> claus.ibsen@gmail.com>
> >>>> >> >>> wrote:
> >>>> >> >>> >
> >>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
> >>>> codeintheopen@gmail.com>
> >>>> >> >>> wrote:
> >>>> >> >>> >> > Even with the al4j-log4j dependecy added in the
> libraries, I
> >>>> get
> >>>> >> this
> >>>> >> >>> >> error.
> >>>> >> >>> >> >
> >>>> >> >>> >>
> >>>> >> >>> >> Are you sure they are on the classpath when you run the app
> >>>> form
> >>>> >> within
> >>>> >> >>> >> Eclipse.
> >>>> >> >>> >>
> >>>> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
> >>>> bridge
> >>>> >> so
> >>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
> >>>> >> >>> >> Then you can see logs in the console in eclipse etc, if you
> >>>> >> configure
> >>>> >> >>> >> logging to output to std out.
> >>>> >> >>> >>
> >>>> >> >>> >> If you create a new Camel project using the maven archetypes
> >>>> it does
> >>>> >> >>> that.
> >>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
> >>>> >> >>> >>
> >>>> >> >>> >> Or see some of the Camel examples in the examples dir
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> >> >>> >> > Regards,
> >>>> >> >>> >> > Jothi
> >>>> >> >>> >> >
> >>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
> >>>> >> claus.ibsen@gmail.com>
> >>>> >> >>> >> wrote:
> >>>> >> >>> >> >
> >>>> >> >>> >> >> Hi
> >>>> >> >>> >> >>
> >>>> >> >>> >> >> See this FAQ
> >>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
> >>>> >> >>> >> >>
> >>>> >> >>> >> >>
> >>>> >> >>> >> >>
> >>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
> >>>> >> codeintheopen@gmail.com>
> >>>> >> >>> >> wrote:
> >>>> >> >>> >> >> > Exception in thread "main"
> java.lang.NoClassDefFoundError:
> >>>> >> >>> >> >> > org/slf4j/LoggerFactory
> >>>> >> >>> >> >> >     at
> >>>> >> >>> >> >> >
> >>>> >> >>> >>
> >>>> >> >>>
> >>>> >>
> >>>>
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >>>> >> >>> >> >> >     at
> >>>> >> >>> >> >> >
> >>>> >> >>> >>
> >>>> >> >>>
> >>>> >>
> >>>>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
> >>>> >> >>> org.slf4j.LoggerFactory
> >>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
> >>>> >> >>> >> >> >     at
> java.security.AccessController.doPrivileged(Native
> >>>> >> Method)
> >>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown
> Source)
> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >>>> >> >>> >> >> >     at
> sun.misc.Launcher$AppClassLoader.loadClass(Unknown
> >>>> >> Source)
> >>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >>>> >> >>> >> >> >     ... 2 more
> >>>> >> >>> >> >> >
> >>>> >> >>> >> >> > My simple route fails with the above exception. All I
> >>>> have in
> >>>> >> my
> >>>> >> >>> >> pom.xml
> >>>> >> >>> >> >> > defined is:
> >>>> >> >>> >> >> >
> >>>> >> >>> >> >> >     <dependency>
> >>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
> >>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
> >>>> >> >>> >> >> >         <version>2.9.2</version>
> >>>> >> >>> >> >> >     </dependency>
> >>>> >> >>> >> >> >     <dependency>
> >>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
> >>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
> >>>> >> >>> >> >> >       <version>2.9.2</version>
> >>>> >> >>> >> >> >     </dependency>
> >>>> >> >>> >> >> >
> >>>> >> >>> >> >> > Do I need additional dependencies to be added other
> than
> >>>> this?
> >>>> >> >>> >> >> >
> >>>> >> >>> >> >> > Regards,
> >>>> >> >>> >> >> > Jothi
> >>>> >> >>> >> >> >
> >>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
> >>>> >> codeintheopen@gmail.com
> >>>> >> >>> >
> >>>> >> >>> >> >> wrote:
> >>>> >> >>> >> >> >
> >>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
> >>>> expected
> >>>> >> this
> >>>> >> >>> hint
> >>>> >> >>> >> >> that
> >>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
> >>>> >> >>> automagically
> >>>> >> >>> >> >> without
> >>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3
> itself.
> >>>> >> >>> >> >> >>
> >>>> >> >>> >> >> >> Regards,
> >>>> >> >>> >> >> >> Jothi
> >>>> >> >>> >> >> >>
> >>>> >> >>> >> >> >>
> >>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
> >>>> >> >>> claus.ibsen@gmail.com
> >>>> >> >>> >> >> >wrote:
> >>>> >> >>> >> >> >>
> >>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
> >>>> >> >>> codeintheopen@gmail.com>
> >>>> >> >>> >> >> wrote:
> >>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My
> actual
> >>>> >> >>> question
> >>>> >> >>> >> got
> >>>> >> >>> >> >> >>> > clarified once I had a look into the documentation.
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> >> >> >>> > From the Camel in Action book:
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
> >>>> >> >>> >> >> >>> > .to("
> >>>> http://riders.com/orders/cmd=received&date=yesterday
> >>>> >> ")
> >>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> >> >> >>> > How does Camel know which method in the
> >>>> OrderToCsvBean()
> >>>> >> >>> class to
> >>>> >> >>> >> >> >>> invoke.
> >>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
> >>>> Chapter 3.
> >>>> >> >>> Not
> >>>> >> >>> >> sure
> >>>> >> >>> >> >> if
> >>>> >> >>> >> >> >>> it
> >>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
> >>>> Chapter
> >>>> >> 4.
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with
> >>>> Camel; see
> >>>> >> for
> >>>> >> >>> >> >> >>> example page 105.
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then
> Camel
> >>>> knows
> >>>> >> >>> that
> >>>> >> >>> >> it
> >>>> >> >>> >> >> >>> should invoke that method.
> >>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more
> complicated.
> >>>> You
> >>>> >> can
> >>>> >> >>> of
> >>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well you
> >>>> can
> >>>> >> find
> >>>> >> >>> >> pieces
> >>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>> > Regards,
> >>>> >> >>> >> >> >>> > Jothi
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> >>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
> >>>> >> >>> >> >> >>> >
> >>>> >> >>> >> >> >>> >> Check the documentation for this:
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>> >> Babak
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
> >>>> >> >>> >> codeintheopen@gmail.com
> >>>> >> >>> >> >> >:
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My
> >>>> route
> >>>> >> >>> >> definition
> >>>> >> >>> >> >> >>> looks
> >>>> >> >>> >> >> >>> >> >like this:
> >>>> >> >>> >> >> >>> >> >
> >>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
> >>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
> >>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
> >>>> >> >>> >> >> >>> >> >            public void configure() {
> >>>> >> >>> >> >> >>> >> >
> >>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
> >>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
> >>>> >> >>> >> >> >>> >> >            }
> >>>> >> >>> >> >> >>> >> >        });
> >>>> >> >>> >> >> >>> >> >
> >>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object
> >>>> (say
> >>>> >> >>> >> Person.java)
> >>>> >> >>> >> >> >>> in my
> >>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
> >>>> Processing,
> >>>> >> how
> >>>> >> >>> does
> >>>> >> >>> >> >> Camel
> >>>> >> >>> >> >> >>> know
> >>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
> >>>> >> >>> >> >> >>> >> >
> >>>> >> >>> >> >> >>> >> >Regards,
> >>>> >> >>> >> >> >>> >> >Jothi
> >>>> >> >>> >> >> >>> >> >
> >>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
> >>>> >> >>> >> codeintheopen@gmail.com>
> >>>> >> >>> >> >> >>> wrote:
> >>>> >> >>> >> >> >>> >> >
> >>>> >> >>> >> >> >>> >> >> Guys,
> >>>> >> >>> >> >> >>> >> >>
> >>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
> >>>> >> >>> >> >> >>> >> >>
> >>>> >> >>> >> >> >>> >> >>
> >>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
> >>>> >> >>> >> >> >>> >> >>
> >>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
> >>>> >> ProcessorBean.
> >>>> >> >>> >> Where
> >>>> >> >>> >> >> >>> and how
> >>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be
> filled
> >>>> with
> >>>> >> the
> >>>> >> >>> >> values
> >>>> >> >>> >> >> >>> in the
> >>>> >> >>> >> >> >>> >> >> xml file?
> >>>> >> >>> >> >> >>> >> >>
> >>>> >> >>> >> >> >>> >> >> Regards,
> >>>> >> >>> >> >> >>> >> >> Jothi
> >>>> >> >>> >> >> >>> >> >>
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>> >>
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>> --
> >>>> >> >>> >> >> >>> Claus Ibsen
> >>>> >> >>> >> >> >>> -----------------
> >>>> >> >>> >> >> >>> FuseSource
> >>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
> >>>> >> >>> >> >> >>> Web: http://fusesource.com
> >>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
> >>>> >> >>> >> >> >>> Blog: http://davsclaus.com
> >>>> >> >>> >> >> >>> Author of Camel in Action:
> http://www.manning.com/ibsen
> >>>> >> >>> >> >> >>>
> >>>> >> >>> >> >> >>
> >>>> >> >>> >> >> >>
> >>>> >> >>> >> >>
> >>>> >> >>> >> >>
> >>>> >> >>> >> >>
> >>>> >> >>> >> >> --
> >>>> >> >>> >> >> Claus Ibsen
> >>>> >> >>> >> >> -----------------
> >>>> >> >>> >> >> FuseSource
> >>>> >> >>> >> >> Email: cibsen@fusesource.com
> >>>> >> >>> >> >> Web: http://fusesource.com
> >>>> >> >>> >> >> Twitter: davsclaus, fusenews
> >>>> >> >>> >> >> Blog: http://davsclaus.com
> >>>> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>>> >> >>> >> >>
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> >> >>> >>
> >>>> >> >>> >> --
> >>>> >> >>> >> Claus Ibsen
> >>>> >> >>> >> -----------------
> >>>> >> >>> >> FuseSource
> >>>> >> >>> >> Email: cibsen@fusesource.com
> >>>> >> >>> >> Web: http://fusesource.com
> >>>> >> >>> >> Twitter: davsclaus, fusenews
> >>>> >> >>> >> Blog: http://davsclaus.com
> >>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>>> >> >>> >>
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>>
> >>>> >> >>> --
> >>>> >> >>> Claus Ibsen
> >>>> >> >>> -----------------
> >>>> >> >>> FuseSource
> >>>> >> >>> Email: cibsen@fusesource.com
> >>>> >> >>> Web: http://fusesource.com
> >>>> >> >>> Twitter: davsclaus, fusenews
> >>>> >> >>> Blog: http://davsclaus.com
> >>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >>>> >> >>>
> >>>> >> >>
> >>>> >> >>
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> Claus Ibsen
> >>>> >> -----------------
> >>>> >> FuseSource
> >>>> >> Email: cibsen@fusesource.com
> >>>> >> Web: http://fusesource.com
> >>>> >> Twitter: davsclaus, fusenews
> >>>> >> Blog: http://davsclaus.com
> >>>> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>>> >>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Claus Ibsen
> >>>> -----------------
> >>>> FuseSource
> >>>> Email: cibsen@fusesource.com
> >>>> Web: http://fusesource.com
> >>>> Twitter: davsclaus, fusenews
> >>>> Blog: http://davsclaus.com
> >>>> Author of Camel in Action: http://www.manning.com/ibsen
> >>>>
> >>>
> >>>
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Aug 19, 2012 at 12:14 PM, Joe San <co...@gmail.com> wrote:
> What is wondering me is that I do not see any exception at all.
> Thread.sleep(10000) sleeps for 10 seconds and I think that is ample time to
> copy a simple 4 line xml to the outbox. Is there a way that I could debug a
> bit here to understand what is happening behind the scenes?
>

It does not copy to the outbox directory. You have configured the
route to write the file to the same input file.
If you want to write to a different directory.

Then this
to("file://Users/jothi/Desktop/inbox/filename=my.xml");

Should possible be changed to
to("file://Users/jothi/Desktop/outbox/filename=my.xml");

And you dont have to specify file name as Camel can reuse the input name

to("file://Users/jothi/Desktop/outbox");

Also you have a typo in the option. Its fileName, with a capital N.

See the options names here
http://camel.apache.org/file2

They must be spelled in the right case.

> Regards,
> Jothi
>
> On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com> wrote:
>
>> After being unsuccessful at my effort to make the above route to work, I
>> created the necessary inbox and outbox folders and my new route looks like
>> below:
>>
>>
>> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
>> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>>
>> Why does this not work either? What else should I tell Camel so that he
>> writes the my.xml to the outbox?
>>
>> Regards,
>> Jothi
>>
>>
>> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com> wrote:
>>
>>> Thanks for the pointer. I made the necessary changes to my route but
>>> still unable to make it work!
>>>
>>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
>>> ProcessorBean()).to("file:.?fileName=my1.xml");
>>>
>>> For convenient sake, I changed the name of the target file (my1.xml). Why
>>> would my ProcessorBean not invoked? Also how can I see that my.xml was
>>> picked up by Camel in the from clause?
>>>
>>> Regards,
>>> Jothi
>>>
>>>
>>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <cl...@gmail.com>wrote:
>>>
>>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>>>> wrote:
>>>> > Thanks! That solved the problem.
>>>> >
>>>> > Now I'm able to successfully get my example running. But I'm not
>>>> getting
>>>> > Camel do what I wanted. Here is how my route definition looks like!
>>>> >
>>>> >                 context.addRoutes(new RouteBuilder() {
>>>> >                     public void configure() {
>>>> >                         from("file:my.xml").unmarshal(jaxb).bean(new
>>>> > ProcessorBean()).to("file:my.xml");
>>>> >                     }
>>>> >                 });
>>>> >
>>>> > The my.xml is in the same folder where the class containing the above
>>>> route
>>>> > definition exists. What I'm trying to do is to read the xml, change the
>>>> > value for the name attribute using a processor and write the new xml
>>>> to the
>>>> > same file.
>>>> >
>>>>
>>>> The file component in Camel
>>>> http://camel.apache.org/file2
>>>>
>>>> Requires to be configured with a *starting directory*. If you want to
>>>> pickup a single file by its name, you need to use the fileName option
>>>> for that
>>>>
>>>> from("file:startingDir?fileName=my.xml")...
>>>>
>>>> You may use dot as starting directory to say current dir (a bit odd
>>>> though)
>>>> from("file:.?fileName=my.xml")...
>>>>
>>>>
>>>> > Regards,
>>>> > Jothi
>>>> >
>>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com>
>>>> wrote:
>>>> >
>>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com>
>>>> wrote:
>>>> >> > So here comes the next bump!
>>>> >> >
>>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
>>>> >> > ObjectFactory.class or jaxb.index
>>>> >> >
>>>> >> > Do I have to add a jaxb.index file to my package?
>>>> >> >
>>>> >>
>>>> >> Yes, see for example p77 in Camel in Action book.
>>>> >> Or google a bit on how to use JAXB with Java.
>>>> >>
>>>> >> Basically you need to drop a jaxb.index file in the JAR with your JAXB
>>>> >> annotated classes.
>>>> >> The file should contain a line per class that has JAXB annotations.
>>>> >>
>>>> >>
>>>> >>
>>>> >> > Regards,
>>>> >> > Jothi
>>>> >> >
>>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
>>>> >> wrote:
>>>> >> >
>>>> >> >> Just managed to get rid of this issue and I was about to post my
>>>> >> solution
>>>> >> >> and saw your message. Added the following as a dependency and it
>>>> worked!
>>>> >> >>
>>>> >> >>     <dependency>
>>>> >> >>         <groupId>org.slf4j</groupId>
>>>> >> >>         <artifactId>slf4j-api</artifactId>
>>>> >> >>         <version>1.6.6</version>
>>>> >> >>     </dependency>
>>>> >> >>
>>>> >> >> Regards,
>>>> >> >> Jothi
>>>> >> >>
>>>> >> >>
>>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>>>> claus.ibsen@gmail.com
>>>> >> >wrote:
>>>> >> >>
>>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <
>>>> codeintheopen@gmail.com>
>>>> >> >>> wrote:
>>>> >> >>> > I've tried to get rid of this issue but unfortunately could not.
>>>> >> What I
>>>> >> >>> do
>>>> >> >>> > not understand is the following:
>>>> >> >>> >
>>>> >> >>> > The Error says:
>>>> >> >>> >
>>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>>> >> >>> > org/slf4j/LoggerFactory
>>>> >> >>> >     at
>>>> >> >>> >
>>>> >>
>>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>>> >> >>> >     at
>>>> >> >>> >
>>>> >> >>>
>>>> >>
>>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>>>> org.slf4j.LoggerFactory
>>>> >> >>> >
>>>> >> >>> > I have a dependency as:
>>>> >> >>> >
>>>> >> >>> >     <dependency>
>>>> >> >>> >         <groupId>org.slf4j</groupId>
>>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>>>> >> >>> >         <version>1.6.6</version>
>>>> >> >>> >     </dependency>
>>>> >> >>> >
>>>> >> >>> > When I checked the slf4j jar file, the package structure is
>>>> different
>>>> >> >>> from
>>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
>>>> rather
>>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>>>> >> >>> >
>>>> >> >>>
>>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>>>> >> >>>
>>>> >> >>> > Regards,
>>>> >> >>> > Jothi
>>>> >> >>> >
>>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>>>> claus.ibsen@gmail.com>
>>>> >> >>> wrote:
>>>> >> >>> >
>>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>>>> codeintheopen@gmail.com>
>>>> >> >>> wrote:
>>>> >> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I
>>>> get
>>>> >> this
>>>> >> >>> >> error.
>>>> >> >>> >> >
>>>> >> >>> >>
>>>> >> >>> >> Are you sure they are on the classpath when you run the app
>>>> form
>>>> >> within
>>>> >> >>> >> Eclipse.
>>>> >> >>> >>
>>>> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
>>>> bridge
>>>> >> so
>>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>>>> >> >>> >> Then you can see logs in the console in eclipse etc, if you
>>>> >> configure
>>>> >> >>> >> logging to output to std out.
>>>> >> >>> >>
>>>> >> >>> >> If you create a new Camel project using the maven archetypes
>>>> it does
>>>> >> >>> that.
>>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>>>> >> >>> >>
>>>> >> >>> >> Or see some of the Camel examples in the examples dir
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >> > Regards,
>>>> >> >>> >> > Jothi
>>>> >> >>> >> >
>>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>>>> >> claus.ibsen@gmail.com>
>>>> >> >>> >> wrote:
>>>> >> >>> >> >
>>>> >> >>> >> >> Hi
>>>> >> >>> >> >>
>>>> >> >>> >> >> See this FAQ
>>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>>>> >> >>> >> >>
>>>> >> >>> >> >>
>>>> >> >>> >> >>
>>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>>>> >> codeintheopen@gmail.com>
>>>> >> >>> >> wrote:
>>>> >> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>>> >> >>> >> >> > org/slf4j/LoggerFactory
>>>> >> >>> >> >> >     at
>>>> >> >>> >> >> >
>>>> >> >>> >>
>>>> >> >>>
>>>> >>
>>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>>> >> >>> >> >> >     at
>>>> >> >>> >> >> >
>>>> >> >>> >>
>>>> >> >>>
>>>> >>
>>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>>>> >> >>> org.slf4j.LoggerFactory
>>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>>>> >> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
>>>> >> Method)
>>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>>> >> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>>>> >> Source)
>>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>>> >> >>> >> >> >     ... 2 more
>>>> >> >>> >> >> >
>>>> >> >>> >> >> > My simple route fails with the above exception. All I
>>>> have in
>>>> >> my
>>>> >> >>> >> pom.xml
>>>> >> >>> >> >> > defined is:
>>>> >> >>> >> >> >
>>>> >> >>> >> >> >     <dependency>
>>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>>>> >> >>> >> >> >         <version>2.9.2</version>
>>>> >> >>> >> >> >     </dependency>
>>>> >> >>> >> >> >     <dependency>
>>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>>>> >> >>> >> >> >       <version>2.9.2</version>
>>>> >> >>> >> >> >     </dependency>
>>>> >> >>> >> >> >
>>>> >> >>> >> >> > Do I need additional dependencies to be added other than
>>>> this?
>>>> >> >>> >> >> >
>>>> >> >>> >> >> > Regards,
>>>> >> >>> >> >> > Jothi
>>>> >> >>> >> >> >
>>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>>>> >> codeintheopen@gmail.com
>>>> >> >>> >
>>>> >> >>> >> >> wrote:
>>>> >> >>> >> >> >
>>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>>>> expected
>>>> >> this
>>>> >> >>> hint
>>>> >> >>> >> >> that
>>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>>>> >> >>> automagically
>>>> >> >>> >> >> without
>>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>>>> >> >>> >> >> >>
>>>> >> >>> >> >> >> Regards,
>>>> >> >>> >> >> >> Jothi
>>>> >> >>> >> >> >>
>>>> >> >>> >> >> >>
>>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>>>> >> >>> claus.ibsen@gmail.com
>>>> >> >>> >> >> >wrote:
>>>> >> >>> >> >> >>
>>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>>>> >> >>> codeintheopen@gmail.com>
>>>> >> >>> >> >> wrote:
>>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>>>> >> >>> question
>>>> >> >>> >> got
>>>> >> >>> >> >> >>> > clarified once I had a look into the documentation.
>>>> >> >>> >> >> >>> >
>>>> >> >>> >> >> >>> > From the Camel in Action book:
>>>> >> >>> >> >> >>> >
>>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>>>> >> >>> >> >> >>> > .to("
>>>> http://riders.com/orders/cmd=received&date=yesterday
>>>> >> ")
>>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>>>> >> >>> >> >> >>> >
>>>> >> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>>> >> >>> >> >> >>> >
>>>> >> >>> >> >> >>> > How does Camel know which method in the
>>>> OrderToCsvBean()
>>>> >> >>> class to
>>>> >> >>> >> >> >>> invoke.
>>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>>>> Chapter 3.
>>>> >> >>> Not
>>>> >> >>> >> sure
>>>> >> >>> >> >> if
>>>> >> >>> >> >> >>> it
>>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
>>>> Chapter
>>>> >> 4.
>>>> >> >>> >> >> >>> >
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with
>>>> Camel; see
>>>> >> for
>>>> >> >>> >> >> >>> example page 105.
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel
>>>> knows
>>>> >> >>> that
>>>> >> >>> >> it
>>>> >> >>> >> >> >>> should invoke that method.
>>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more complicated.
>>>> You
>>>> >> can
>>>> >> >>> of
>>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well you
>>>> can
>>>> >> find
>>>> >> >>> >> pieces
>>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>> > Regards,
>>>> >> >>> >> >> >>> > Jothi
>>>> >> >>> >> >> >>> >
>>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>>>> >> >>> >> >> >>> >
>>>> >> >>> >> >> >>> >> Check the documentation for this:
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>> >> Babak
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>>>> >> >>> >> codeintheopen@gmail.com
>>>> >> >>> >> >> >:
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My
>>>> route
>>>> >> >>> >> definition
>>>> >> >>> >> >> >>> looks
>>>> >> >>> >> >> >>> >> >like this:
>>>> >> >>> >> >> >>> >> >
>>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>>>> >> >>> >> >> >>> >> >            public void configure() {
>>>> >> >>> >> >> >>> >> >
>>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>>>> >> >>> >> >> >>> >> >            }
>>>> >> >>> >> >> >>> >> >        });
>>>> >> >>> >> >> >>> >> >
>>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object
>>>> (say
>>>> >> >>> >> Person.java)
>>>> >> >>> >> >> >>> in my
>>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>>>> Processing,
>>>> >> how
>>>> >> >>> does
>>>> >> >>> >> >> Camel
>>>> >> >>> >> >> >>> know
>>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>>>> >> >>> >> >> >>> >> >
>>>> >> >>> >> >> >>> >> >Regards,
>>>> >> >>> >> >> >>> >> >Jothi
>>>> >> >>> >> >> >>> >> >
>>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>>>> >> >>> >> codeintheopen@gmail.com>
>>>> >> >>> >> >> >>> wrote:
>>>> >> >>> >> >> >>> >> >
>>>> >> >>> >> >> >>> >> >> Guys,
>>>> >> >>> >> >> >>> >> >>
>>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>>>> >> >>> >> >> >>> >> >>
>>>> >> >>> >> >> >>> >> >>
>>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>>>> >> >>> >> >> >>> >> >>
>>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>>>> >> ProcessorBean.
>>>> >> >>> >> Where
>>>> >> >>> >> >> >>> and how
>>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be filled
>>>> with
>>>> >> the
>>>> >> >>> >> values
>>>> >> >>> >> >> >>> in the
>>>> >> >>> >> >> >>> >> >> xml file?
>>>> >> >>> >> >> >>> >> >>
>>>> >> >>> >> >> >>> >> >> Regards,
>>>> >> >>> >> >> >>> >> >> Jothi
>>>> >> >>> >> >> >>> >> >>
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>> >>
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>> --
>>>> >> >>> >> >> >>> Claus Ibsen
>>>> >> >>> >> >> >>> -----------------
>>>> >> >>> >> >> >>> FuseSource
>>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>>>> >> >>> >> >> >>> Web: http://fusesource.com
>>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>>>> >> >>> >> >> >>> Blog: http://davsclaus.com
>>>> >> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >> >>> >> >> >>>
>>>> >> >>> >> >> >>
>>>> >> >>> >> >> >>
>>>> >> >>> >> >>
>>>> >> >>> >> >>
>>>> >> >>> >> >>
>>>> >> >>> >> >> --
>>>> >> >>> >> >> Claus Ibsen
>>>> >> >>> >> >> -----------------
>>>> >> >>> >> >> FuseSource
>>>> >> >>> >> >> Email: cibsen@fusesource.com
>>>> >> >>> >> >> Web: http://fusesource.com
>>>> >> >>> >> >> Twitter: davsclaus, fusenews
>>>> >> >>> >> >> Blog: http://davsclaus.com
>>>> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >> >>> >> >>
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >>
>>>> >> >>> >> --
>>>> >> >>> >> Claus Ibsen
>>>> >> >>> >> -----------------
>>>> >> >>> >> FuseSource
>>>> >> >>> >> Email: cibsen@fusesource.com
>>>> >> >>> >> Web: http://fusesource.com
>>>> >> >>> >> Twitter: davsclaus, fusenews
>>>> >> >>> >> Blog: http://davsclaus.com
>>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >> >>> >>
>>>> >> >>>
>>>> >> >>>
>>>> >> >>>
>>>> >> >>> --
>>>> >> >>> Claus Ibsen
>>>> >> >>> -----------------
>>>> >> >>> FuseSource
>>>> >> >>> Email: cibsen@fusesource.com
>>>> >> >>> Web: http://fusesource.com
>>>> >> >>> Twitter: davsclaus, fusenews
>>>> >> >>> Blog: http://davsclaus.com
>>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >> >>>
>>>> >> >>
>>>> >> >>
>>>> >>
>>>> >>
>>>> >>
>>>> >> --
>>>> >> Claus Ibsen
>>>> >> -----------------
>>>> >> FuseSource
>>>> >> Email: cibsen@fusesource.com
>>>> >> Web: http://fusesource.com
>>>> >> Twitter: davsclaus, fusenews
>>>> >> Blog: http://davsclaus.com
>>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>>> >>
>>>>
>>>>
>>>>
>>>> --
>>>> Claus Ibsen
>>>> -----------------
>>>> FuseSource
>>>> Email: cibsen@fusesource.com
>>>> Web: http://fusesource.com
>>>> Twitter: davsclaus, fusenews
>>>> Blog: http://davsclaus.com
>>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>>
>>>
>>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
What is wondering me is that I do not see any exception at all.
Thread.sleep(10000) sleeps for 10 seconds and I think that is ample time to
copy a simple 4 line xml to the outbox. Is there a way that I could debug a
bit here to understand what is happening behind the scenes?

Regards,
Jothi

On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com> wrote:

> After being unsuccessful at my effort to make the above route to work, I
> created the necessary inbox and outbox folders and my new route looks like
> below:
>
>
> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>
> Why does this not work either? What else should I tell Camel so that he
> writes the my.xml to the outbox?
>
> Regards,
> Jothi
>
>
> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com> wrote:
>
>> Thanks for the pointer. I made the necessary changes to my route but
>> still unable to make it work!
>>
>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
>> ProcessorBean()).to("file:.?fileName=my1.xml");
>>
>> For convenient sake, I changed the name of the target file (my1.xml). Why
>> would my ProcessorBean not invoked? Also how can I see that my.xml was
>> picked up by Camel in the from clause?
>>
>> Regards,
>> Jothi
>>
>>
>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <cl...@gmail.com>wrote:
>>
>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>>> wrote:
>>> > Thanks! That solved the problem.
>>> >
>>> > Now I'm able to successfully get my example running. But I'm not
>>> getting
>>> > Camel do what I wanted. Here is how my route definition looks like!
>>> >
>>> >                 context.addRoutes(new RouteBuilder() {
>>> >                     public void configure() {
>>> >                         from("file:my.xml").unmarshal(jaxb).bean(new
>>> > ProcessorBean()).to("file:my.xml");
>>> >                     }
>>> >                 });
>>> >
>>> > The my.xml is in the same folder where the class containing the above
>>> route
>>> > definition exists. What I'm trying to do is to read the xml, change the
>>> > value for the name attribute using a processor and write the new xml
>>> to the
>>> > same file.
>>> >
>>>
>>> The file component in Camel
>>> http://camel.apache.org/file2
>>>
>>> Requires to be configured with a *starting directory*. If you want to
>>> pickup a single file by its name, you need to use the fileName option
>>> for that
>>>
>>> from("file:startingDir?fileName=my.xml")...
>>>
>>> You may use dot as starting directory to say current dir (a bit odd
>>> though)
>>> from("file:.?fileName=my.xml")...
>>>
>>>
>>> > Regards,
>>> > Jothi
>>> >
>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com>
>>> wrote:
>>> >
>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com>
>>> wrote:
>>> >> > So here comes the next bump!
>>> >> >
>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
>>> >> > ObjectFactory.class or jaxb.index
>>> >> >
>>> >> > Do I have to add a jaxb.index file to my package?
>>> >> >
>>> >>
>>> >> Yes, see for example p77 in Camel in Action book.
>>> >> Or google a bit on how to use JAXB with Java.
>>> >>
>>> >> Basically you need to drop a jaxb.index file in the JAR with your JAXB
>>> >> annotated classes.
>>> >> The file should contain a line per class that has JAXB annotations.
>>> >>
>>> >>
>>> >>
>>> >> > Regards,
>>> >> > Jothi
>>> >> >
>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
>>> >> wrote:
>>> >> >
>>> >> >> Just managed to get rid of this issue and I was about to post my
>>> >> solution
>>> >> >> and saw your message. Added the following as a dependency and it
>>> worked!
>>> >> >>
>>> >> >>     <dependency>
>>> >> >>         <groupId>org.slf4j</groupId>
>>> >> >>         <artifactId>slf4j-api</artifactId>
>>> >> >>         <version>1.6.6</version>
>>> >> >>     </dependency>
>>> >> >>
>>> >> >> Regards,
>>> >> >> Jothi
>>> >> >>
>>> >> >>
>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>>> claus.ibsen@gmail.com
>>> >> >wrote:
>>> >> >>
>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <
>>> codeintheopen@gmail.com>
>>> >> >>> wrote:
>>> >> >>> > I've tried to get rid of this issue but unfortunately could not.
>>> >> What I
>>> >> >>> do
>>> >> >>> > not understand is the following:
>>> >> >>> >
>>> >> >>> > The Error says:
>>> >> >>> >
>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> >> >>> > org/slf4j/LoggerFactory
>>> >> >>> >     at
>>> >> >>> >
>>> >>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >> >>> >     at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>>> org.slf4j.LoggerFactory
>>> >> >>> >
>>> >> >>> > I have a dependency as:
>>> >> >>> >
>>> >> >>> >     <dependency>
>>> >> >>> >         <groupId>org.slf4j</groupId>
>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>>> >> >>> >         <version>1.6.6</version>
>>> >> >>> >     </dependency>
>>> >> >>> >
>>> >> >>> > When I checked the slf4j jar file, the package structure is
>>> different
>>> >> >>> from
>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
>>> rather
>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>>> >> >>> >
>>> >> >>>
>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>>> >> >>>
>>> >> >>> > Regards,
>>> >> >>> > Jothi
>>> >> >>> >
>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>>> claus.ibsen@gmail.com>
>>> >> >>> wrote:
>>> >> >>> >
>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>>> codeintheopen@gmail.com>
>>> >> >>> wrote:
>>> >> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I
>>> get
>>> >> this
>>> >> >>> >> error.
>>> >> >>> >> >
>>> >> >>> >>
>>> >> >>> >> Are you sure they are on the classpath when you run the app
>>> form
>>> >> within
>>> >> >>> >> Eclipse.
>>> >> >>> >>
>>> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
>>> bridge
>>> >> so
>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>>> >> >>> >> Then you can see logs in the console in eclipse etc, if you
>>> >> configure
>>> >> >>> >> logging to output to std out.
>>> >> >>> >>
>>> >> >>> >> If you create a new Camel project using the maven archetypes
>>> it does
>>> >> >>> that.
>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>>> >> >>> >>
>>> >> >>> >> Or see some of the Camel examples in the examples dir
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >> > Regards,
>>> >> >>> >> > Jothi
>>> >> >>> >> >
>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>>> >> claus.ibsen@gmail.com>
>>> >> >>> >> wrote:
>>> >> >>> >> >
>>> >> >>> >> >> Hi
>>> >> >>> >> >>
>>> >> >>> >> >> See this FAQ
>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>>> >> codeintheopen@gmail.com>
>>> >> >>> >> wrote:
>>> >> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> >> >>> >> >> > org/slf4j/LoggerFactory
>>> >> >>> >> >> >     at
>>> >> >>> >> >> >
>>> >> >>> >>
>>> >> >>>
>>> >>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >> >>> >> >> >     at
>>> >> >>> >> >> >
>>> >> >>> >>
>>> >> >>>
>>> >>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>>> >> >>> org.slf4j.LoggerFactory
>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>>> >> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
>>> >> Method)
>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>> >> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>>> >> Source)
>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>> >> >>> >> >> >     ... 2 more
>>> >> >>> >> >> >
>>> >> >>> >> >> > My simple route fails with the above exception. All I
>>> have in
>>> >> my
>>> >> >>> >> pom.xml
>>> >> >>> >> >> > defined is:
>>> >> >>> >> >> >
>>> >> >>> >> >> >     <dependency>
>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>>> >> >>> >> >> >         <version>2.9.2</version>
>>> >> >>> >> >> >     </dependency>
>>> >> >>> >> >> >     <dependency>
>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>>> >> >>> >> >> >       <version>2.9.2</version>
>>> >> >>> >> >> >     </dependency>
>>> >> >>> >> >> >
>>> >> >>> >> >> > Do I need additional dependencies to be added other than
>>> this?
>>> >> >>> >> >> >
>>> >> >>> >> >> > Regards,
>>> >> >>> >> >> > Jothi
>>> >> >>> >> >> >
>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>>> >> codeintheopen@gmail.com
>>> >> >>> >
>>> >> >>> >> >> wrote:
>>> >> >>> >> >> >
>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>>> expected
>>> >> this
>>> >> >>> hint
>>> >> >>> >> >> that
>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>>> >> >>> automagically
>>> >> >>> >> >> without
>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>>> >> >>> >> >> >>
>>> >> >>> >> >> >> Regards,
>>> >> >>> >> >> >> Jothi
>>> >> >>> >> >> >>
>>> >> >>> >> >> >>
>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>>> >> >>> claus.ibsen@gmail.com
>>> >> >>> >> >> >wrote:
>>> >> >>> >> >> >>
>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>>> >> >>> codeintheopen@gmail.com>
>>> >> >>> >> >> wrote:
>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>>> >> >>> question
>>> >> >>> >> got
>>> >> >>> >> >> >>> > clarified once I had a look into the documentation.
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > From the Camel in Action book:
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>>> >> >>> >> >> >>> > .to("
>>> http://riders.com/orders/cmd=received&date=yesterday
>>> >> ")
>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>>> >> >>> >> >> >>> >
>>> >> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > How does Camel know which method in the
>>> OrderToCsvBean()
>>> >> >>> class to
>>> >> >>> >> >> >>> invoke.
>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>>> Chapter 3.
>>> >> >>> Not
>>> >> >>> >> sure
>>> >> >>> >> >> if
>>> >> >>> >> >> >>> it
>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
>>> Chapter
>>> >> 4.
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with
>>> Camel; see
>>> >> for
>>> >> >>> >> >> >>> example page 105.
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel
>>> knows
>>> >> >>> that
>>> >> >>> >> it
>>> >> >>> >> >> >>> should invoke that method.
>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more complicated.
>>> You
>>> >> can
>>> >> >>> of
>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well you
>>> can
>>> >> find
>>> >> >>> >> pieces
>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> > Regards,
>>> >> >>> >> >> >>> > Jothi
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> >> Check the documentation for this:
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> Babak
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>>> >> >>> >> codeintheopen@gmail.com
>>> >> >>> >> >> >:
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My
>>> route
>>> >> >>> >> definition
>>> >> >>> >> >> >>> looks
>>> >> >>> >> >> >>> >> >like this:
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>>> >> >>> >> >> >>> >> >            public void configure() {
>>> >> >>> >> >> >>> >> >
>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>>> >> >>> >> >> >>> >> >            }
>>> >> >>> >> >> >>> >> >        });
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object
>>> (say
>>> >> >>> >> Person.java)
>>> >> >>> >> >> >>> in my
>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>>> Processing,
>>> >> how
>>> >> >>> does
>>> >> >>> >> >> Camel
>>> >> >>> >> >> >>> know
>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >Regards,
>>> >> >>> >> >> >>> >> >Jothi
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>>> >> >>> >> codeintheopen@gmail.com>
>>> >> >>> >> >> >>> wrote:
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >> Guys,
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >>
>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>>> >> ProcessorBean.
>>> >> >>> >> Where
>>> >> >>> >> >> >>> and how
>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be filled
>>> with
>>> >> the
>>> >> >>> >> values
>>> >> >>> >> >> >>> in the
>>> >> >>> >> >> >>> >> >> xml file?
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >> Regards,
>>> >> >>> >> >> >>> >> >> Jothi
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> --
>>> >> >>> >> >> >>> Claus Ibsen
>>> >> >>> >> >> >>> -----------------
>>> >> >>> >> >> >>> FuseSource
>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>>> >> >>> >> >> >>> Web: http://fusesource.com
>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>>> >> >>> >> >> >>> Blog: http://davsclaus.com
>>> >> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>
>>> >> >>> >> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >> --
>>> >> >>> >> >> Claus Ibsen
>>> >> >>> >> >> -----------------
>>> >> >>> >> >> FuseSource
>>> >> >>> >> >> Email: cibsen@fusesource.com
>>> >> >>> >> >> Web: http://fusesource.com
>>> >> >>> >> >> Twitter: davsclaus, fusenews
>>> >> >>> >> >> Blog: http://davsclaus.com
>>> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>> >> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >> --
>>> >> >>> >> Claus Ibsen
>>> >> >>> >> -----------------
>>> >> >>> >> FuseSource
>>> >> >>> >> Email: cibsen@fusesource.com
>>> >> >>> >> Web: http://fusesource.com
>>> >> >>> >> Twitter: davsclaus, fusenews
>>> >> >>> >> Blog: http://davsclaus.com
>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>> >>
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>> --
>>> >> >>> Claus Ibsen
>>> >> >>> -----------------
>>> >> >>> FuseSource
>>> >> >>> Email: cibsen@fusesource.com
>>> >> >>> Web: http://fusesource.com
>>> >> >>> Twitter: davsclaus, fusenews
>>> >> >>> Blog: http://davsclaus.com
>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>>
>>> >> >>
>>> >> >>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> -----------------
>>> >> FuseSource
>>> >> Email: cibsen@fusesource.com
>>> >> Web: http://fusesource.com
>>> >> Twitter: davsclaus, fusenews
>>> >> Blog: http://davsclaus.com
>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: cibsen@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>
>>
>>
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Aug 19, 2012 at 11:14 AM, Joe San <co...@gmail.com> wrote:
> After being unsuccessful at my effort to make the above route to work, I
> created the necessary inbox and outbox folders and my new route looks like
> below:
>
>
> from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
> ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");
>
> Why does this not work either? What else should I tell Camel so that he
> writes the my.xml to the outbox?
>

With Camel you can use the tracer to see how messages is being routed
http://camel.apache.org/tracer

But often its also just easier to take out pieces of the route, until
something happens/works. (divide and conquer)
So you could just start with a file -> log, and then see if the file
is picked up.
And then add the unmarshal and then move on.

And make sure you got the logging setup so you can log to the console / file.
eg the slf4j + log4j etc. And a log4j.properties file. The Camel Maven
archetypes / examples all uses log4j and have a sample
log4j.properties file to set all this up.




> Regards,
> Jothi
>
> On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com> wrote:
>
>> Thanks for the pointer. I made the necessary changes to my route but still
>> unable to make it work!
>>
>> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
>> ProcessorBean()).to("file:.?fileName=my1.xml");
>>
>> For convenient sake, I changed the name of the target file (my1.xml). Why
>> would my ProcessorBean not invoked? Also how can I see that my.xml was
>> picked up by Camel in the from clause?
>>
>> Regards,
>> Jothi
>>
>>
>> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <cl...@gmail.com>wrote:
>>
>>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>>> wrote:
>>> > Thanks! That solved the problem.
>>> >
>>> > Now I'm able to successfully get my example running. But I'm not getting
>>> > Camel do what I wanted. Here is how my route definition looks like!
>>> >
>>> >                 context.addRoutes(new RouteBuilder() {
>>> >                     public void configure() {
>>> >                         from("file:my.xml").unmarshal(jaxb).bean(new
>>> > ProcessorBean()).to("file:my.xml");
>>> >                     }
>>> >                 });
>>> >
>>> > The my.xml is in the same folder where the class containing the above
>>> route
>>> > definition exists. What I'm trying to do is to read the xml, change the
>>> > value for the name attribute using a processor and write the new xml to
>>> the
>>> > same file.
>>> >
>>>
>>> The file component in Camel
>>> http://camel.apache.org/file2
>>>
>>> Requires to be configured with a *starting directory*. If you want to
>>> pickup a single file by its name, you need to use the fileName option
>>> for that
>>>
>>> from("file:startingDir?fileName=my.xml")...
>>>
>>> You may use dot as starting directory to say current dir (a bit odd
>>> though)
>>> from("file:.?fileName=my.xml")...
>>>
>>>
>>> > Regards,
>>> > Jothi
>>> >
>>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com>
>>> wrote:
>>> >
>>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com>
>>> wrote:
>>> >> > So here comes the next bump!
>>> >> >
>>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
>>> >> > ObjectFactory.class or jaxb.index
>>> >> >
>>> >> > Do I have to add a jaxb.index file to my package?
>>> >> >
>>> >>
>>> >> Yes, see for example p77 in Camel in Action book.
>>> >> Or google a bit on how to use JAXB with Java.
>>> >>
>>> >> Basically you need to drop a jaxb.index file in the JAR with your JAXB
>>> >> annotated classes.
>>> >> The file should contain a line per class that has JAXB annotations.
>>> >>
>>> >>
>>> >>
>>> >> > Regards,
>>> >> > Jothi
>>> >> >
>>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
>>> >> wrote:
>>> >> >
>>> >> >> Just managed to get rid of this issue and I was about to post my
>>> >> solution
>>> >> >> and saw your message. Added the following as a dependency and it
>>> worked!
>>> >> >>
>>> >> >>     <dependency>
>>> >> >>         <groupId>org.slf4j</groupId>
>>> >> >>         <artifactId>slf4j-api</artifactId>
>>> >> >>         <version>1.6.6</version>
>>> >> >>     </dependency>
>>> >> >>
>>> >> >> Regards,
>>> >> >> Jothi
>>> >> >>
>>> >> >>
>>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>>> claus.ibsen@gmail.com
>>> >> >wrote:
>>> >> >>
>>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <codeintheopen@gmail.com
>>> >
>>> >> >>> wrote:
>>> >> >>> > I've tried to get rid of this issue but unfortunately could not.
>>> >> What I
>>> >> >>> do
>>> >> >>> > not understand is the following:
>>> >> >>> >
>>> >> >>> > The Error says:
>>> >> >>> >
>>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> >> >>> > org/slf4j/LoggerFactory
>>> >> >>> >     at
>>> >> >>> >
>>> >>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >> >>> >     at
>>> >> >>> >
>>> >> >>>
>>> >>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>>> org.slf4j.LoggerFactory
>>> >> >>> >
>>> >> >>> > I have a dependency as:
>>> >> >>> >
>>> >> >>> >     <dependency>
>>> >> >>> >         <groupId>org.slf4j</groupId>
>>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>>> >> >>> >         <version>1.6.6</version>
>>> >> >>> >     </dependency>
>>> >> >>> >
>>> >> >>> > When I checked the slf4j jar file, the package structure is
>>> different
>>> >> >>> from
>>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
>>> rather
>>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>>> >> >>> >
>>> >> >>>
>>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>>> >> >>>
>>> >> >>> > Regards,
>>> >> >>> > Jothi
>>> >> >>> >
>>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>>> claus.ibsen@gmail.com>
>>> >> >>> wrote:
>>> >> >>> >
>>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>>> codeintheopen@gmail.com>
>>> >> >>> wrote:
>>> >> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I
>>> get
>>> >> this
>>> >> >>> >> error.
>>> >> >>> >> >
>>> >> >>> >>
>>> >> >>> >> Are you sure they are on the classpath when you run the app form
>>> >> within
>>> >> >>> >> Eclipse.
>>> >> >>> >>
>>> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
>>> bridge
>>> >> so
>>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>>> >> >>> >> Then you can see logs in the console in eclipse etc, if you
>>> >> configure
>>> >> >>> >> logging to output to std out.
>>> >> >>> >>
>>> >> >>> >> If you create a new Camel project using the maven archetypes it
>>> does
>>> >> >>> that.
>>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>>> >> >>> >>
>>> >> >>> >> Or see some of the Camel examples in the examples dir
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >> > Regards,
>>> >> >>> >> > Jothi
>>> >> >>> >> >
>>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>>> >> claus.ibsen@gmail.com>
>>> >> >>> >> wrote:
>>> >> >>> >> >
>>> >> >>> >> >> Hi
>>> >> >>> >> >>
>>> >> >>> >> >> See this FAQ
>>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>>> >> codeintheopen@gmail.com>
>>> >> >>> >> wrote:
>>> >> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> >> >>> >> >> > org/slf4j/LoggerFactory
>>> >> >>> >> >> >     at
>>> >> >>> >> >> >
>>> >> >>> >>
>>> >> >>>
>>> >>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >> >>> >> >> >     at
>>> >> >>> >> >> >
>>> >> >>> >>
>>> >> >>>
>>> >>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>>> >> >>> org.slf4j.LoggerFactory
>>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>>> >> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
>>> >> Method)
>>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>> >> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>>> >> Source)
>>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>> >> >>> >> >> >     ... 2 more
>>> >> >>> >> >> >
>>> >> >>> >> >> > My simple route fails with the above exception. All I have
>>> in
>>> >> my
>>> >> >>> >> pom.xml
>>> >> >>> >> >> > defined is:
>>> >> >>> >> >> >
>>> >> >>> >> >> >     <dependency>
>>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>>> >> >>> >> >> >         <version>2.9.2</version>
>>> >> >>> >> >> >     </dependency>
>>> >> >>> >> >> >     <dependency>
>>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>>> >> >>> >> >> >       <version>2.9.2</version>
>>> >> >>> >> >> >     </dependency>
>>> >> >>> >> >> >
>>> >> >>> >> >> > Do I need additional dependencies to be added other than
>>> this?
>>> >> >>> >> >> >
>>> >> >>> >> >> > Regards,
>>> >> >>> >> >> > Jothi
>>> >> >>> >> >> >
>>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>>> >> codeintheopen@gmail.com
>>> >> >>> >
>>> >> >>> >> >> wrote:
>>> >> >>> >> >> >
>>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>>> expected
>>> >> this
>>> >> >>> hint
>>> >> >>> >> >> that
>>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>>> >> >>> automagically
>>> >> >>> >> >> without
>>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>>> >> >>> >> >> >>
>>> >> >>> >> >> >> Regards,
>>> >> >>> >> >> >> Jothi
>>> >> >>> >> >> >>
>>> >> >>> >> >> >>
>>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>>> >> >>> claus.ibsen@gmail.com
>>> >> >>> >> >> >wrote:
>>> >> >>> >> >> >>
>>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>>> >> >>> codeintheopen@gmail.com>
>>> >> >>> >> >> wrote:
>>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>>> >> >>> question
>>> >> >>> >> got
>>> >> >>> >> >> >>> > clarified once I had a look into the documentation.
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > From the Camel in Action book:
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>>> >> >>> >> >> >>> > .to("
>>> http://riders.com/orders/cmd=received&date=yesterday
>>> >> ")
>>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>>> >> >>> >> >> >>> >
>>> >> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > How does Camel know which method in the
>>> OrderToCsvBean()
>>> >> >>> class to
>>> >> >>> >> >> >>> invoke.
>>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>>> Chapter 3.
>>> >> >>> Not
>>> >> >>> >> sure
>>> >> >>> >> >> if
>>> >> >>> >> >> >>> it
>>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
>>> Chapter
>>> >> 4.
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel;
>>> see
>>> >> for
>>> >> >>> >> >> >>> example page 105.
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel
>>> knows
>>> >> >>> that
>>> >> >>> >> it
>>> >> >>> >> >> >>> should invoke that method.
>>> >> >>> >> >> >>> Its when you have 2+ methods it gets more complicated.
>>> You
>>> >> can
>>> >> >>> of
>>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well you can
>>> >> find
>>> >> >>> >> pieces
>>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> > Regards,
>>> >> >>> >> >> >>> > Jothi
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>>> >> >>> >> >> >>> >
>>> >> >>> >> >> >>> >> Check the documentation for this:
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> Babak
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>>> >> >>> >> codeintheopen@gmail.com
>>> >> >>> >> >> >:
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My
>>> route
>>> >> >>> >> definition
>>> >> >>> >> >> >>> looks
>>> >> >>> >> >> >>> >> >like this:
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>>> >> >>> >> >> >>> >> >            public void configure() {
>>> >> >>> >> >> >>> >> >
>>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>>> >> >>> >> >> >>> >> >            }
>>> >> >>> >> >> >>> >> >        });
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object
>>> (say
>>> >> >>> >> Person.java)
>>> >> >>> >> >> >>> in my
>>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>>> Processing,
>>> >> how
>>> >> >>> does
>>> >> >>> >> >> Camel
>>> >> >>> >> >> >>> know
>>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >Regards,
>>> >> >>> >> >> >>> >> >Jothi
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>>> >> >>> >> codeintheopen@gmail.com>
>>> >> >>> >> >> >>> wrote:
>>> >> >>> >> >> >>> >> >
>>> >> >>> >> >> >>> >> >> Guys,
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >>
>>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>>> >> ProcessorBean.
>>> >> >>> >> Where
>>> >> >>> >> >> >>> and how
>>> >> >>> >> >> >>> >> >> do I specify the Java object which will be filled
>>> with
>>> >> the
>>> >> >>> >> values
>>> >> >>> >> >> >>> in the
>>> >> >>> >> >> >>> >> >> xml file?
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >> >> Regards,
>>> >> >>> >> >> >>> >> >> Jothi
>>> >> >>> >> >> >>> >> >>
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>> >>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>> --
>>> >> >>> >> >> >>> Claus Ibsen
>>> >> >>> >> >> >>> -----------------
>>> >> >>> >> >> >>> FuseSource
>>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>>> >> >>> >> >> >>> Web: http://fusesource.com
>>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>>> >> >>> >> >> >>> Blog: http://davsclaus.com
>>> >> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>> >> >> >>>
>>> >> >>> >> >> >>
>>> >> >>> >> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >>
>>> >> >>> >> >> --
>>> >> >>> >> >> Claus Ibsen
>>> >> >>> >> >> -----------------
>>> >> >>> >> >> FuseSource
>>> >> >>> >> >> Email: cibsen@fusesource.com
>>> >> >>> >> >> Web: http://fusesource.com
>>> >> >>> >> >> Twitter: davsclaus, fusenews
>>> >> >>> >> >> Blog: http://davsclaus.com
>>> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>> >> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >>
>>> >> >>> >> --
>>> >> >>> >> Claus Ibsen
>>> >> >>> >> -----------------
>>> >> >>> >> FuseSource
>>> >> >>> >> Email: cibsen@fusesource.com
>>> >> >>> >> Web: http://fusesource.com
>>> >> >>> >> Twitter: davsclaus, fusenews
>>> >> >>> >> Blog: http://davsclaus.com
>>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>> >>
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>> --
>>> >> >>> Claus Ibsen
>>> >> >>> -----------------
>>> >> >>> FuseSource
>>> >> >>> Email: cibsen@fusesource.com
>>> >> >>> Web: http://fusesource.com
>>> >> >>> Twitter: davsclaus, fusenews
>>> >> >>> Blog: http://davsclaus.com
>>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>>
>>> >> >>
>>> >> >>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> -----------------
>>> >> FuseSource
>>> >> Email: cibsen@fusesource.com
>>> >> Web: http://fusesource.com
>>> >> Twitter: davsclaus, fusenews
>>> >> Blog: http://davsclaus.com
>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: cibsen@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>
>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
After being unsuccessful at my effort to make the above route to work, I
created the necessary inbox and outbox folders and my new route looks like
below:


from("file://Users/jothi/Desktop/inbox/filename=my.xml").unmarshal(jaxb).bean(new
ProcessorBean()).to("file://Users/jothi/Desktop/inbox/filename=my.xml");

Why does this not work either? What else should I tell Camel so that he
writes the my.xml to the outbox?

Regards,
Jothi

On Fri, Aug 17, 2012 at 12:47 PM, Joe San <co...@gmail.com> wrote:

> Thanks for the pointer. I made the necessary changes to my route but still
> unable to make it work!
>
> from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
> ProcessorBean()).to("file:.?fileName=my1.xml");
>
> For convenient sake, I changed the name of the target file (my1.xml). Why
> would my ProcessorBean not invoked? Also how can I see that my.xml was
> picked up by Camel in the from clause?
>
> Regards,
> Jothi
>
>
> On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <cl...@gmail.com>wrote:
>
>> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com>
>> wrote:
>> > Thanks! That solved the problem.
>> >
>> > Now I'm able to successfully get my example running. But I'm not getting
>> > Camel do what I wanted. Here is how my route definition looks like!
>> >
>> >                 context.addRoutes(new RouteBuilder() {
>> >                     public void configure() {
>> >                         from("file:my.xml").unmarshal(jaxb).bean(new
>> > ProcessorBean()).to("file:my.xml");
>> >                     }
>> >                 });
>> >
>> > The my.xml is in the same folder where the class containing the above
>> route
>> > definition exists. What I'm trying to do is to read the xml, change the
>> > value for the name attribute using a processor and write the new xml to
>> the
>> > same file.
>> >
>>
>> The file component in Camel
>> http://camel.apache.org/file2
>>
>> Requires to be configured with a *starting directory*. If you want to
>> pickup a single file by its name, you need to use the fileName option
>> for that
>>
>> from("file:startingDir?fileName=my.xml")...
>>
>> You may use dot as starting directory to say current dir (a bit odd
>> though)
>> from("file:.?fileName=my.xml")...
>>
>>
>> > Regards,
>> > Jothi
>> >
>> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com>
>> wrote:
>> >> > So here comes the next bump!
>> >> >
>> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
>> >> > ObjectFactory.class or jaxb.index
>> >> >
>> >> > Do I have to add a jaxb.index file to my package?
>> >> >
>> >>
>> >> Yes, see for example p77 in Camel in Action book.
>> >> Or google a bit on how to use JAXB with Java.
>> >>
>> >> Basically you need to drop a jaxb.index file in the JAR with your JAXB
>> >> annotated classes.
>> >> The file should contain a line per class that has JAXB annotations.
>> >>
>> >>
>> >>
>> >> > Regards,
>> >> > Jothi
>> >> >
>> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
>> >> wrote:
>> >> >
>> >> >> Just managed to get rid of this issue and I was about to post my
>> >> solution
>> >> >> and saw your message. Added the following as a dependency and it
>> worked!
>> >> >>
>> >> >>     <dependency>
>> >> >>         <groupId>org.slf4j</groupId>
>> >> >>         <artifactId>slf4j-api</artifactId>
>> >> >>         <version>1.6.6</version>
>> >> >>     </dependency>
>> >> >>
>> >> >> Regards,
>> >> >> Jothi
>> >> >>
>> >> >>
>> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <
>> claus.ibsen@gmail.com
>> >> >wrote:
>> >> >>
>> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <codeintheopen@gmail.com
>> >
>> >> >>> wrote:
>> >> >>> > I've tried to get rid of this issue but unfortunately could not.
>> >> What I
>> >> >>> do
>> >> >>> > not understand is the following:
>> >> >>> >
>> >> >>> > The Error says:
>> >> >>> >
>> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >> >>> > org/slf4j/LoggerFactory
>> >> >>> >     at
>> >> >>> >
>> >>
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >> >>> >     at
>> >> >>> >
>> >> >>>
>> >>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >> >>> > Caused by: java.lang.ClassNotFoundException:
>> org.slf4j.LoggerFactory
>> >> >>> >
>> >> >>> > I have a dependency as:
>> >> >>> >
>> >> >>> >     <dependency>
>> >> >>> >         <groupId>org.slf4j</groupId>
>> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
>> >> >>> >         <version>1.6.6</version>
>> >> >>> >     </dependency>
>> >> >>> >
>> >> >>> > When I checked the slf4j jar file, the package structure is
>> different
>> >> >>> from
>> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
>> rather
>> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>> >> >>> >
>> >> >>>
>> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>> >> >>>
>> >> >>> > Regards,
>> >> >>> > Jothi
>> >> >>> >
>> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
>> claus.ibsen@gmail.com>
>> >> >>> wrote:
>> >> >>> >
>> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
>> codeintheopen@gmail.com>
>> >> >>> wrote:
>> >> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I
>> get
>> >> this
>> >> >>> >> error.
>> >> >>> >> >
>> >> >>> >>
>> >> >>> >> Are you sure they are on the classpath when you run the app form
>> >> within
>> >> >>> >> Eclipse.
>> >> >>> >>
>> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
>> bridge
>> >> so
>> >> >>> >> you can use log4j, or maybe some other log kit to log.
>> >> >>> >> Then you can see logs in the console in eclipse etc, if you
>> >> configure
>> >> >>> >> logging to output to std out.
>> >> >>> >>
>> >> >>> >> If you create a new Camel project using the maven archetypes it
>> does
>> >> >>> that.
>> >> >>> >> camel.apache.org/camel-maven-archetypes.html
>> >> >>> >>
>> >> >>> >> Or see some of the Camel examples in the examples dir
>> >> >>> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >> > Regards,
>> >> >>> >> > Jothi
>> >> >>> >> >
>> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>> >> claus.ibsen@gmail.com>
>> >> >>> >> wrote:
>> >> >>> >> >
>> >> >>> >> >> Hi
>> >> >>> >> >>
>> >> >>> >> >> See this FAQ
>> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>> >> >>> >> >>
>> >> >>> >> >>
>> >> >>> >> >>
>> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>> >> codeintheopen@gmail.com>
>> >> >>> >> wrote:
>> >> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >> >>> >> >> > org/slf4j/LoggerFactory
>> >> >>> >> >> >     at
>> >> >>> >> >> >
>> >> >>> >>
>> >> >>>
>> >>
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >> >>> >> >> >     at
>> >> >>> >> >> >
>> >> >>> >>
>> >> >>>
>> >>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>> >> >>> org.slf4j.LoggerFactory
>> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>> >> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
>> >> Method)
>> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>> >> Source)
>> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >> >>> >> >> >     ... 2 more
>> >> >>> >> >> >
>> >> >>> >> >> > My simple route fails with the above exception. All I have
>> in
>> >> my
>> >> >>> >> pom.xml
>> >> >>> >> >> > defined is:
>> >> >>> >> >> >
>> >> >>> >> >> >     <dependency>
>> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
>> >> >>> >> >> >         <artifactId>camel-core</artifactId>
>> >> >>> >> >> >         <version>2.9.2</version>
>> >> >>> >> >> >     </dependency>
>> >> >>> >> >> >     <dependency>
>> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
>> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>> >> >>> >> >> >       <version>2.9.2</version>
>> >> >>> >> >> >     </dependency>
>> >> >>> >> >> >
>> >> >>> >> >> > Do I need additional dependencies to be added other than
>> this?
>> >> >>> >> >> >
>> >> >>> >> >> > Regards,
>> >> >>> >> >> > Jothi
>> >> >>> >> >> >
>> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>> >> codeintheopen@gmail.com
>> >> >>> >
>> >> >>> >> >> wrote:
>> >> >>> >> >> >
>> >> >>> >> >> >> I just found that out from Chapter 4. I would have
>> expected
>> >> this
>> >> >>> hint
>> >> >>> >> >> that
>> >> >>> >> >> >> "when the bean has only one method, camel invokes it
>> >> >>> automagically
>> >> >>> >> >> without
>> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>> >> >>> >> >> >>
>> >> >>> >> >> >> Regards,
>> >> >>> >> >> >> Jothi
>> >> >>> >> >> >>
>> >> >>> >> >> >>
>> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>> >> >>> claus.ibsen@gmail.com
>> >> >>> >> >> >wrote:
>> >> >>> >> >> >>
>> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>> >> >>> codeintheopen@gmail.com>
>> >> >>> >> >> wrote:
>> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>> >> >>> question
>> >> >>> >> got
>> >> >>> >> >> >>> > clarified once I had a look into the documentation.
>> >> >>> >> >> >>> >
>> >> >>> >> >> >>> > From the Camel in Action book:
>> >> >>> >> >> >>> >
>> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>> >> >>> >> >> >>> > .to("
>> http://riders.com/orders/cmd=received&date=yesterday
>> >> ")
>> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
>> >> >>> >> >> >>> >
>> >> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >> >>> >> >> >>> >
>> >> >>> >> >> >>> > How does Camel know which method in the
>> OrderToCsvBean()
>> >> >>> class to
>> >> >>> >> >> >>> invoke.
>> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
>> Chapter 3.
>> >> >>> Not
>> >> >>> >> sure
>> >> >>> >> >> if
>> >> >>> >> >> >>> it
>> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
>> Chapter
>> >> 4.
>> >> >>> >> >> >>> >
>> >> >>> >> >> >>>
>> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel;
>> see
>> >> for
>> >> >>> >> >> >>> example page 105.
>> >> >>> >> >> >>>
>> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel
>> knows
>> >> >>> that
>> >> >>> >> it
>> >> >>> >> >> >>> should invoke that method.
>> >> >>> >> >> >>> Its when you have 2+ methods it gets more complicated.
>> You
>> >> can
>> >> >>> of
>> >> >>> >> >> >>> course tell Camel the method name to use etc.
>> >> >>> >> >> >>>
>> >> >>> >> >> >>> But its all covered as well in chapter 4, as well you can
>> >> find
>> >> >>> >> pieces
>> >> >>> >> >> >>> of details scattered online in the Camel docs.
>> >> >>> >> >> >>>
>> >> >>> >> >> >>>
>> >> >>> >> >> >>> > Regards,
>> >> >>> >> >> >>> > Jothi
>> >> >>> >> >> >>> >
>> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>> >> >>> >> >> >>> >
>> >> >>> >> >> >>> >> Check the documentation for this:
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>> >> Babak
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>> >> >>> >> codeintheopen@gmail.com
>> >> >>> >> >> >:
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My
>> route
>> >> >>> >> definition
>> >> >>> >> >> >>> looks
>> >> >>> >> >> >>> >> >like this:
>> >> >>> >> >> >>> >> >
>> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>> >> >>> >> >> >>> >> >            public void configure() {
>> >> >>> >> >> >>> >> >
>> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>> >> >>> >> >> >>> >> >            }
>> >> >>> >> >> >>> >> >        });
>> >> >>> >> >> >>> >> >
>> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object
>> (say
>> >> >>> >> Person.java)
>> >> >>> >> >> >>> in my
>> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for
>> Processing,
>> >> how
>> >> >>> does
>> >> >>> >> >> Camel
>> >> >>> >> >> >>> know
>> >> >>> >> >> >>> >> >which method to invoke in that bean?
>> >> >>> >> >> >>> >> >
>> >> >>> >> >> >>> >> >Regards,
>> >> >>> >> >> >>> >> >Jothi
>> >> >>> >> >> >>> >> >
>> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>> >> >>> >> codeintheopen@gmail.com>
>> >> >>> >> >> >>> wrote:
>> >> >>> >> >> >>> >> >
>> >> >>> >> >> >>> >> >> Guys,
>> >> >>> >> >> >>> >> >>
>> >> >>> >> >> >>> >> >> I have a route which is defined as below:
>> >> >>> >> >> >>> >> >>
>> >> >>> >> >> >>> >> >>
>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>> >> >>> >> >> >>> >> >>
>> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>> >> ProcessorBean.
>> >> >>> >> Where
>> >> >>> >> >> >>> and how
>> >> >>> >> >> >>> >> >> do I specify the Java object which will be filled
>> with
>> >> the
>> >> >>> >> values
>> >> >>> >> >> >>> in the
>> >> >>> >> >> >>> >> >> xml file?
>> >> >>> >> >> >>> >> >>
>> >> >>> >> >> >>> >> >> Regards,
>> >> >>> >> >> >>> >> >> Jothi
>> >> >>> >> >> >>> >> >>
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>> >>
>> >> >>> >> >> >>>
>> >> >>> >> >> >>>
>> >> >>> >> >> >>>
>> >> >>> >> >> >>> --
>> >> >>> >> >> >>> Claus Ibsen
>> >> >>> >> >> >>> -----------------
>> >> >>> >> >> >>> FuseSource
>> >> >>> >> >> >>> Email: cibsen@fusesource.com
>> >> >>> >> >> >>> Web: http://fusesource.com
>> >> >>> >> >> >>> Twitter: davsclaus, fusenews
>> >> >>> >> >> >>> Blog: http://davsclaus.com
>> >> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >>> >> >> >>>
>> >> >>> >> >> >>
>> >> >>> >> >> >>
>> >> >>> >> >>
>> >> >>> >> >>
>> >> >>> >> >>
>> >> >>> >> >> --
>> >> >>> >> >> Claus Ibsen
>> >> >>> >> >> -----------------
>> >> >>> >> >> FuseSource
>> >> >>> >> >> Email: cibsen@fusesource.com
>> >> >>> >> >> Web: http://fusesource.com
>> >> >>> >> >> Twitter: davsclaus, fusenews
>> >> >>> >> >> Blog: http://davsclaus.com
>> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >>> >> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >> --
>> >> >>> >> Claus Ibsen
>> >> >>> >> -----------------
>> >> >>> >> FuseSource
>> >> >>> >> Email: cibsen@fusesource.com
>> >> >>> >> Web: http://fusesource.com
>> >> >>> >> Twitter: davsclaus, fusenews
>> >> >>> >> Blog: http://davsclaus.com
>> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >>> >>
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Claus Ibsen
>> >> >>> -----------------
>> >> >>> FuseSource
>> >> >>> Email: cibsen@fusesource.com
>> >> >>> Web: http://fusesource.com
>> >> >>> Twitter: davsclaus, fusenews
>> >> >>> Blog: http://davsclaus.com
>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >>>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> -----------------
>> >> FuseSource
>> >> Email: cibsen@fusesource.com
>> >> Web: http://fusesource.com
>> >> Twitter: davsclaus, fusenews
>> >> Blog: http://davsclaus.com
>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Thanks for the pointer. I made the necessary changes to my route but still
unable to make it work!

from("file:.?fileName=my.xml").unmarshal(jaxb).bean(new
ProcessorBean()).to("file:.?fileName=my1.xml");

For convenient sake, I changed the name of the target file (my1.xml). Why
would my ProcessorBean not invoked? Also how can I see that my.xml was
picked up by Camel in the from clause?

Regards,
Jothi

On Fri, Aug 17, 2012 at 12:19 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com> wrote:
> > Thanks! That solved the problem.
> >
> > Now I'm able to successfully get my example running. But I'm not getting
> > Camel do what I wanted. Here is how my route definition looks like!
> >
> >                 context.addRoutes(new RouteBuilder() {
> >                     public void configure() {
> >                         from("file:my.xml").unmarshal(jaxb).bean(new
> > ProcessorBean()).to("file:my.xml");
> >                     }
> >                 });
> >
> > The my.xml is in the same folder where the class containing the above
> route
> > definition exists. What I'm trying to do is to read the xml, change the
> > value for the name attribute using a processor and write the new xml to
> the
> > same file.
> >
>
> The file component in Camel
> http://camel.apache.org/file2
>
> Requires to be configured with a *starting directory*. If you want to
> pickup a single file by its name, you need to use the fileName option
> for that
>
> from("file:startingDir?fileName=my.xml")...
>
> You may use dot as starting directory to say current dir (a bit odd though)
> from("file:.?fileName=my.xml")...
>
>
> > Regards,
> > Jothi
> >
> > On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com>
> wrote:
> >> > So here comes the next bump!
> >> >
> >> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
> >> > ObjectFactory.class or jaxb.index
> >> >
> >> > Do I have to add a jaxb.index file to my package?
> >> >
> >>
> >> Yes, see for example p77 in Camel in Action book.
> >> Or google a bit on how to use JAXB with Java.
> >>
> >> Basically you need to drop a jaxb.index file in the JAR with your JAXB
> >> annotated classes.
> >> The file should contain a line per class that has JAXB annotations.
> >>
> >>
> >>
> >> > Regards,
> >> > Jothi
> >> >
> >> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
> >> wrote:
> >> >
> >> >> Just managed to get rid of this issue and I was about to post my
> >> solution
> >> >> and saw your message. Added the following as a dependency and it
> worked!
> >> >>
> >> >>     <dependency>
> >> >>         <groupId>org.slf4j</groupId>
> >> >>         <artifactId>slf4j-api</artifactId>
> >> >>         <version>1.6.6</version>
> >> >>     </dependency>
> >> >>
> >> >> Regards,
> >> >> Jothi
> >> >>
> >> >>
> >> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <claus.ibsen@gmail.com
> >> >wrote:
> >> >>
> >> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com>
> >> >>> wrote:
> >> >>> > I've tried to get rid of this issue but unfortunately could not.
> >> What I
> >> >>> do
> >> >>> > not understand is the following:
> >> >>> >
> >> >>> > The Error says:
> >> >>> >
> >> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >> >>> > org/slf4j/LoggerFactory
> >> >>> >     at
> >> >>> >
> >> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >> >>> >     at
> >> >>> >
> >> >>>
> >>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >> >>> > Caused by: java.lang.ClassNotFoundException:
> org.slf4j.LoggerFactory
> >> >>> >
> >> >>> > I have a dependency as:
> >> >>> >
> >> >>> >     <dependency>
> >> >>> >         <groupId>org.slf4j</groupId>
> >> >>> >         <artifactId>slf4j-log4j12</artifactId>
> >> >>> >         <version>1.6.6</version>
> >> >>> >     </dependency>
> >> >>> >
> >> >>> > When I checked the slf4j jar file, the package structure is
> different
> >> >>> from
> >> >>> > what the error says. There is no org.slf4j.LoggerFactory but
> rather
> >> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
> >> >>> >
> >> >>>
> >> >>> And you got slf4j-api JAR as well? Its needed as dependency.
> >> >>>
> >> >>> > Regards,
> >> >>> > Jothi
> >> >>> >
> >> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <
> claus.ibsen@gmail.com>
> >> >>> wrote:
> >> >>> >
> >> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <
> codeintheopen@gmail.com>
> >> >>> wrote:
> >> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I
> get
> >> this
> >> >>> >> error.
> >> >>> >> >
> >> >>> >>
> >> >>> >> Are you sure they are on the classpath when you run the app form
> >> within
> >> >>> >> Eclipse.
> >> >>> >>
> >> >>> >> And you may want to add slf4j-log4j12 or some other logging
> bridge
> >> so
> >> >>> >> you can use log4j, or maybe some other log kit to log.
> >> >>> >> Then you can see logs in the console in eclipse etc, if you
> >> configure
> >> >>> >> logging to output to std out.
> >> >>> >>
> >> >>> >> If you create a new Camel project using the maven archetypes it
> does
> >> >>> that.
> >> >>> >> camel.apache.org/camel-maven-archetypes.html
> >> >>> >>
> >> >>> >> Or see some of the Camel examples in the examples dir
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> > Regards,
> >> >>> >> > Jothi
> >> >>> >> >
> >> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
> >> claus.ibsen@gmail.com>
> >> >>> >> wrote:
> >> >>> >> >
> >> >>> >> >> Hi
> >> >>> >> >>
> >> >>> >> >> See this FAQ
> >> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
> >> >>> >> >>
> >> >>> >> >>
> >> >>> >> >>
> >> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
> >> codeintheopen@gmail.com>
> >> >>> >> wrote:
> >> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >> >>> >> >> > org/slf4j/LoggerFactory
> >> >>> >> >> >     at
> >> >>> >> >> >
> >> >>> >>
> >> >>>
> >> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >> >>> >> >> >     at
> >> >>> >> >> >
> >> >>> >>
> >> >>>
> >>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
> >> >>> org.slf4j.LoggerFactory
> >> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
> >> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
> >> Method)
> >> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
> >> Source)
> >> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >> >>> >> >> >     ... 2 more
> >> >>> >> >> >
> >> >>> >> >> > My simple route fails with the above exception. All I have
> in
> >> my
> >> >>> >> pom.xml
> >> >>> >> >> > defined is:
> >> >>> >> >> >
> >> >>> >> >> >     <dependency>
> >> >>> >> >> >         <groupId>org.apache.camel</groupId>
> >> >>> >> >> >         <artifactId>camel-core</artifactId>
> >> >>> >> >> >         <version>2.9.2</version>
> >> >>> >> >> >     </dependency>
> >> >>> >> >> >     <dependency>
> >> >>> >> >> >       <groupId>org.apache.camel</groupId>
> >> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
> >> >>> >> >> >       <version>2.9.2</version>
> >> >>> >> >> >     </dependency>
> >> >>> >> >> >
> >> >>> >> >> > Do I need additional dependencies to be added other than
> this?
> >> >>> >> >> >
> >> >>> >> >> > Regards,
> >> >>> >> >> > Jothi
> >> >>> >> >> >
> >> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
> >> codeintheopen@gmail.com
> >> >>> >
> >> >>> >> >> wrote:
> >> >>> >> >> >
> >> >>> >> >> >> I just found that out from Chapter 4. I would have expected
> >> this
> >> >>> hint
> >> >>> >> >> that
> >> >>> >> >> >> "when the bean has only one method, camel invokes it
> >> >>> automagically
> >> >>> >> >> without
> >> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
> >> >>> >> >> >>
> >> >>> >> >> >> Regards,
> >> >>> >> >> >> Jothi
> >> >>> >> >> >>
> >> >>> >> >> >>
> >> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
> >> >>> claus.ibsen@gmail.com
> >> >>> >> >> >wrote:
> >> >>> >> >> >>
> >> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
> >> >>> codeintheopen@gmail.com>
> >> >>> >> >> wrote:
> >> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
> >> >>> question
> >> >>> >> got
> >> >>> >> >> >>> > clarified once I had a look into the documentation.
> >> >>> >> >> >>> >
> >> >>> >> >> >>> > From the Camel in Action book:
> >> >>> >> >> >>> >
> >> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
> >> >>> >> >> >>> > .to("
> http://riders.com/orders/cmd=received&date=yesterday
> >> ")
> >> >>> >> >> >>> > .bean(new OrderToCsvBean())
> >> >>> >> >> >>> >
> >> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >> >>> >> >> >>> >
> >> >>> >> >> >>> > How does Camel know which method in the OrderToCsvBean()
> >> >>> class to
> >> >>> >> >> >>> invoke.
> >> >>> >> >> >>> > Unfortunately the book does not mentions this in
> Chapter 3.
> >> >>> Not
> >> >>> >> sure
> >> >>> >> >> if
> >> >>> >> >> >>> it
> >> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with
> Chapter
> >> 4.
> >> >>> >> >> >>> >
> >> >>> >> >> >>>
> >> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel;
> see
> >> for
> >> >>> >> >> >>> example page 105.
> >> >>> >> >> >>>
> >> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel
> knows
> >> >>> that
> >> >>> >> it
> >> >>> >> >> >>> should invoke that method.
> >> >>> >> >> >>> Its when you have 2+ methods it gets more complicated. You
> >> can
> >> >>> of
> >> >>> >> >> >>> course tell Camel the method name to use etc.
> >> >>> >> >> >>>
> >> >>> >> >> >>> But its all covered as well in chapter 4, as well you can
> >> find
> >> >>> >> pieces
> >> >>> >> >> >>> of details scattered online in the Camel docs.
> >> >>> >> >> >>>
> >> >>> >> >> >>>
> >> >>> >> >> >>> > Regards,
> >> >>> >> >> >>> > Jothi
> >> >>> >> >> >>> >
> >> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> >> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
> >> >>> >> >> >>> >
> >> >>> >> >> >>> >> Check the documentation for this:
> >> >>> >> >> >>> >>
> >> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
> >> >>> >> >> >>> >>
> >> >>> >> >> >>> >> Babak
> >> >>> >> >> >>> >>
> >> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
> >> >>> >> codeintheopen@gmail.com
> >> >>> >> >> >:
> >> >>> >> >> >>> >>
> >> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My
> route
> >> >>> >> definition
> >> >>> >> >> >>> looks
> >> >>> >> >> >>> >> >like this:
> >> >>> >> >> >>> >> >
> >> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
> >> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
> >> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
> >> >>> >> >> >>> >> >            public void configure() {
> >> >>> >> >> >>> >> >
> >> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
> >> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
> >> >>> >> >> >>> >> >            }
> >> >>> >> >> >>> >> >        });
> >> >>> >> >> >>> >> >
> >> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
> >> >>> >> Person.java)
> >> >>> >> >> >>> in my
> >> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing,
> >> how
> >> >>> does
> >> >>> >> >> Camel
> >> >>> >> >> >>> know
> >> >>> >> >> >>> >> >which method to invoke in that bean?
> >> >>> >> >> >>> >> >
> >> >>> >> >> >>> >> >Regards,
> >> >>> >> >> >>> >> >Jothi
> >> >>> >> >> >>> >> >
> >> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
> >> >>> >> codeintheopen@gmail.com>
> >> >>> >> >> >>> wrote:
> >> >>> >> >> >>> >> >
> >> >>> >> >> >>> >> >> Guys,
> >> >>> >> >> >>> >> >>
> >> >>> >> >> >>> >> >> I have a route which is defined as below:
> >> >>> >> >> >>> >> >>
> >> >>> >> >> >>> >> >>
> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
> >> >>> >> >> >>> >> >>
> >> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
> >> ProcessorBean.
> >> >>> >> Where
> >> >>> >> >> >>> and how
> >> >>> >> >> >>> >> >> do I specify the Java object which will be filled
> with
> >> the
> >> >>> >> values
> >> >>> >> >> >>> in the
> >> >>> >> >> >>> >> >> xml file?
> >> >>> >> >> >>> >> >>
> >> >>> >> >> >>> >> >> Regards,
> >> >>> >> >> >>> >> >> Jothi
> >> >>> >> >> >>> >> >>
> >> >>> >> >> >>> >>
> >> >>> >> >> >>> >>
> >> >>> >> >> >>> >>
> >> >>> >> >> >>>
> >> >>> >> >> >>>
> >> >>> >> >> >>>
> >> >>> >> >> >>> --
> >> >>> >> >> >>> Claus Ibsen
> >> >>> >> >> >>> -----------------
> >> >>> >> >> >>> FuseSource
> >> >>> >> >> >>> Email: cibsen@fusesource.com
> >> >>> >> >> >>> Web: http://fusesource.com
> >> >>> >> >> >>> Twitter: davsclaus, fusenews
> >> >>> >> >> >>> Blog: http://davsclaus.com
> >> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >> >>> >> >> >>>
> >> >>> >> >> >>
> >> >>> >> >> >>
> >> >>> >> >>
> >> >>> >> >>
> >> >>> >> >>
> >> >>> >> >> --
> >> >>> >> >> Claus Ibsen
> >> >>> >> >> -----------------
> >> >>> >> >> FuseSource
> >> >>> >> >> Email: cibsen@fusesource.com
> >> >>> >> >> Web: http://fusesource.com
> >> >>> >> >> Twitter: davsclaus, fusenews
> >> >>> >> >> Blog: http://davsclaus.com
> >> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
> >> >>> >> >>
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>> >> --
> >> >>> >> Claus Ibsen
> >> >>> >> -----------------
> >> >>> >> FuseSource
> >> >>> >> Email: cibsen@fusesource.com
> >> >>> >> Web: http://fusesource.com
> >> >>> >> Twitter: davsclaus, fusenews
> >> >>> >> Blog: http://davsclaus.com
> >> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
> >> >>> >>
> >> >>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Claus Ibsen
> >> >>> -----------------
> >> >>> FuseSource
> >> >>> Email: cibsen@fusesource.com
> >> >>> Web: http://fusesource.com
> >> >>> Twitter: davsclaus, fusenews
> >> >>> Blog: http://davsclaus.com
> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >> >>>
> >> >>
> >> >>
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus, fusenews
> >> Blog: http://davsclaus.com
> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Aug 17, 2012 at 11:26 AM, Joe San <co...@gmail.com> wrote:
> Thanks! That solved the problem.
>
> Now I'm able to successfully get my example running. But I'm not getting
> Camel do what I wanted. Here is how my route definition looks like!
>
>                 context.addRoutes(new RouteBuilder() {
>                     public void configure() {
>                         from("file:my.xml").unmarshal(jaxb).bean(new
> ProcessorBean()).to("file:my.xml");
>                     }
>                 });
>
> The my.xml is in the same folder where the class containing the above route
> definition exists. What I'm trying to do is to read the xml, change the
> value for the name attribute using a processor and write the new xml to the
> same file.
>

The file component in Camel
http://camel.apache.org/file2

Requires to be configured with a *starting directory*. If you want to
pickup a single file by its name, you need to use the fileName option
for that

from("file:startingDir?fileName=my.xml")...

You may use dot as starting directory to say current dir (a bit odd though)
from("file:.?fileName=my.xml")...


> Regards,
> Jothi
>
> On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com> wrote:
>> > So here comes the next bump!
>> >
>> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
>> > ObjectFactory.class or jaxb.index
>> >
>> > Do I have to add a jaxb.index file to my package?
>> >
>>
>> Yes, see for example p77 in Camel in Action book.
>> Or google a bit on how to use JAXB with Java.
>>
>> Basically you need to drop a jaxb.index file in the JAR with your JAXB
>> annotated classes.
>> The file should contain a line per class that has JAXB annotations.
>>
>>
>>
>> > Regards,
>> > Jothi
>> >
>> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
>> wrote:
>> >
>> >> Just managed to get rid of this issue and I was about to post my
>> solution
>> >> and saw your message. Added the following as a dependency and it worked!
>> >>
>> >>     <dependency>
>> >>         <groupId>org.slf4j</groupId>
>> >>         <artifactId>slf4j-api</artifactId>
>> >>         <version>1.6.6</version>
>> >>     </dependency>
>> >>
>> >> Regards,
>> >> Jothi
>> >>
>> >>
>> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <claus.ibsen@gmail.com
>> >wrote:
>> >>
>> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com>
>> >>> wrote:
>> >>> > I've tried to get rid of this issue but unfortunately could not.
>> What I
>> >>> do
>> >>> > not understand is the following:
>> >>> >
>> >>> > The Error says:
>> >>> >
>> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >>> > org/slf4j/LoggerFactory
>> >>> >     at
>> >>> >
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >>> >     at
>> >>> >
>> >>>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >>> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>> >>> >
>> >>> > I have a dependency as:
>> >>> >
>> >>> >     <dependency>
>> >>> >         <groupId>org.slf4j</groupId>
>> >>> >         <artifactId>slf4j-log4j12</artifactId>
>> >>> >         <version>1.6.6</version>
>> >>> >     </dependency>
>> >>> >
>> >>> > When I checked the slf4j jar file, the package structure is different
>> >>> from
>> >>> > what the error says. There is no org.slf4j.LoggerFactory but rather
>> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>> >>> >
>> >>>
>> >>> And you got slf4j-api JAR as well? Its needed as dependency.
>> >>>
>> >>> > Regards,
>> >>> > Jothi
>> >>> >
>> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com>
>> >>> wrote:
>> >>> >
>> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com>
>> >>> wrote:
>> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I get
>> this
>> >>> >> error.
>> >>> >> >
>> >>> >>
>> >>> >> Are you sure they are on the classpath when you run the app form
>> within
>> >>> >> Eclipse.
>> >>> >>
>> >>> >> And you may want to add slf4j-log4j12 or some other logging bridge
>> so
>> >>> >> you can use log4j, or maybe some other log kit to log.
>> >>> >> Then you can see logs in the console in eclipse etc, if you
>> configure
>> >>> >> logging to output to std out.
>> >>> >>
>> >>> >> If you create a new Camel project using the maven archetypes it does
>> >>> that.
>> >>> >> camel.apache.org/camel-maven-archetypes.html
>> >>> >>
>> >>> >> Or see some of the Camel examples in the examples dir
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> > Regards,
>> >>> >> > Jothi
>> >>> >> >
>> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
>> claus.ibsen@gmail.com>
>> >>> >> wrote:
>> >>> >> >
>> >>> >> >> Hi
>> >>> >> >>
>> >>> >> >> See this FAQ
>> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>> >>> >> >>
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
>> codeintheopen@gmail.com>
>> >>> >> wrote:
>> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >>> >> >> > org/slf4j/LoggerFactory
>> >>> >> >> >     at
>> >>> >> >> >
>> >>> >>
>> >>>
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >>> >> >> >     at
>> >>> >> >> >
>> >>> >>
>> >>>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
>> >>> org.slf4j.LoggerFactory
>> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
>> Method)
>> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
>> Source)
>> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >>> >> >> >     ... 2 more
>> >>> >> >> >
>> >>> >> >> > My simple route fails with the above exception. All I have in
>> my
>> >>> >> pom.xml
>> >>> >> >> > defined is:
>> >>> >> >> >
>> >>> >> >> >     <dependency>
>> >>> >> >> >         <groupId>org.apache.camel</groupId>
>> >>> >> >> >         <artifactId>camel-core</artifactId>
>> >>> >> >> >         <version>2.9.2</version>
>> >>> >> >> >     </dependency>
>> >>> >> >> >     <dependency>
>> >>> >> >> >       <groupId>org.apache.camel</groupId>
>> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
>> >>> >> >> >       <version>2.9.2</version>
>> >>> >> >> >     </dependency>
>> >>> >> >> >
>> >>> >> >> > Do I need additional dependencies to be added other than this?
>> >>> >> >> >
>> >>> >> >> > Regards,
>> >>> >> >> > Jothi
>> >>> >> >> >
>> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
>> codeintheopen@gmail.com
>> >>> >
>> >>> >> >> wrote:
>> >>> >> >> >
>> >>> >> >> >> I just found that out from Chapter 4. I would have expected
>> this
>> >>> hint
>> >>> >> >> that
>> >>> >> >> >> "when the bean has only one method, camel invokes it
>> >>> automagically
>> >>> >> >> without
>> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>> >>> >> >> >>
>> >>> >> >> >> Regards,
>> >>> >> >> >> Jothi
>> >>> >> >> >>
>> >>> >> >> >>
>> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>> >>> claus.ibsen@gmail.com
>> >>> >> >> >wrote:
>> >>> >> >> >>
>> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>> >>> codeintheopen@gmail.com>
>> >>> >> >> wrote:
>> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>> >>> question
>> >>> >> got
>> >>> >> >> >>> > clarified once I had a look into the documentation.
>> >>> >> >> >>> >
>> >>> >> >> >>> > From the Camel in Action book:
>> >>> >> >> >>> >
>> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>> >>> >> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday
>> ")
>> >>> >> >> >>> > .bean(new OrderToCsvBean())
>> >>> >> >> >>> >
>> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >>> >> >> >>> >
>> >>> >> >> >>> > How does Camel know which method in the OrderToCsvBean()
>> >>> class to
>> >>> >> >> >>> invoke.
>> >>> >> >> >>> > Unfortunately the book does not mentions this in Chapter 3.
>> >>> Not
>> >>> >> sure
>> >>> >> >> if
>> >>> >> >> >>> it
>> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter
>> 4.
>> >>> >> >> >>> >
>> >>> >> >> >>>
>> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see
>> for
>> >>> >> >> >>> example page 105.
>> >>> >> >> >>>
>> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel knows
>> >>> that
>> >>> >> it
>> >>> >> >> >>> should invoke that method.
>> >>> >> >> >>> Its when you have 2+ methods it gets more complicated. You
>> can
>> >>> of
>> >>> >> >> >>> course tell Camel the method name to use etc.
>> >>> >> >> >>>
>> >>> >> >> >>> But its all covered as well in chapter 4, as well you can
>> find
>> >>> >> pieces
>> >>> >> >> >>> of details scattered online in the Camel docs.
>> >>> >> >> >>>
>> >>> >> >> >>>
>> >>> >> >> >>> > Regards,
>> >>> >> >> >>> > Jothi
>> >>> >> >> >>> >
>> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
>> >>> >> >> >>> >
>> >>> >> >> >>> >> Check the documentation for this:
>> >>> >> >> >>> >>
>> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>> >>> >> >> >>> >>
>> >>> >> >> >>> >> Babak
>> >>> >> >> >>> >>
>> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>> >>> >> codeintheopen@gmail.com
>> >>> >> >> >:
>> >>> >> >> >>> >>
>> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My route
>> >>> >> definition
>> >>> >> >> >>> looks
>> >>> >> >> >>> >> >like this:
>> >>> >> >> >>> >> >
>> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>> >>> >> >> >>> >> >            public void configure() {
>> >>> >> >> >>> >> >
>> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
>> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>> >>> >> >> >>> >> >            }
>> >>> >> >> >>> >> >        });
>> >>> >> >> >>> >> >
>> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
>> >>> >> Person.java)
>> >>> >> >> >>> in my
>> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing,
>> how
>> >>> does
>> >>> >> >> Camel
>> >>> >> >> >>> know
>> >>> >> >> >>> >> >which method to invoke in that bean?
>> >>> >> >> >>> >> >
>> >>> >> >> >>> >> >Regards,
>> >>> >> >> >>> >> >Jothi
>> >>> >> >> >>> >> >
>> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>> >>> >> codeintheopen@gmail.com>
>> >>> >> >> >>> wrote:
>> >>> >> >> >>> >> >
>> >>> >> >> >>> >> >> Guys,
>> >>> >> >> >>> >> >>
>> >>> >> >> >>> >> >> I have a route which is defined as below:
>> >>> >> >> >>> >> >>
>> >>> >> >> >>> >> >>
>> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>> >>> >> >> >>> >> >>
>> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
>> ProcessorBean.
>> >>> >> Where
>> >>> >> >> >>> and how
>> >>> >> >> >>> >> >> do I specify the Java object which will be filled with
>> the
>> >>> >> values
>> >>> >> >> >>> in the
>> >>> >> >> >>> >> >> xml file?
>> >>> >> >> >>> >> >>
>> >>> >> >> >>> >> >> Regards,
>> >>> >> >> >>> >> >> Jothi
>> >>> >> >> >>> >> >>
>> >>> >> >> >>> >>
>> >>> >> >> >>> >>
>> >>> >> >> >>> >>
>> >>> >> >> >>>
>> >>> >> >> >>>
>> >>> >> >> >>>
>> >>> >> >> >>> --
>> >>> >> >> >>> Claus Ibsen
>> >>> >> >> >>> -----------------
>> >>> >> >> >>> FuseSource
>> >>> >> >> >>> Email: cibsen@fusesource.com
>> >>> >> >> >>> Web: http://fusesource.com
>> >>> >> >> >>> Twitter: davsclaus, fusenews
>> >>> >> >> >>> Blog: http://davsclaus.com
>> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >>> >> >> >>>
>> >>> >> >> >>
>> >>> >> >> >>
>> >>> >> >>
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> --
>> >>> >> >> Claus Ibsen
>> >>> >> >> -----------------
>> >>> >> >> FuseSource
>> >>> >> >> Email: cibsen@fusesource.com
>> >>> >> >> Web: http://fusesource.com
>> >>> >> >> Twitter: davsclaus, fusenews
>> >>> >> >> Blog: http://davsclaus.com
>> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>> >> >>
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> --
>> >>> >> Claus Ibsen
>> >>> >> -----------------
>> >>> >> FuseSource
>> >>> >> Email: cibsen@fusesource.com
>> >>> >> Web: http://fusesource.com
>> >>> >> Twitter: davsclaus, fusenews
>> >>> >> Blog: http://davsclaus.com
>> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>> >>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Claus Ibsen
>> >>> -----------------
>> >>> FuseSource
>> >>> Email: cibsen@fusesource.com
>> >>> Web: http://fusesource.com
>> >>> Twitter: davsclaus, fusenews
>> >>> Blog: http://davsclaus.com
>> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>
>> >>
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Thanks! That solved the problem.

Now I'm able to successfully get my example running. But I'm not getting
Camel do what I wanted. Here is how my route definition looks like!

                context.addRoutes(new RouteBuilder() {
                    public void configure() {
                        from("file:my.xml").unmarshal(jaxb).bean(new
ProcessorBean()).to("file:my.xml");
                    }
                });

The my.xml is in the same folder where the class containing the above route
definition exists. What I'm trying to do is to read the xml, change the
value for the name attribute using a processor and write the new xml to the
same file.

Regards,
Jothi

On Fri, Aug 17, 2012 at 10:57 AM, Claus Ibsen <cl...@gmail.com> wrote:

> On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com> wrote:
> > So here comes the next bump!
> >
> > javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
> > ObjectFactory.class or jaxb.index
> >
> > Do I have to add a jaxb.index file to my package?
> >
>
> Yes, see for example p77 in Camel in Action book.
> Or google a bit on how to use JAXB with Java.
>
> Basically you need to drop a jaxb.index file in the JAR with your JAXB
> annotated classes.
> The file should contain a line per class that has JAXB annotations.
>
>
>
> > Regards,
> > Jothi
> >
> > On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com>
> wrote:
> >
> >> Just managed to get rid of this issue and I was about to post my
> solution
> >> and saw your message. Added the following as a dependency and it worked!
> >>
> >>     <dependency>
> >>         <groupId>org.slf4j</groupId>
> >>         <artifactId>slf4j-api</artifactId>
> >>         <version>1.6.6</version>
> >>     </dependency>
> >>
> >> Regards,
> >> Jothi
> >>
> >>
> >> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <claus.ibsen@gmail.com
> >wrote:
> >>
> >>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com>
> >>> wrote:
> >>> > I've tried to get rid of this issue but unfortunately could not.
> What I
> >>> do
> >>> > not understand is the following:
> >>> >
> >>> > The Error says:
> >>> >
> >>> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >>> > org/slf4j/LoggerFactory
> >>> >     at
> >>> >
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >>> >     at
> >>> >
> >>>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >>> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
> >>> >
> >>> > I have a dependency as:
> >>> >
> >>> >     <dependency>
> >>> >         <groupId>org.slf4j</groupId>
> >>> >         <artifactId>slf4j-log4j12</artifactId>
> >>> >         <version>1.6.6</version>
> >>> >     </dependency>
> >>> >
> >>> > When I checked the slf4j jar file, the package structure is different
> >>> from
> >>> > what the error says. There is no org.slf4j.LoggerFactory but rather
> >>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
> >>> >
> >>>
> >>> And you got slf4j-api JAR as well? Its needed as dependency.
> >>>
> >>> > Regards,
> >>> > Jothi
> >>> >
> >>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com>
> >>> wrote:
> >>> >
> >>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com>
> >>> wrote:
> >>> >> > Even with the al4j-log4j dependecy added in the libraries, I get
> this
> >>> >> error.
> >>> >> >
> >>> >>
> >>> >> Are you sure they are on the classpath when you run the app form
> within
> >>> >> Eclipse.
> >>> >>
> >>> >> And you may want to add slf4j-log4j12 or some other logging bridge
> so
> >>> >> you can use log4j, or maybe some other log kit to log.
> >>> >> Then you can see logs in the console in eclipse etc, if you
> configure
> >>> >> logging to output to std out.
> >>> >>
> >>> >> If you create a new Camel project using the maven archetypes it does
> >>> that.
> >>> >> camel.apache.org/camel-maven-archetypes.html
> >>> >>
> >>> >> Or see some of the Camel examples in the examples dir
> >>> >>
> >>> >>
> >>> >>
> >>> >> > Regards,
> >>> >> > Jothi
> >>> >> >
> >>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <
> claus.ibsen@gmail.com>
> >>> >> wrote:
> >>> >> >
> >>> >> >> Hi
> >>> >> >>
> >>> >> >> See this FAQ
> >>> >> >> http://camel.apache.org/what-jars-do-i-need.html
> >>> >> >>
> >>> >> >>
> >>> >> >>
> >>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <
> codeintheopen@gmail.com>
> >>> >> wrote:
> >>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >>> >> >> > org/slf4j/LoggerFactory
> >>> >> >> >     at
> >>> >> >> >
> >>> >>
> >>>
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >>> >> >> >     at
> >>> >> >> >
> >>> >>
> >>>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >>> >> >> > Caused by: java.lang.ClassNotFoundException:
> >>> org.slf4j.LoggerFactory
> >>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
> >>> >> >> >     at java.security.AccessController.doPrivileged(Native
> Method)
> >>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown
> Source)
> >>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >>> >> >> >     ... 2 more
> >>> >> >> >
> >>> >> >> > My simple route fails with the above exception. All I have in
> my
> >>> >> pom.xml
> >>> >> >> > defined is:
> >>> >> >> >
> >>> >> >> >     <dependency>
> >>> >> >> >         <groupId>org.apache.camel</groupId>
> >>> >> >> >         <artifactId>camel-core</artifactId>
> >>> >> >> >         <version>2.9.2</version>
> >>> >> >> >     </dependency>
> >>> >> >> >     <dependency>
> >>> >> >> >       <groupId>org.apache.camel</groupId>
> >>> >> >> >       <artifactId>camel-jaxb</artifactId>
> >>> >> >> >       <version>2.9.2</version>
> >>> >> >> >     </dependency>
> >>> >> >> >
> >>> >> >> > Do I need additional dependencies to be added other than this?
> >>> >> >> >
> >>> >> >> > Regards,
> >>> >> >> > Jothi
> >>> >> >> >
> >>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <
> codeintheopen@gmail.com
> >>> >
> >>> >> >> wrote:
> >>> >> >> >
> >>> >> >> >> I just found that out from Chapter 4. I would have expected
> this
> >>> hint
> >>> >> >> that
> >>> >> >> >> "when the bean has only one method, camel invokes it
> >>> automagically
> >>> >> >> without
> >>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
> >>> >> >> >>
> >>> >> >> >> Regards,
> >>> >> >> >> Jothi
> >>> >> >> >>
> >>> >> >> >>
> >>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
> >>> claus.ibsen@gmail.com
> >>> >> >> >wrote:
> >>> >> >> >>
> >>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
> >>> codeintheopen@gmail.com>
> >>> >> >> wrote:
> >>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
> >>> question
> >>> >> got
> >>> >> >> >>> > clarified once I had a look into the documentation.
> >>> >> >> >>> >
> >>> >> >> >>> > From the Camel in Action book:
> >>> >> >> >>> >
> >>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
> >>> >> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday
> ")
> >>> >> >> >>> > .bean(new OrderToCsvBean())
> >>> >> >> >>> >
> >>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >>> >> >> >>> >
> >>> >> >> >>> > How does Camel know which method in the OrderToCsvBean()
> >>> class to
> >>> >> >> >>> invoke.
> >>> >> >> >>> > Unfortunately the book does not mentions this in Chapter 3.
> >>> Not
> >>> >> sure
> >>> >> >> if
> >>> >> >> >>> it
> >>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter
> 4.
> >>> >> >> >>> >
> >>> >> >> >>>
> >>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see
> for
> >>> >> >> >>> example page 105.
> >>> >> >> >>>
> >>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel knows
> >>> that
> >>> >> it
> >>> >> >> >>> should invoke that method.
> >>> >> >> >>> Its when you have 2+ methods it gets more complicated. You
> can
> >>> of
> >>> >> >> >>> course tell Camel the method name to use etc.
> >>> >> >> >>>
> >>> >> >> >>> But its all covered as well in chapter 4, as well you can
> find
> >>> >> pieces
> >>> >> >> >>> of details scattered online in the Camel docs.
> >>> >> >> >>>
> >>> >> >> >>>
> >>> >> >> >>> > Regards,
> >>> >> >> >>> > Jothi
> >>> >> >> >>> >
> >>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> >>> >> >> >>> > <ba...@swissonline.ch>wrote:
> >>> >> >> >>> >
> >>> >> >> >>> >> Check the documentation for this:
> >>> >> >> >>> >>
> >>> >> >> >>> >> http://camel.apache.org/bean-binding.html
> >>> >> >> >>> >>
> >>> >> >> >>> >> Babak
> >>> >> >> >>> >>
> >>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
> >>> >> codeintheopen@gmail.com
> >>> >> >> >:
> >>> >> >> >>> >>
> >>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My route
> >>> >> definition
> >>> >> >> >>> looks
> >>> >> >> >>> >> >like this:
> >>> >> >> >>> >> >
> >>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
> >>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
> >>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
> >>> >> >> >>> >> >            public void configure() {
> >>> >> >> >>> >> >
> >>>  from("file://my.xml").unmarshal(jaxb).bean(new
> >>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
> >>> >> >> >>> >> >            }
> >>> >> >> >>> >> >        });
> >>> >> >> >>> >> >
> >>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
> >>> >> Person.java)
> >>> >> >> >>> in my
> >>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing,
> how
> >>> does
> >>> >> >> Camel
> >>> >> >> >>> know
> >>> >> >> >>> >> >which method to invoke in that bean?
> >>> >> >> >>> >> >
> >>> >> >> >>> >> >Regards,
> >>> >> >> >>> >> >Jothi
> >>> >> >> >>> >> >
> >>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
> >>> >> codeintheopen@gmail.com>
> >>> >> >> >>> wrote:
> >>> >> >> >>> >> >
> >>> >> >> >>> >> >> Guys,
> >>> >> >> >>> >> >>
> >>> >> >> >>> >> >> I have a route which is defined as below:
> >>> >> >> >>> >> >>
> >>> >> >> >>> >> >>
> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
> >>> >> >> >>> >> >>
> >>> >> >> >>> >> >> All I want to do is access the my.xml in my
> ProcessorBean.
> >>> >> Where
> >>> >> >> >>> and how
> >>> >> >> >>> >> >> do I specify the Java object which will be filled with
> the
> >>> >> values
> >>> >> >> >>> in the
> >>> >> >> >>> >> >> xml file?
> >>> >> >> >>> >> >>
> >>> >> >> >>> >> >> Regards,
> >>> >> >> >>> >> >> Jothi
> >>> >> >> >>> >> >>
> >>> >> >> >>> >>
> >>> >> >> >>> >>
> >>> >> >> >>> >>
> >>> >> >> >>>
> >>> >> >> >>>
> >>> >> >> >>>
> >>> >> >> >>> --
> >>> >> >> >>> Claus Ibsen
> >>> >> >> >>> -----------------
> >>> >> >> >>> FuseSource
> >>> >> >> >>> Email: cibsen@fusesource.com
> >>> >> >> >>> Web: http://fusesource.com
> >>> >> >> >>> Twitter: davsclaus, fusenews
> >>> >> >> >>> Blog: http://davsclaus.com
> >>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >>> >> >> >>>
> >>> >> >> >>
> >>> >> >> >>
> >>> >> >>
> >>> >> >>
> >>> >> >>
> >>> >> >> --
> >>> >> >> Claus Ibsen
> >>> >> >> -----------------
> >>> >> >> FuseSource
> >>> >> >> Email: cibsen@fusesource.com
> >>> >> >> Web: http://fusesource.com
> >>> >> >> Twitter: davsclaus, fusenews
> >>> >> >> Blog: http://davsclaus.com
> >>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>> >> >>
> >>> >>
> >>> >>
> >>> >>
> >>> >> --
> >>> >> Claus Ibsen
> >>> >> -----------------
> >>> >> FuseSource
> >>> >> Email: cibsen@fusesource.com
> >>> >> Web: http://fusesource.com
> >>> >> Twitter: davsclaus, fusenews
> >>> >> Blog: http://davsclaus.com
> >>> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>> >>
> >>>
> >>>
> >>>
> >>> --
> >>> Claus Ibsen
> >>> -----------------
> >>> FuseSource
> >>> Email: cibsen@fusesource.com
> >>> Web: http://fusesource.com
> >>> Twitter: davsclaus, fusenews
> >>> Blog: http://davsclaus.com
> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >>>
> >>
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Aug 17, 2012 at 10:46 AM, Joe San <co...@gmail.com> wrote:
> So here comes the next bump!
>
> javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
> ObjectFactory.class or jaxb.index
>
> Do I have to add a jaxb.index file to my package?
>

Yes, see for example p77 in Camel in Action book.
Or google a bit on how to use JAXB with Java.

Basically you need to drop a jaxb.index file in the JAR with your JAXB
annotated classes.
The file should contain a line per class that has JAXB annotations.



> Regards,
> Jothi
>
> On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com> wrote:
>
>> Just managed to get rid of this issue and I was about to post my solution
>> and saw your message. Added the following as a dependency and it worked!
>>
>>     <dependency>
>>         <groupId>org.slf4j</groupId>
>>         <artifactId>slf4j-api</artifactId>
>>         <version>1.6.6</version>
>>     </dependency>
>>
>> Regards,
>> Jothi
>>
>>
>> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <cl...@gmail.com>wrote:
>>
>>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com>
>>> wrote:
>>> > I've tried to get rid of this issue but unfortunately could not. What I
>>> do
>>> > not understand is the following:
>>> >
>>> > The Error says:
>>> >
>>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> > org/slf4j/LoggerFactory
>>> >     at
>>> > org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >     at
>>> >
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>>> >
>>> > I have a dependency as:
>>> >
>>> >     <dependency>
>>> >         <groupId>org.slf4j</groupId>
>>> >         <artifactId>slf4j-log4j12</artifactId>
>>> >         <version>1.6.6</version>
>>> >     </dependency>
>>> >
>>> > When I checked the slf4j jar file, the package structure is different
>>> from
>>> > what the error says. There is no org.slf4j.LoggerFactory but rather
>>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>>> >
>>>
>>> And you got slf4j-api JAR as well? Its needed as dependency.
>>>
>>> > Regards,
>>> > Jothi
>>> >
>>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com>
>>> wrote:
>>> >
>>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com>
>>> wrote:
>>> >> > Even with the al4j-log4j dependecy added in the libraries, I get this
>>> >> error.
>>> >> >
>>> >>
>>> >> Are you sure they are on the classpath when you run the app form within
>>> >> Eclipse.
>>> >>
>>> >> And you may want to add slf4j-log4j12 or some other logging bridge so
>>> >> you can use log4j, or maybe some other log kit to log.
>>> >> Then you can see logs in the console in eclipse etc, if you configure
>>> >> logging to output to std out.
>>> >>
>>> >> If you create a new Camel project using the maven archetypes it does
>>> that.
>>> >> camel.apache.org/camel-maven-archetypes.html
>>> >>
>>> >> Or see some of the Camel examples in the examples dir
>>> >>
>>> >>
>>> >>
>>> >> > Regards,
>>> >> > Jothi
>>> >> >
>>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com>
>>> >> wrote:
>>> >> >
>>> >> >> Hi
>>> >> >>
>>> >> >> See this FAQ
>>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com>
>>> >> wrote:
>>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>>> >> >> > org/slf4j/LoggerFactory
>>> >> >> >     at
>>> >> >> >
>>> >>
>>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>>> >> >> >     at
>>> >> >> >
>>> >>
>>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>>> >> >> > Caused by: java.lang.ClassNotFoundException:
>>> org.slf4j.LoggerFactory
>>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>>> >> >> >     at java.security.AccessController.doPrivileged(Native Method)
>>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>>> >> >> >     ... 2 more
>>> >> >> >
>>> >> >> > My simple route fails with the above exception. All I have in my
>>> >> pom.xml
>>> >> >> > defined is:
>>> >> >> >
>>> >> >> >     <dependency>
>>> >> >> >         <groupId>org.apache.camel</groupId>
>>> >> >> >         <artifactId>camel-core</artifactId>
>>> >> >> >         <version>2.9.2</version>
>>> >> >> >     </dependency>
>>> >> >> >     <dependency>
>>> >> >> >       <groupId>org.apache.camel</groupId>
>>> >> >> >       <artifactId>camel-jaxb</artifactId>
>>> >> >> >       <version>2.9.2</version>
>>> >> >> >     </dependency>
>>> >> >> >
>>> >> >> > Do I need additional dependencies to be added other than this?
>>> >> >> >
>>> >> >> > Regards,
>>> >> >> > Jothi
>>> >> >> >
>>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <codeintheopen@gmail.com
>>> >
>>> >> >> wrote:
>>> >> >> >
>>> >> >> >> I just found that out from Chapter 4. I would have expected this
>>> hint
>>> >> >> that
>>> >> >> >> "when the bean has only one method, camel invokes it
>>> automagically
>>> >> >> without
>>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>>> >> >> >>
>>> >> >> >> Regards,
>>> >> >> >> Jothi
>>> >> >> >>
>>> >> >> >>
>>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>>> claus.ibsen@gmail.com
>>> >> >> >wrote:
>>> >> >> >>
>>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>>> codeintheopen@gmail.com>
>>> >> >> wrote:
>>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>>> question
>>> >> got
>>> >> >> >>> > clarified once I had a look into the documentation.
>>> >> >> >>> >
>>> >> >> >>> > From the Camel in Action book:
>>> >> >> >>> >
>>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>>> >> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
>>> >> >> >>> > .bean(new OrderToCsvBean())
>>> >> >> >>> >
>>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>> >> >> >>> >
>>> >> >> >>> > How does Camel know which method in the OrderToCsvBean()
>>> class to
>>> >> >> >>> invoke.
>>> >> >> >>> > Unfortunately the book does not mentions this in Chapter 3.
>>> Not
>>> >> sure
>>> >> >> if
>>> >> >> >>> it
>>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>>> >> >> >>> >
>>> >> >> >>>
>>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
>>> >> >> >>> example page 105.
>>> >> >> >>>
>>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel knows
>>> that
>>> >> it
>>> >> >> >>> should invoke that method.
>>> >> >> >>> Its when you have 2+ methods it gets more complicated. You can
>>> of
>>> >> >> >>> course tell Camel the method name to use etc.
>>> >> >> >>>
>>> >> >> >>> But its all covered as well in chapter 4, as well you can find
>>> >> pieces
>>> >> >> >>> of details scattered online in the Camel docs.
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> > Regards,
>>> >> >> >>> > Jothi
>>> >> >> >>> >
>>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>> >> >> >>> > <ba...@swissonline.ch>wrote:
>>> >> >> >>> >
>>> >> >> >>> >> Check the documentation for this:
>>> >> >> >>> >>
>>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>>> >> >> >>> >>
>>> >> >> >>> >> Babak
>>> >> >> >>> >>
>>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>>> >> codeintheopen@gmail.com
>>> >> >> >:
>>> >> >> >>> >>
>>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My route
>>> >> definition
>>> >> >> >>> looks
>>> >> >> >>> >> >like this:
>>> >> >> >>> >> >
>>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>>> >> >> >>> >> >            public void configure() {
>>> >> >> >>> >> >
>>>  from("file://my.xml").unmarshal(jaxb).bean(new
>>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>>> >> >> >>> >> >            }
>>> >> >> >>> >> >        });
>>> >> >> >>> >> >
>>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
>>> >> Person.java)
>>> >> >> >>> in my
>>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how
>>> does
>>> >> >> Camel
>>> >> >> >>> know
>>> >> >> >>> >> >which method to invoke in that bean?
>>> >> >> >>> >> >
>>> >> >> >>> >> >Regards,
>>> >> >> >>> >> >Jothi
>>> >> >> >>> >> >
>>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>>> >> codeintheopen@gmail.com>
>>> >> >> >>> wrote:
>>> >> >> >>> >> >
>>> >> >> >>> >> >> Guys,
>>> >> >> >>> >> >>
>>> >> >> >>> >> >> I have a route which is defined as below:
>>> >> >> >>> >> >>
>>> >> >> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>>> >> >> >>> >> >>
>>> >> >> >>> >> >> All I want to do is access the my.xml in my ProcessorBean.
>>> >> Where
>>> >> >> >>> and how
>>> >> >> >>> >> >> do I specify the Java object which will be filled with the
>>> >> values
>>> >> >> >>> in the
>>> >> >> >>> >> >> xml file?
>>> >> >> >>> >> >>
>>> >> >> >>> >> >> Regards,
>>> >> >> >>> >> >> Jothi
>>> >> >> >>> >> >>
>>> >> >> >>> >>
>>> >> >> >>> >>
>>> >> >> >>> >>
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>>
>>> >> >> >>> --
>>> >> >> >>> Claus Ibsen
>>> >> >> >>> -----------------
>>> >> >> >>> FuseSource
>>> >> >> >>> Email: cibsen@fusesource.com
>>> >> >> >>> Web: http://fusesource.com
>>> >> >> >>> Twitter: davsclaus, fusenews
>>> >> >> >>> Blog: http://davsclaus.com
>>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >> >>>
>>> >> >> >>
>>> >> >> >>
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> --
>>> >> >> Claus Ibsen
>>> >> >> -----------------
>>> >> >> FuseSource
>>> >> >> Email: cibsen@fusesource.com
>>> >> >> Web: http://fusesource.com
>>> >> >> Twitter: davsclaus, fusenews
>>> >> >> Blog: http://davsclaus.com
>>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >> >>
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> -----------------
>>> >> FuseSource
>>> >> Email: cibsen@fusesource.com
>>> >> Web: http://fusesource.com
>>> >> Twitter: davsclaus, fusenews
>>> >> Blog: http://davsclaus.com
>>> >> Author of Camel in Action: http://www.manning.com/ibsen
>>> >>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: cibsen@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>
>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
So here comes the next bump!

javax.xml.bind.JAXBException: "com.example.filexml" doesnt contain
ObjectFactory.class or jaxb.index

Do I have to add a jaxb.index file to my package?

Regards,
Jothi

On Fri, Aug 17, 2012 at 10:24 AM, Joe San <co...@gmail.com> wrote:

> Just managed to get rid of this issue and I was about to post my solution
> and saw your message. Added the following as a dependency and it worked!
>
>     <dependency>
>         <groupId>org.slf4j</groupId>
>         <artifactId>slf4j-api</artifactId>
>         <version>1.6.6</version>
>     </dependency>
>
> Regards,
> Jothi
>
>
> On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <cl...@gmail.com>wrote:
>
>> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com>
>> wrote:
>> > I've tried to get rid of this issue but unfortunately could not. What I
>> do
>> > not understand is the following:
>> >
>> > The Error says:
>> >
>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> > org/slf4j/LoggerFactory
>> >     at
>> > org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >     at
>> >
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>> >
>> > I have a dependency as:
>> >
>> >     <dependency>
>> >         <groupId>org.slf4j</groupId>
>> >         <artifactId>slf4j-log4j12</artifactId>
>> >         <version>1.6.6</version>
>> >     </dependency>
>> >
>> > When I checked the slf4j jar file, the package structure is different
>> from
>> > what the error says. There is no org.slf4j.LoggerFactory but rather
>> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>> >
>>
>> And you got slf4j-api JAR as well? Its needed as dependency.
>>
>> > Regards,
>> > Jothi
>> >
>> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com>
>> wrote:
>> >> > Even with the al4j-log4j dependecy added in the libraries, I get this
>> >> error.
>> >> >
>> >>
>> >> Are you sure they are on the classpath when you run the app form within
>> >> Eclipse.
>> >>
>> >> And you may want to add slf4j-log4j12 or some other logging bridge so
>> >> you can use log4j, or maybe some other log kit to log.
>> >> Then you can see logs in the console in eclipse etc, if you configure
>> >> logging to output to std out.
>> >>
>> >> If you create a new Camel project using the maven archetypes it does
>> that.
>> >> camel.apache.org/camel-maven-archetypes.html
>> >>
>> >> Or see some of the Camel examples in the examples dir
>> >>
>> >>
>> >>
>> >> > Regards,
>> >> > Jothi
>> >> >
>> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com>
>> >> wrote:
>> >> >
>> >> >> Hi
>> >> >>
>> >> >> See this FAQ
>> >> >> http://camel.apache.org/what-jars-do-i-need.html
>> >> >>
>> >> >>
>> >> >>
>> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com>
>> >> wrote:
>> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >> >> > org/slf4j/LoggerFactory
>> >> >> >     at
>> >> >> >
>> >>
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >> >> >     at
>> >> >> >
>> >>
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >> >> > Caused by: java.lang.ClassNotFoundException:
>> org.slf4j.LoggerFactory
>> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>> >> >> >     at java.security.AccessController.doPrivileged(Native Method)
>> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >> >> >     ... 2 more
>> >> >> >
>> >> >> > My simple route fails with the above exception. All I have in my
>> >> pom.xml
>> >> >> > defined is:
>> >> >> >
>> >> >> >     <dependency>
>> >> >> >         <groupId>org.apache.camel</groupId>
>> >> >> >         <artifactId>camel-core</artifactId>
>> >> >> >         <version>2.9.2</version>
>> >> >> >     </dependency>
>> >> >> >     <dependency>
>> >> >> >       <groupId>org.apache.camel</groupId>
>> >> >> >       <artifactId>camel-jaxb</artifactId>
>> >> >> >       <version>2.9.2</version>
>> >> >> >     </dependency>
>> >> >> >
>> >> >> > Do I need additional dependencies to be added other than this?
>> >> >> >
>> >> >> > Regards,
>> >> >> > Jothi
>> >> >> >
>> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <codeintheopen@gmail.com
>> >
>> >> >> wrote:
>> >> >> >
>> >> >> >> I just found that out from Chapter 4. I would have expected this
>> hint
>> >> >> that
>> >> >> >> "when the bean has only one method, camel invokes it
>> automagically
>> >> >> without
>> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
>> >> >> >>
>> >> >> >> Regards,
>> >> >> >> Jothi
>> >> >> >>
>> >> >> >>
>> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
>> claus.ibsen@gmail.com
>> >> >> >wrote:
>> >> >> >>
>> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
>> codeintheopen@gmail.com>
>> >> >> wrote:
>> >> >> >>> > Thanks for pointing me to toe documentation. My actual
>> question
>> >> got
>> >> >> >>> > clarified once I had a look into the documentation.
>> >> >> >>> >
>> >> >> >>> > From the Camel in Action book:
>> >> >> >>> >
>> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>> >> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
>> >> >> >>> > .bean(new OrderToCsvBean())
>> >> >> >>> >
>> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >> >> >>> >
>> >> >> >>> > How does Camel know which method in the OrderToCsvBean()
>> class to
>> >> >> >>> invoke.
>> >> >> >>> > Unfortunately the book does not mentions this in Chapter 3.
>> Not
>> >> sure
>> >> >> if
>> >> >> >>> it
>> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>> >> >> >>> >
>> >> >> >>>
>> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
>> >> >> >>> example page 105.
>> >> >> >>>
>> >> >> >>> But basically if the pojo/bean has 1 method, then Camel knows
>> that
>> >> it
>> >> >> >>> should invoke that method.
>> >> >> >>> Its when you have 2+ methods it gets more complicated. You can
>> of
>> >> >> >>> course tell Camel the method name to use etc.
>> >> >> >>>
>> >> >> >>> But its all covered as well in chapter 4, as well you can find
>> >> pieces
>> >> >> >>> of details scattered online in the Camel docs.
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> > Regards,
>> >> >> >>> > Jothi
>> >> >> >>> >
>> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> >> >> >>> > <ba...@swissonline.ch>wrote:
>> >> >> >>> >
>> >> >> >>> >> Check the documentation for this:
>> >> >> >>> >>
>> >> >> >>> >> http://camel.apache.org/bean-binding.html
>> >> >> >>> >>
>> >> >> >>> >> Babak
>> >> >> >>> >>
>> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>> >> codeintheopen@gmail.com
>> >> >> >:
>> >> >> >>> >>
>> >> >> >>> >> >I have decided to use JAXB instead of xStream. My route
>> >> definition
>> >> >> >>> looks
>> >> >> >>> >> >like this:
>> >> >> >>> >> >
>> >> >> >>> >> >        final JaxbDataFormat jaxb = new
>> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
>> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>> >> >> >>> >> >            public void configure() {
>> >> >> >>> >> >
>>  from("file://my.xml").unmarshal(jaxb).bean(new
>> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
>> >> >> >>> >> >            }
>> >> >> >>> >> >        });
>> >> >> >>> >> >
>> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
>> >> Person.java)
>> >> >> >>> in my
>> >> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how
>> does
>> >> >> Camel
>> >> >> >>> know
>> >> >> >>> >> >which method to invoke in that bean?
>> >> >> >>> >> >
>> >> >> >>> >> >Regards,
>> >> >> >>> >> >Jothi
>> >> >> >>> >> >
>> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>> >> codeintheopen@gmail.com>
>> >> >> >>> wrote:
>> >> >> >>> >> >
>> >> >> >>> >> >> Guys,
>> >> >> >>> >> >>
>> >> >> >>> >> >> I have a route which is defined as below:
>> >> >> >>> >> >>
>> >> >> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>> >> >> >>> >> >>
>> >> >> >>> >> >> All I want to do is access the my.xml in my ProcessorBean.
>> >> Where
>> >> >> >>> and how
>> >> >> >>> >> >> do I specify the Java object which will be filled with the
>> >> values
>> >> >> >>> in the
>> >> >> >>> >> >> xml file?
>> >> >> >>> >> >>
>> >> >> >>> >> >> Regards,
>> >> >> >>> >> >> Jothi
>> >> >> >>> >> >>
>> >> >> >>> >>
>> >> >> >>> >>
>> >> >> >>> >>
>> >> >> >>>
>> >> >> >>>
>> >> >> >>>
>> >> >> >>> --
>> >> >> >>> Claus Ibsen
>> >> >> >>> -----------------
>> >> >> >>> FuseSource
>> >> >> >>> Email: cibsen@fusesource.com
>> >> >> >>> Web: http://fusesource.com
>> >> >> >>> Twitter: davsclaus, fusenews
>> >> >> >>> Blog: http://davsclaus.com
>> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >> >>>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Claus Ibsen
>> >> >> -----------------
>> >> >> FuseSource
>> >> >> Email: cibsen@fusesource.com
>> >> >> Web: http://fusesource.com
>> >> >> Twitter: davsclaus, fusenews
>> >> >> Blog: http://davsclaus.com
>> >> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >>
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> -----------------
>> >> FuseSource
>> >> Email: cibsen@fusesource.com
>> >> Web: http://fusesource.com
>> >> Twitter: davsclaus, fusenews
>> >> Blog: http://davsclaus.com
>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Just managed to get rid of this issue and I was about to post my solution
and saw your message. Added the following as a dependency and it worked!

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.6</version>
    </dependency>

Regards,
Jothi

On Fri, Aug 17, 2012 at 10:18 AM, Claus Ibsen <cl...@gmail.com> wrote:

> On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com> wrote:
> > I've tried to get rid of this issue but unfortunately could not. What I
> do
> > not understand is the following:
> >
> > The Error says:
> >
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/slf4j/LoggerFactory
> >     at
> > org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >     at
> > org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
> >
> > I have a dependency as:
> >
> >     <dependency>
> >         <groupId>org.slf4j</groupId>
> >         <artifactId>slf4j-log4j12</artifactId>
> >         <version>1.6.6</version>
> >     </dependency>
> >
> > When I checked the slf4j jar file, the package structure is different
> from
> > what the error says. There is no org.slf4j.LoggerFactory but rather
> > org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
> >
>
> And you got slf4j-api JAR as well? Its needed as dependency.
>
> > Regards,
> > Jothi
> >
> > On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com>
> wrote:
> >> > Even with the al4j-log4j dependecy added in the libraries, I get this
> >> error.
> >> >
> >>
> >> Are you sure they are on the classpath when you run the app form within
> >> Eclipse.
> >>
> >> And you may want to add slf4j-log4j12 or some other logging bridge so
> >> you can use log4j, or maybe some other log kit to log.
> >> Then you can see logs in the console in eclipse etc, if you configure
> >> logging to output to std out.
> >>
> >> If you create a new Camel project using the maven archetypes it does
> that.
> >> camel.apache.org/camel-maven-archetypes.html
> >>
> >> Or see some of the Camel examples in the examples dir
> >>
> >>
> >>
> >> > Regards,
> >> > Jothi
> >> >
> >> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com>
> >> wrote:
> >> >
> >> >> Hi
> >> >>
> >> >> See this FAQ
> >> >> http://camel.apache.org/what-jars-do-i-need.html
> >> >>
> >> >>
> >> >>
> >> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com>
> >> wrote:
> >> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >> >> > org/slf4j/LoggerFactory
> >> >> >     at
> >> >> >
> >> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >> >> >     at
> >> >> >
> >>
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >> >> > Caused by: java.lang.ClassNotFoundException:
> org.slf4j.LoggerFactory
> >> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
> >> >> >     at java.security.AccessController.doPrivileged(Native Method)
> >> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> >> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >> >> >     ... 2 more
> >> >> >
> >> >> > My simple route fails with the above exception. All I have in my
> >> pom.xml
> >> >> > defined is:
> >> >> >
> >> >> >     <dependency>
> >> >> >         <groupId>org.apache.camel</groupId>
> >> >> >         <artifactId>camel-core</artifactId>
> >> >> >         <version>2.9.2</version>
> >> >> >     </dependency>
> >> >> >     <dependency>
> >> >> >       <groupId>org.apache.camel</groupId>
> >> >> >       <artifactId>camel-jaxb</artifactId>
> >> >> >       <version>2.9.2</version>
> >> >> >     </dependency>
> >> >> >
> >> >> > Do I need additional dependencies to be added other than this?
> >> >> >
> >> >> > Regards,
> >> >> > Jothi
> >> >> >
> >> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com>
> >> >> wrote:
> >> >> >
> >> >> >> I just found that out from Chapter 4. I would have expected this
> hint
> >> >> that
> >> >> >> "when the bean has only one method, camel invokes it automagically
> >> >> without
> >> >> >> having to explicitly specifying it" in Chapter 3 itself.
> >> >> >>
> >> >> >> Regards,
> >> >> >> Jothi
> >> >> >>
> >> >> >>
> >> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <
> claus.ibsen@gmail.com
> >> >> >wrote:
> >> >> >>
> >> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <
> codeintheopen@gmail.com>
> >> >> wrote:
> >> >> >>> > Thanks for pointing me to toe documentation. My actual question
> >> got
> >> >> >>> > clarified once I had a look into the documentation.
> >> >> >>> >
> >> >> >>> > From the Camel in Action book:
> >> >> >>> >
> >> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
> >> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
> >> >> >>> > .bean(new OrderToCsvBean())
> >> >> >>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >> >> >>> >
> >> >> >>> > How does Camel know which method in the OrderToCsvBean() class
> to
> >> >> >>> invoke.
> >> >> >>> > Unfortunately the book does not mentions this in Chapter 3. Not
> >> sure
> >> >> if
> >> >> >>> it
> >> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
> >> >> >>> >
> >> >> >>>
> >> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
> >> >> >>> example page 105.
> >> >> >>>
> >> >> >>> But basically if the pojo/bean has 1 method, then Camel knows
> that
> >> it
> >> >> >>> should invoke that method.
> >> >> >>> Its when you have 2+ methods it gets more complicated. You can of
> >> >> >>> course tell Camel the method name to use etc.
> >> >> >>>
> >> >> >>> But its all covered as well in chapter 4, as well you can find
> >> pieces
> >> >> >>> of details scattered online in the Camel docs.
> >> >> >>>
> >> >> >>>
> >> >> >>> > Regards,
> >> >> >>> > Jothi
> >> >> >>> >
> >> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> >> >> >>> > <ba...@swissonline.ch>wrote:
> >> >> >>> >
> >> >> >>> >> Check the documentation for this:
> >> >> >>> >>
> >> >> >>> >> http://camel.apache.org/bean-binding.html
> >> >> >>> >>
> >> >> >>> >> Babak
> >> >> >>> >>
> >> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
> >> codeintheopen@gmail.com
> >> >> >:
> >> >> >>> >>
> >> >> >>> >> >I have decided to use JAXB instead of xStream. My route
> >> definition
> >> >> >>> looks
> >> >> >>> >> >like this:
> >> >> >>> >> >
> >> >> >>> >> >        final JaxbDataFormat jaxb = new
> >> >> >>> >> >JaxbDataFormat("com.example.filexml");
> >> >> >>> >> >        context.addRoutes(new RouteBuilder() {
> >> >> >>> >> >            public void configure() {
> >> >> >>> >> >
>  from("file://my.xml").unmarshal(jaxb).bean(new
> >> >> >>> >> >ProcessorBean()).to("file://my.xml");
> >> >> >>> >> >            }
> >> >> >>> >> >        });
> >> >> >>> >> >
> >> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
> >> Person.java)
> >> >> >>> in my
> >> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how
> does
> >> >> Camel
> >> >> >>> know
> >> >> >>> >> >which method to invoke in that bean?
> >> >> >>> >> >
> >> >> >>> >> >Regards,
> >> >> >>> >> >Jothi
> >> >> >>> >> >
> >> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
> >> codeintheopen@gmail.com>
> >> >> >>> wrote:
> >> >> >>> >> >
> >> >> >>> >> >> Guys,
> >> >> >>> >> >>
> >> >> >>> >> >> I have a route which is defined as below:
> >> >> >>> >> >>
> >> >> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >> >> >>> >> >> ProcessorBean()).to("file://my.xml");
> >> >> >>> >> >>
> >> >> >>> >> >> All I want to do is access the my.xml in my ProcessorBean.
> >> Where
> >> >> >>> and how
> >> >> >>> >> >> do I specify the Java object which will be filled with the
> >> values
> >> >> >>> in the
> >> >> >>> >> >> xml file?
> >> >> >>> >> >>
> >> >> >>> >> >> Regards,
> >> >> >>> >> >> Jothi
> >> >> >>> >> >>
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>> >>
> >> >> >>>
> >> >> >>>
> >> >> >>>
> >> >> >>> --
> >> >> >>> Claus Ibsen
> >> >> >>> -----------------
> >> >> >>> FuseSource
> >> >> >>> Email: cibsen@fusesource.com
> >> >> >>> Web: http://fusesource.com
> >> >> >>> Twitter: davsclaus, fusenews
> >> >> >>> Blog: http://davsclaus.com
> >> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >> >> >>>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Claus Ibsen
> >> >> -----------------
> >> >> FuseSource
> >> >> Email: cibsen@fusesource.com
> >> >> Web: http://fusesource.com
> >> >> Twitter: davsclaus, fusenews
> >> >> Blog: http://davsclaus.com
> >> >> Author of Camel in Action: http://www.manning.com/ibsen
> >> >>
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus, fusenews
> >> Blog: http://davsclaus.com
> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Aug 17, 2012 at 10:06 AM, Joe San <co...@gmail.com> wrote:
> I've tried to get rid of this issue but unfortunately could not. What I do
> not understand is the following:
>
> The Error says:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/slf4j/LoggerFactory
>     at
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>     at
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>
> I have a dependency as:
>
>     <dependency>
>         <groupId>org.slf4j</groupId>
>         <artifactId>slf4j-log4j12</artifactId>
>         <version>1.6.6</version>
>     </dependency>
>
> When I checked the slf4j jar file, the package structure is different from
> what the error says. There is no org.slf4j.LoggerFactory but rather
> org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?
>

And you got slf4j-api JAR as well? Its needed as dependency.

> Regards,
> Jothi
>
> On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com> wrote:
>> > Even with the al4j-log4j dependecy added in the libraries, I get this
>> error.
>> >
>>
>> Are you sure they are on the classpath when you run the app form within
>> Eclipse.
>>
>> And you may want to add slf4j-log4j12 or some other logging bridge so
>> you can use log4j, or maybe some other log kit to log.
>> Then you can see logs in the console in eclipse etc, if you configure
>> logging to output to std out.
>>
>> If you create a new Camel project using the maven archetypes it does that.
>> camel.apache.org/camel-maven-archetypes.html
>>
>> Or see some of the Camel examples in the examples dir
>>
>>
>>
>> > Regards,
>> > Jothi
>> >
>> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> Hi
>> >>
>> >> See this FAQ
>> >> http://camel.apache.org/what-jars-do-i-need.html
>> >>
>> >>
>> >>
>> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com>
>> wrote:
>> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> >> > org/slf4j/LoggerFactory
>> >> >     at
>> >> >
>> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >> >     at
>> >> >
>> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> >> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
>> >> >     at java.security.AccessController.doPrivileged(Native Method)
>> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
>> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >> >     ... 2 more
>> >> >
>> >> > My simple route fails with the above exception. All I have in my
>> pom.xml
>> >> > defined is:
>> >> >
>> >> >     <dependency>
>> >> >         <groupId>org.apache.camel</groupId>
>> >> >         <artifactId>camel-core</artifactId>
>> >> >         <version>2.9.2</version>
>> >> >     </dependency>
>> >> >     <dependency>
>> >> >       <groupId>org.apache.camel</groupId>
>> >> >       <artifactId>camel-jaxb</artifactId>
>> >> >       <version>2.9.2</version>
>> >> >     </dependency>
>> >> >
>> >> > Do I need additional dependencies to be added other than this?
>> >> >
>> >> > Regards,
>> >> > Jothi
>> >> >
>> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com>
>> >> wrote:
>> >> >
>> >> >> I just found that out from Chapter 4. I would have expected this hint
>> >> that
>> >> >> "when the bean has only one method, camel invokes it automagically
>> >> without
>> >> >> having to explicitly specifying it" in Chapter 3 itself.
>> >> >>
>> >> >> Regards,
>> >> >> Jothi
>> >> >>
>> >> >>
>> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <claus.ibsen@gmail.com
>> >> >wrote:
>> >> >>
>> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com>
>> >> wrote:
>> >> >>> > Thanks for pointing me to toe documentation. My actual question
>> got
>> >> >>> > clarified once I had a look into the documentation.
>> >> >>> >
>> >> >>> > From the Camel in Action book:
>> >> >>> >
>> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
>> >> >>> > .bean(new OrderToCsvBean())
>> >> >>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >> >>> >
>> >> >>> > How does Camel know which method in the OrderToCsvBean() class to
>> >> >>> invoke.
>> >> >>> > Unfortunately the book does not mentions this in Chapter 3. Not
>> sure
>> >> if
>> >> >>> it
>> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>> >> >>> >
>> >> >>>
>> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
>> >> >>> example page 105.
>> >> >>>
>> >> >>> But basically if the pojo/bean has 1 method, then Camel knows that
>> it
>> >> >>> should invoke that method.
>> >> >>> Its when you have 2+ methods it gets more complicated. You can of
>> >> >>> course tell Camel the method name to use etc.
>> >> >>>
>> >> >>> But its all covered as well in chapter 4, as well you can find
>> pieces
>> >> >>> of details scattered online in the Camel docs.
>> >> >>>
>> >> >>>
>> >> >>> > Regards,
>> >> >>> > Jothi
>> >> >>> >
>> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> >> >>> > <ba...@swissonline.ch>wrote:
>> >> >>> >
>> >> >>> >> Check the documentation for this:
>> >> >>> >>
>> >> >>> >> http://camel.apache.org/bean-binding.html
>> >> >>> >>
>> >> >>> >> Babak
>> >> >>> >>
>> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
>> codeintheopen@gmail.com
>> >> >:
>> >> >>> >>
>> >> >>> >> >I have decided to use JAXB instead of xStream. My route
>> definition
>> >> >>> looks
>> >> >>> >> >like this:
>> >> >>> >> >
>> >> >>> >> >        final JaxbDataFormat jaxb = new
>> >> >>> >> >JaxbDataFormat("com.example.filexml");
>> >> >>> >> >        context.addRoutes(new RouteBuilder() {
>> >> >>> >> >            public void configure() {
>> >> >>> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
>> >> >>> >> >ProcessorBean()).to("file://my.xml");
>> >> >>> >> >            }
>> >> >>> >> >        });
>> >> >>> >> >
>> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
>> Person.java)
>> >> >>> in my
>> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how does
>> >> Camel
>> >> >>> know
>> >> >>> >> >which method to invoke in that bean?
>> >> >>> >> >
>> >> >>> >> >Regards,
>> >> >>> >> >Jothi
>> >> >>> >> >
>> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
>> codeintheopen@gmail.com>
>> >> >>> wrote:
>> >> >>> >> >
>> >> >>> >> >> Guys,
>> >> >>> >> >>
>> >> >>> >> >> I have a route which is defined as below:
>> >> >>> >> >>
>> >> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >> >>> >> >> ProcessorBean()).to("file://my.xml");
>> >> >>> >> >>
>> >> >>> >> >> All I want to do is access the my.xml in my ProcessorBean.
>> Where
>> >> >>> and how
>> >> >>> >> >> do I specify the Java object which will be filled with the
>> values
>> >> >>> in the
>> >> >>> >> >> xml file?
>> >> >>> >> >>
>> >> >>> >> >> Regards,
>> >> >>> >> >> Jothi
>> >> >>> >> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>> >>
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> --
>> >> >>> Claus Ibsen
>> >> >>> -----------------
>> >> >>> FuseSource
>> >> >>> Email: cibsen@fusesource.com
>> >> >>> Web: http://fusesource.com
>> >> >>> Twitter: davsclaus, fusenews
>> >> >>> Blog: http://davsclaus.com
>> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >> >>>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> -----------------
>> >> FuseSource
>> >> Email: cibsen@fusesource.com
>> >> Web: http://fusesource.com
>> >> Twitter: davsclaus, fusenews
>> >> Blog: http://davsclaus.com
>> >> Author of Camel in Action: http://www.manning.com/ibsen
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
I've tried to get rid of this issue but unfortunately could not. What I do
not understand is the following:

The Error says:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory
    at
org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
    at
org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory

I have a dependency as:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.6</version>
    </dependency>

When I checked the slf4j jar file, the package structure is different from
what the error says. There is no org.slf4j.LoggerFactory but rather
org\slf4j\impl\Log4jLoggerFactory. Am I using wrong libraries?

Regards,
Jothi

On Thu, Aug 16, 2012 at 5:37 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com> wrote:
> > Even with the al4j-log4j dependecy added in the libraries, I get this
> error.
> >
>
> Are you sure they are on the classpath when you run the app form within
> Eclipse.
>
> And you may want to add slf4j-log4j12 or some other logging bridge so
> you can use log4j, or maybe some other log kit to log.
> Then you can see logs in the console in eclipse etc, if you configure
> logging to output to std out.
>
> If you create a new Camel project using the maven archetypes it does that.
> camel.apache.org/camel-maven-archetypes.html
>
> Or see some of the Camel examples in the examples dir
>
>
>
> > Regards,
> > Jothi
> >
> > On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> Hi
> >>
> >> See this FAQ
> >> http://camel.apache.org/what-jars-do-i-need.html
> >>
> >>
> >>
> >> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com>
> wrote:
> >> > Exception in thread "main" java.lang.NoClassDefFoundError:
> >> > org/slf4j/LoggerFactory
> >> >     at
> >> >
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >> >     at
> >> >
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> >> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
> >> >     at java.net.URLClassLoader$1.run(Unknown Source)
> >> >     at java.security.AccessController.doPrivileged(Native Method)
> >> >     at java.net.URLClassLoader.findClass(Unknown Source)
> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> >> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >> >     ... 2 more
> >> >
> >> > My simple route fails with the above exception. All I have in my
> pom.xml
> >> > defined is:
> >> >
> >> >     <dependency>
> >> >         <groupId>org.apache.camel</groupId>
> >> >         <artifactId>camel-core</artifactId>
> >> >         <version>2.9.2</version>
> >> >     </dependency>
> >> >     <dependency>
> >> >       <groupId>org.apache.camel</groupId>
> >> >       <artifactId>camel-jaxb</artifactId>
> >> >       <version>2.9.2</version>
> >> >     </dependency>
> >> >
> >> > Do I need additional dependencies to be added other than this?
> >> >
> >> > Regards,
> >> > Jothi
> >> >
> >> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com>
> >> wrote:
> >> >
> >> >> I just found that out from Chapter 4. I would have expected this hint
> >> that
> >> >> "when the bean has only one method, camel invokes it automagically
> >> without
> >> >> having to explicitly specifying it" in Chapter 3 itself.
> >> >>
> >> >> Regards,
> >> >> Jothi
> >> >>
> >> >>
> >> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <claus.ibsen@gmail.com
> >> >wrote:
> >> >>
> >> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com>
> >> wrote:
> >> >>> > Thanks for pointing me to toe documentation. My actual question
> got
> >> >>> > clarified once I had a look into the documentation.
> >> >>> >
> >> >>> > From the Camel in Action book:
> >> >>> >
> >> >>> > from("quartz://report?cron=0+0+6+*+*+?")
> >> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
> >> >>> > .bean(new OrderToCsvBean())
> >> >>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >> >>> >
> >> >>> > How does Camel know which method in the OrderToCsvBean() class to
> >> >>> invoke.
> >> >>> > Unfortunately the book does not mentions this in Chapter 3. Not
> sure
> >> if
> >> >>> it
> >> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
> >> >>> >
> >> >>>
> >> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
> >> >>> example page 105.
> >> >>>
> >> >>> But basically if the pojo/bean has 1 method, then Camel knows that
> it
> >> >>> should invoke that method.
> >> >>> Its when you have 2+ methods it gets more complicated. You can of
> >> >>> course tell Camel the method name to use etc.
> >> >>>
> >> >>> But its all covered as well in chapter 4, as well you can find
> pieces
> >> >>> of details scattered online in the Camel docs.
> >> >>>
> >> >>>
> >> >>> > Regards,
> >> >>> > Jothi
> >> >>> >
> >> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> >> >>> > <ba...@swissonline.ch>wrote:
> >> >>> >
> >> >>> >> Check the documentation for this:
> >> >>> >>
> >> >>> >> http://camel.apache.org/bean-binding.html
> >> >>> >>
> >> >>> >> Babak
> >> >>> >>
> >> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <
> codeintheopen@gmail.com
> >> >:
> >> >>> >>
> >> >>> >> >I have decided to use JAXB instead of xStream. My route
> definition
> >> >>> looks
> >> >>> >> >like this:
> >> >>> >> >
> >> >>> >> >        final JaxbDataFormat jaxb = new
> >> >>> >> >JaxbDataFormat("com.example.filexml");
> >> >>> >> >        context.addRoutes(new RouteBuilder() {
> >> >>> >> >            public void configure() {
> >> >>> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
> >> >>> >> >ProcessorBean()).to("file://my.xml");
> >> >>> >> >            }
> >> >>> >> >        });
> >> >>> >> >
> >> >>> >> >How do I get hold of the UnMarshalled Java Object (say
> Person.java)
> >> >>> in my
> >> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how does
> >> Camel
> >> >>> know
> >> >>> >> >which method to invoke in that bean?
> >> >>> >> >
> >> >>> >> >Regards,
> >> >>> >> >Jothi
> >> >>> >> >
> >> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <
> codeintheopen@gmail.com>
> >> >>> wrote:
> >> >>> >> >
> >> >>> >> >> Guys,
> >> >>> >> >>
> >> >>> >> >> I have a route which is defined as below:
> >> >>> >> >>
> >> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >> >>> >> >> ProcessorBean()).to("file://my.xml");
> >> >>> >> >>
> >> >>> >> >> All I want to do is access the my.xml in my ProcessorBean.
> Where
> >> >>> and how
> >> >>> >> >> do I specify the Java object which will be filled with the
> values
> >> >>> in the
> >> >>> >> >> xml file?
> >> >>> >> >>
> >> >>> >> >> Regards,
> >> >>> >> >> Jothi
> >> >>> >> >>
> >> >>> >>
> >> >>> >>
> >> >>> >>
> >> >>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Claus Ibsen
> >> >>> -----------------
> >> >>> FuseSource
> >> >>> Email: cibsen@fusesource.com
> >> >>> Web: http://fusesource.com
> >> >>> Twitter: davsclaus, fusenews
> >> >>> Blog: http://davsclaus.com
> >> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >> >>>
> >> >>
> >> >>
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus, fusenews
> >> Blog: http://davsclaus.com
> >> Author of Camel in Action: http://www.manning.com/ibsen
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 16, 2012 at 4:08 PM, Joe San <co...@gmail.com> wrote:
> Even with the al4j-log4j dependecy added in the libraries, I get this error.
>

Are you sure they are on the classpath when you run the app form within Eclipse.

And you may want to add slf4j-log4j12 or some other logging bridge so
you can use log4j, or maybe some other log kit to log.
Then you can see logs in the console in eclipse etc, if you configure
logging to output to std out.

If you create a new Camel project using the maven archetypes it does that.
camel.apache.org/camel-maven-archetypes.html

Or see some of the Camel examples in the examples dir



> Regards,
> Jothi
>
> On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> Hi
>>
>> See this FAQ
>> http://camel.apache.org/what-jars-do-i-need.html
>>
>>
>>
>> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com> wrote:
>> > Exception in thread "main" java.lang.NoClassDefFoundError:
>> > org/slf4j/LoggerFactory
>> >     at
>> > org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>> >     at
>> > org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
>> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>> >     at java.net.URLClassLoader$1.run(Unknown Source)
>> >     at java.security.AccessController.doPrivileged(Native Method)
>> >     at java.net.URLClassLoader.findClass(Unknown Source)
>> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> >     at java.lang.ClassLoader.loadClass(Unknown Source)
>> >     ... 2 more
>> >
>> > My simple route fails with the above exception. All I have in my pom.xml
>> > defined is:
>> >
>> >     <dependency>
>> >         <groupId>org.apache.camel</groupId>
>> >         <artifactId>camel-core</artifactId>
>> >         <version>2.9.2</version>
>> >     </dependency>
>> >     <dependency>
>> >       <groupId>org.apache.camel</groupId>
>> >       <artifactId>camel-jaxb</artifactId>
>> >       <version>2.9.2</version>
>> >     </dependency>
>> >
>> > Do I need additional dependencies to be added other than this?
>> >
>> > Regards,
>> > Jothi
>> >
>> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com>
>> wrote:
>> >
>> >> I just found that out from Chapter 4. I would have expected this hint
>> that
>> >> "when the bean has only one method, camel invokes it automagically
>> without
>> >> having to explicitly specifying it" in Chapter 3 itself.
>> >>
>> >> Regards,
>> >> Jothi
>> >>
>> >>
>> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <claus.ibsen@gmail.com
>> >wrote:
>> >>
>> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com>
>> wrote:
>> >>> > Thanks for pointing me to toe documentation. My actual question got
>> >>> > clarified once I had a look into the documentation.
>> >>> >
>> >>> > From the Camel in Action book:
>> >>> >
>> >>> > from("quartz://report?cron=0+0+6+*+*+?")
>> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
>> >>> > .bean(new OrderToCsvBean())
>> >>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >>> >
>> >>> > How does Camel know which method in the OrderToCsvBean() class to
>> >>> invoke.
>> >>> > Unfortunately the book does not mentions this in Chapter 3. Not sure
>> if
>> >>> it
>> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>> >>> >
>> >>>
>> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
>> >>> example page 105.
>> >>>
>> >>> But basically if the pojo/bean has 1 method, then Camel knows that it
>> >>> should invoke that method.
>> >>> Its when you have 2+ methods it gets more complicated. You can of
>> >>> course tell Camel the method name to use etc.
>> >>>
>> >>> But its all covered as well in chapter 4, as well you can find pieces
>> >>> of details scattered online in the Camel docs.
>> >>>
>> >>>
>> >>> > Regards,
>> >>> > Jothi
>> >>> >
>> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> >>> > <ba...@swissonline.ch>wrote:
>> >>> >
>> >>> >> Check the documentation for this:
>> >>> >>
>> >>> >> http://camel.apache.org/bean-binding.html
>> >>> >>
>> >>> >> Babak
>> >>> >>
>> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <codeintheopen@gmail.com
>> >:
>> >>> >>
>> >>> >> >I have decided to use JAXB instead of xStream. My route definition
>> >>> looks
>> >>> >> >like this:
>> >>> >> >
>> >>> >> >        final JaxbDataFormat jaxb = new
>> >>> >> >JaxbDataFormat("com.example.filexml");
>> >>> >> >        context.addRoutes(new RouteBuilder() {
>> >>> >> >            public void configure() {
>> >>> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
>> >>> >> >ProcessorBean()).to("file://my.xml");
>> >>> >> >            }
>> >>> >> >        });
>> >>> >> >
>> >>> >> >How do I get hold of the UnMarshalled Java Object (say Person.java)
>> >>> in my
>> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how does
>> Camel
>> >>> know
>> >>> >> >which method to invoke in that bean?
>> >>> >> >
>> >>> >> >Regards,
>> >>> >> >Jothi
>> >>> >> >
>> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com>
>> >>> wrote:
>> >>> >> >
>> >>> >> >> Guys,
>> >>> >> >>
>> >>> >> >> I have a route which is defined as below:
>> >>> >> >>
>> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >>> >> >> ProcessorBean()).to("file://my.xml");
>> >>> >> >>
>> >>> >> >> All I want to do is access the my.xml in my ProcessorBean. Where
>> >>> and how
>> >>> >> >> do I specify the Java object which will be filled with the values
>> >>> in the
>> >>> >> >> xml file?
>> >>> >> >>
>> >>> >> >> Regards,
>> >>> >> >> Jothi
>> >>> >> >>
>> >>> >>
>> >>> >>
>> >>> >>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Claus Ibsen
>> >>> -----------------
>> >>> FuseSource
>> >>> Email: cibsen@fusesource.com
>> >>> Web: http://fusesource.com
>> >>> Twitter: davsclaus, fusenews
>> >>> Blog: http://davsclaus.com
>> >>> Author of Camel in Action: http://www.manning.com/ibsen
>> >>>
>> >>
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Even with the al4j-log4j dependecy added in the libraries, I get this error.

Regards,
Jothi

On Thu, Aug 16, 2012 at 3:59 PM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> See this FAQ
> http://camel.apache.org/what-jars-do-i-need.html
>
>
>
> On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com> wrote:
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > org/slf4j/LoggerFactory
> >     at
> > org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
> >     at
> > org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> > Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
> >     at java.net.URLClassLoader$1.run(Unknown Source)
> >     at java.security.AccessController.doPrivileged(Native Method)
> >     at java.net.URLClassLoader.findClass(Unknown Source)
> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
> >     at java.lang.ClassLoader.loadClass(Unknown Source)
> >     ... 2 more
> >
> > My simple route fails with the above exception. All I have in my pom.xml
> > defined is:
> >
> >     <dependency>
> >         <groupId>org.apache.camel</groupId>
> >         <artifactId>camel-core</artifactId>
> >         <version>2.9.2</version>
> >     </dependency>
> >     <dependency>
> >       <groupId>org.apache.camel</groupId>
> >       <artifactId>camel-jaxb</artifactId>
> >       <version>2.9.2</version>
> >     </dependency>
> >
> > Do I need additional dependencies to be added other than this?
> >
> > Regards,
> > Jothi
> >
> > On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com>
> wrote:
> >
> >> I just found that out from Chapter 4. I would have expected this hint
> that
> >> "when the bean has only one method, camel invokes it automagically
> without
> >> having to explicitly specifying it" in Chapter 3 itself.
> >>
> >> Regards,
> >> Jothi
> >>
> >>
> >> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <claus.ibsen@gmail.com
> >wrote:
> >>
> >>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com>
> wrote:
> >>> > Thanks for pointing me to toe documentation. My actual question got
> >>> > clarified once I had a look into the documentation.
> >>> >
> >>> > From the Camel in Action book:
> >>> >
> >>> > from("quartz://report?cron=0+0+6+*+*+?")
> >>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
> >>> > .bean(new OrderToCsvBean())
> >>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >>> >
> >>> > How does Camel know which method in the OrderToCsvBean() class to
> >>> invoke.
> >>> > Unfortunately the book does not mentions this in Chapter 3. Not sure
> if
> >>> it
> >>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
> >>> >
> >>>
> >>> Yep chapter 4 is all about using beans/pojos with Camel; see for
> >>> example page 105.
> >>>
> >>> But basically if the pojo/bean has 1 method, then Camel knows that it
> >>> should invoke that method.
> >>> Its when you have 2+ methods it gets more complicated. You can of
> >>> course tell Camel the method name to use etc.
> >>>
> >>> But its all covered as well in chapter 4, as well you can find pieces
> >>> of details scattered online in the Camel docs.
> >>>
> >>>
> >>> > Regards,
> >>> > Jothi
> >>> >
> >>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> >>> > <ba...@swissonline.ch>wrote:
> >>> >
> >>> >> Check the documentation for this:
> >>> >>
> >>> >> http://camel.apache.org/bean-binding.html
> >>> >>
> >>> >> Babak
> >>> >>
> >>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <codeintheopen@gmail.com
> >:
> >>> >>
> >>> >> >I have decided to use JAXB instead of xStream. My route definition
> >>> looks
> >>> >> >like this:
> >>> >> >
> >>> >> >        final JaxbDataFormat jaxb = new
> >>> >> >JaxbDataFormat("com.example.filexml");
> >>> >> >        context.addRoutes(new RouteBuilder() {
> >>> >> >            public void configure() {
> >>> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
> >>> >> >ProcessorBean()).to("file://my.xml");
> >>> >> >            }
> >>> >> >        });
> >>> >> >
> >>> >> >How do I get hold of the UnMarshalled Java Object (say Person.java)
> >>> in my
> >>> >> >ProcessorBean. Also, when I use a bean for Processing, how does
> Camel
> >>> know
> >>> >> >which method to invoke in that bean?
> >>> >> >
> >>> >> >Regards,
> >>> >> >Jothi
> >>> >> >
> >>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com>
> >>> wrote:
> >>> >> >
> >>> >> >> Guys,
> >>> >> >>
> >>> >> >> I have a route which is defined as below:
> >>> >> >>
> >>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >>> >> >> ProcessorBean()).to("file://my.xml");
> >>> >> >>
> >>> >> >> All I want to do is access the my.xml in my ProcessorBean. Where
> >>> and how
> >>> >> >> do I specify the Java object which will be filled with the values
> >>> in the
> >>> >> >> xml file?
> >>> >> >>
> >>> >> >> Regards,
> >>> >> >> Jothi
> >>> >> >>
> >>> >>
> >>> >>
> >>> >>
> >>>
> >>>
> >>>
> >>> --
> >>> Claus Ibsen
> >>> -----------------
> >>> FuseSource
> >>> Email: cibsen@fusesource.com
> >>> Web: http://fusesource.com
> >>> Twitter: davsclaus, fusenews
> >>> Blog: http://davsclaus.com
> >>> Author of Camel in Action: http://www.manning.com/ibsen
> >>>
> >>
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this FAQ
http://camel.apache.org/what-jars-do-i-need.html



On Thu, Aug 16, 2012 at 3:50 PM, Joe San <co...@gmail.com> wrote:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/slf4j/LoggerFactory
>     at
> org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
>     at
> org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
> Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
>     at java.net.URLClassLoader$1.run(Unknown Source)
>     at java.security.AccessController.doPrivileged(Native Method)
>     at java.net.URLClassLoader.findClass(Unknown Source)
>     at java.lang.ClassLoader.loadClass(Unknown Source)
>     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>     at java.lang.ClassLoader.loadClass(Unknown Source)
>     ... 2 more
>
> My simple route fails with the above exception. All I have in my pom.xml
> defined is:
>
>     <dependency>
>         <groupId>org.apache.camel</groupId>
>         <artifactId>camel-core</artifactId>
>         <version>2.9.2</version>
>     </dependency>
>     <dependency>
>       <groupId>org.apache.camel</groupId>
>       <artifactId>camel-jaxb</artifactId>
>       <version>2.9.2</version>
>     </dependency>
>
> Do I need additional dependencies to be added other than this?
>
> Regards,
> Jothi
>
> On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com> wrote:
>
>> I just found that out from Chapter 4. I would have expected this hint that
>> "when the bean has only one method, camel invokes it automagically without
>> having to explicitly specifying it" in Chapter 3 itself.
>>
>> Regards,
>> Jothi
>>
>>
>> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <cl...@gmail.com>wrote:
>>
>>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com> wrote:
>>> > Thanks for pointing me to toe documentation. My actual question got
>>> > clarified once I had a look into the documentation.
>>> >
>>> > From the Camel in Action book:
>>> >
>>> > from("quartz://report?cron=0+0+6+*+*+?")
>>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
>>> > .bean(new OrderToCsvBean())
>>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
>>> >
>>> > How does Camel know which method in the OrderToCsvBean() class to
>>> invoke.
>>> > Unfortunately the book does not mentions this in Chapter 3. Not sure if
>>> it
>>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>>> >
>>>
>>> Yep chapter 4 is all about using beans/pojos with Camel; see for
>>> example page 105.
>>>
>>> But basically if the pojo/bean has 1 method, then Camel knows that it
>>> should invoke that method.
>>> Its when you have 2+ methods it gets more complicated. You can of
>>> course tell Camel the method name to use etc.
>>>
>>> But its all covered as well in chapter 4, as well you can find pieces
>>> of details scattered online in the Camel docs.
>>>
>>>
>>> > Regards,
>>> > Jothi
>>> >
>>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>>> > <ba...@swissonline.ch>wrote:
>>> >
>>> >> Check the documentation for this:
>>> >>
>>> >> http://camel.apache.org/bean-binding.html
>>> >>
>>> >> Babak
>>> >>
>>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <co...@gmail.com>:
>>> >>
>>> >> >I have decided to use JAXB instead of xStream. My route definition
>>> looks
>>> >> >like this:
>>> >> >
>>> >> >        final JaxbDataFormat jaxb = new
>>> >> >JaxbDataFormat("com.example.filexml");
>>> >> >        context.addRoutes(new RouteBuilder() {
>>> >> >            public void configure() {
>>> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
>>> >> >ProcessorBean()).to("file://my.xml");
>>> >> >            }
>>> >> >        });
>>> >> >
>>> >> >How do I get hold of the UnMarshalled Java Object (say Person.java)
>>> in my
>>> >> >ProcessorBean. Also, when I use a bean for Processing, how does Camel
>>> know
>>> >> >which method to invoke in that bean?
>>> >> >
>>> >> >Regards,
>>> >> >Jothi
>>> >> >
>>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com>
>>> wrote:
>>> >> >
>>> >> >> Guys,
>>> >> >>
>>> >> >> I have a route which is defined as below:
>>> >> >>
>>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>>> >> >> ProcessorBean()).to("file://my.xml");
>>> >> >>
>>> >> >> All I want to do is access the my.xml in my ProcessorBean. Where
>>> and how
>>> >> >> do I specify the Java object which will be filled with the values
>>> in the
>>> >> >> xml file?
>>> >> >>
>>> >> >> Regards,
>>> >> >> Jothi
>>> >> >>
>>> >>
>>> >>
>>> >>
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> -----------------
>>> FuseSource
>>> Email: cibsen@fusesource.com
>>> Web: http://fusesource.com
>>> Twitter: davsclaus, fusenews
>>> Blog: http://davsclaus.com
>>> Author of Camel in Action: http://www.manning.com/ibsen
>>>
>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory
    at
org.apache.camel.support.ServiceSupport.<clinit>(ServiceSupport.java:38)
    at
org.example.filexml.CamelWithFileAndXML.main(CamelWithFileAndXML.java:23)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more

My simple route fails with the above exception. All I have in my pom.xml
defined is:

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-jaxb</artifactId>
      <version>2.9.2</version>
    </dependency>

Do I need additional dependencies to be added other than this?

Regards,
Jothi

On Thu, Aug 16, 2012 at 3:34 PM, Joe San <co...@gmail.com> wrote:

> I just found that out from Chapter 4. I would have expected this hint that
> "when the bean has only one method, camel invokes it automagically without
> having to explicitly specifying it" in Chapter 3 itself.
>
> Regards,
> Jothi
>
>
> On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <cl...@gmail.com>wrote:
>
>> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com> wrote:
>> > Thanks for pointing me to toe documentation. My actual question got
>> > clarified once I had a look into the documentation.
>> >
>> > From the Camel in Action book:
>> >
>> > from("quartz://report?cron=0+0+6+*+*+?")
>> > .to("http://riders.com/orders/cmd=received&date=yesterday")
>> > .bean(new OrderToCsvBean())
>> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
>> >
>> > How does Camel know which method in the OrderToCsvBean() class to
>> invoke.
>> > Unfortunately the book does not mentions this in Chapter 3. Not sure if
>> it
>> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>> >
>>
>> Yep chapter 4 is all about using beans/pojos with Camel; see for
>> example page 105.
>>
>> But basically if the pojo/bean has 1 method, then Camel knows that it
>> should invoke that method.
>> Its when you have 2+ methods it gets more complicated. You can of
>> course tell Camel the method name to use etc.
>>
>> But its all covered as well in chapter 4, as well you can find pieces
>> of details scattered online in the Camel docs.
>>
>>
>> > Regards,
>> > Jothi
>> >
>> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
>> > <ba...@swissonline.ch>wrote:
>> >
>> >> Check the documentation for this:
>> >>
>> >> http://camel.apache.org/bean-binding.html
>> >>
>> >> Babak
>> >>
>> >> Am 16.08.12 14:32 schrieb "Joe San" unter <co...@gmail.com>:
>> >>
>> >> >I have decided to use JAXB instead of xStream. My route definition
>> looks
>> >> >like this:
>> >> >
>> >> >        final JaxbDataFormat jaxb = new
>> >> >JaxbDataFormat("com.example.filexml");
>> >> >        context.addRoutes(new RouteBuilder() {
>> >> >            public void configure() {
>> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
>> >> >ProcessorBean()).to("file://my.xml");
>> >> >            }
>> >> >        });
>> >> >
>> >> >How do I get hold of the UnMarshalled Java Object (say Person.java)
>> in my
>> >> >ProcessorBean. Also, when I use a bean for Processing, how does Camel
>> know
>> >> >which method to invoke in that bean?
>> >> >
>> >> >Regards,
>> >> >Jothi
>> >> >
>> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com>
>> wrote:
>> >> >
>> >> >> Guys,
>> >> >>
>> >> >> I have a route which is defined as below:
>> >> >>
>> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >> >> ProcessorBean()).to("file://my.xml");
>> >> >>
>> >> >> All I want to do is access the my.xml in my ProcessorBean. Where
>> and how
>> >> >> do I specify the Java object which will be filled with the values
>> in the
>> >> >> xml file?
>> >> >>
>> >> >> Regards,
>> >> >> Jothi
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.com
>> Author of Camel in Action: http://www.manning.com/ibsen
>>
>
>

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
I just found that out from Chapter 4. I would have expected this hint that
"when the bean has only one method, camel invokes it automagically without
having to explicitly specifying it" in Chapter 3 itself.

Regards,
Jothi

On Thu, Aug 16, 2012 at 3:32 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com> wrote:
> > Thanks for pointing me to toe documentation. My actual question got
> > clarified once I had a look into the documentation.
> >
> > From the Camel in Action book:
> >
> > from("quartz://report?cron=0+0+6+*+*+?")
> > .to("http://riders.com/orders/cmd=received&date=yesterday")
> > .bean(new OrderToCsvBean())
> > .to("file://riders/orders?fileName=report-${header.Date}.csv");
> >
> > How does Camel know which method in the OrderToCsvBean() class to invoke.
> > Unfortunately the book does not mentions this in Chapter 3. Not sure if
> it
> > is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
> >
>
> Yep chapter 4 is all about using beans/pojos with Camel; see for
> example page 105.
>
> But basically if the pojo/bean has 1 method, then Camel knows that it
> should invoke that method.
> Its when you have 2+ methods it gets more complicated. You can of
> course tell Camel the method name to use etc.
>
> But its all covered as well in chapter 4, as well you can find pieces
> of details scattered online in the Camel docs.
>
>
> > Regards,
> > Jothi
> >
> > On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> > <ba...@swissonline.ch>wrote:
> >
> >> Check the documentation for this:
> >>
> >> http://camel.apache.org/bean-binding.html
> >>
> >> Babak
> >>
> >> Am 16.08.12 14:32 schrieb "Joe San" unter <co...@gmail.com>:
> >>
> >> >I have decided to use JAXB instead of xStream. My route definition
> looks
> >> >like this:
> >> >
> >> >        final JaxbDataFormat jaxb = new
> >> >JaxbDataFormat("com.example.filexml");
> >> >        context.addRoutes(new RouteBuilder() {
> >> >            public void configure() {
> >> >                from("file://my.xml").unmarshal(jaxb).bean(new
> >> >ProcessorBean()).to("file://my.xml");
> >> >            }
> >> >        });
> >> >
> >> >How do I get hold of the UnMarshalled Java Object (say Person.java) in
> my
> >> >ProcessorBean. Also, when I use a bean for Processing, how does Camel
> know
> >> >which method to invoke in that bean?
> >> >
> >> >Regards,
> >> >Jothi
> >> >
> >> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com>
> wrote:
> >> >
> >> >> Guys,
> >> >>
> >> >> I have a route which is defined as below:
> >> >>
> >> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >> >> ProcessorBean()).to("file://my.xml");
> >> >>
> >> >> All I want to do is access the my.xml in my ProcessorBean. Where and
> how
> >> >> do I specify the Java object which will be filled with the values in
> the
> >> >> xml file?
> >> >>
> >> >> Regards,
> >> >> Jothi
> >> >>
> >>
> >>
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: JAXB Data Format

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 16, 2012 at 3:16 PM, Joe San <co...@gmail.com> wrote:
> Thanks for pointing me to toe documentation. My actual question got
> clarified once I had a look into the documentation.
>
> From the Camel in Action book:
>
> from("quartz://report?cron=0+0+6+*+*+?")
> .to("http://riders.com/orders/cmd=received&date=yesterday")
> .bean(new OrderToCsvBean())
> .to("file://riders/orders?fileName=report-${header.Date}.csv");
>
> How does Camel know which method in the OrderToCsvBean() class to invoke.
> Unfortunately the book does not mentions this in Chapter 3. Not sure if it
> is mentioned in Chapter 4 as I'm yet to start with Chapter 4.
>

Yep chapter 4 is all about using beans/pojos with Camel; see for
example page 105.

But basically if the pojo/bean has 1 method, then Camel knows that it
should invoke that method.
Its when you have 2+ methods it gets more complicated. You can of
course tell Camel the method name to use etc.

But its all covered as well in chapter 4, as well you can find pieces
of details scattered online in the Camel docs.


> Regards,
> Jothi
>
> On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
> <ba...@swissonline.ch>wrote:
>
>> Check the documentation for this:
>>
>> http://camel.apache.org/bean-binding.html
>>
>> Babak
>>
>> Am 16.08.12 14:32 schrieb "Joe San" unter <co...@gmail.com>:
>>
>> >I have decided to use JAXB instead of xStream. My route definition looks
>> >like this:
>> >
>> >        final JaxbDataFormat jaxb = new
>> >JaxbDataFormat("com.example.filexml");
>> >        context.addRoutes(new RouteBuilder() {
>> >            public void configure() {
>> >                from("file://my.xml").unmarshal(jaxb).bean(new
>> >ProcessorBean()).to("file://my.xml");
>> >            }
>> >        });
>> >
>> >How do I get hold of the UnMarshalled Java Object (say Person.java) in my
>> >ProcessorBean. Also, when I use a bean for Processing, how does Camel know
>> >which method to invoke in that bean?
>> >
>> >Regards,
>> >Jothi
>> >
>> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com> wrote:
>> >
>> >> Guys,
>> >>
>> >> I have a route which is defined as below:
>> >>
>> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> >> ProcessorBean()).to("file://my.xml");
>> >>
>> >> All I want to do is access the my.xml in my ProcessorBean. Where and how
>> >> do I specify the Java object which will be filled with the values in the
>> >> xml file?
>> >>
>> >> Regards,
>> >> Jothi
>> >>
>>
>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: JAXB Data Format

Posted by Joe San <co...@gmail.com>.
Thanks for pointing me to toe documentation. My actual question got
clarified once I had a look into the documentation.

>From the Camel in Action book:

from("quartz://report?cron=0+0+6+*+*+?")
.to("http://riders.com/orders/cmd=received&date=yesterday")
.bean(new OrderToCsvBean())
.to("file://riders/orders?fileName=report-${header.Date}.csv");

How does Camel know which method in the OrderToCsvBean() class to invoke.
Unfortunately the book does not mentions this in Chapter 3. Not sure if it
is mentioned in Chapter 4 as I'm yet to start with Chapter 4.

Regards,
Jothi

On Thu, Aug 16, 2012 at 2:46 PM, Babak Vahdat
<ba...@swissonline.ch>wrote:

> Check the documentation for this:
>
> http://camel.apache.org/bean-binding.html
>
> Babak
>
> Am 16.08.12 14:32 schrieb "Joe San" unter <co...@gmail.com>:
>
> >I have decided to use JAXB instead of xStream. My route definition looks
> >like this:
> >
> >        final JaxbDataFormat jaxb = new
> >JaxbDataFormat("com.example.filexml");
> >        context.addRoutes(new RouteBuilder() {
> >            public void configure() {
> >                from("file://my.xml").unmarshal(jaxb).bean(new
> >ProcessorBean()).to("file://my.xml");
> >            }
> >        });
> >
> >How do I get hold of the UnMarshalled Java Object (say Person.java) in my
> >ProcessorBean. Also, when I use a bean for Processing, how does Camel know
> >which method to invoke in that bean?
> >
> >Regards,
> >Jothi
> >
> >On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com> wrote:
> >
> >> Guys,
> >>
> >> I have a route which is defined as below:
> >>
> >> from("file://my.xml").marshal().xstream("UTF-8").bean(new
> >> ProcessorBean()).to("file://my.xml");
> >>
> >> All I want to do is access the my.xml in my ProcessorBean. Where and how
> >> do I specify the Java object which will be filled with the values in the
> >> xml file?
> >>
> >> Regards,
> >> Jothi
> >>
>
>
>

Re: JAXB Data Format

Posted by Babak Vahdat <ba...@swissonline.ch>.
Check the documentation for this:

http://camel.apache.org/bean-binding.html

Babak

Am 16.08.12 14:32 schrieb "Joe San" unter <co...@gmail.com>:

>I have decided to use JAXB instead of xStream. My route definition looks
>like this:
>
>        final JaxbDataFormat jaxb = new
>JaxbDataFormat("com.example.filexml");
>        context.addRoutes(new RouteBuilder() {
>            public void configure() {
>                from("file://my.xml").unmarshal(jaxb).bean(new
>ProcessorBean()).to("file://my.xml");
>            }
>        });
>
>How do I get hold of the UnMarshalled Java Object (say Person.java) in my
>ProcessorBean. Also, when I use a bean for Processing, how does Camel know
>which method to invoke in that bean?
>
>Regards,
>Jothi
>
>On Thu, Aug 16, 2012 at 1:56 PM, Joe San <co...@gmail.com> wrote:
>
>> Guys,
>>
>> I have a route which is defined as below:
>>
>> from("file://my.xml").marshal().xstream("UTF-8").bean(new
>> ProcessorBean()).to("file://my.xml");
>>
>> All I want to do is access the my.xml in my ProcessorBean. Where and how
>> do I specify the Java object which will be filled with the values in the
>> xml file?
>>
>> Regards,
>> Jothi
>>