You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ankelee <an...@gmail.com> on 2010/03/10 12:46:07 UTC

How to use JAXB and Java DSL

http://camel.apache.org/jaxb.html

That example doesnt work, looking at the API it doesn't even take a String
in the constructor?

DataFormat jaxb = new JaxbDataFormat("com.acme.model");
from("activemq:My.Queue").unmarshal(jaxb).to("mqseries:Another.Queue");

I tried this:

JaxbDataFormat jaxb = new JaxbDataFormat();
jaxb.setContextPath("package.with.annotated.java.classes");

.to("xslt://file:dir/some.xsl")
.unmarshal(jaxb)
.marshal(jaxb)
.to("file://dir");

...doesn't work:

SEVERE: Failed delivery for exchangeId:
06fc3c4f-3f8a-4322-9c07-416e3e25b464. Exhausted after delivery attempt: 1
caught: java.io.IOException
-- 
View this message in context: http://old.nabble.com/How-to-use-JAXB-and-Java-DSL-tp27848546p27848546.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to use JAXB and Java DSL

Posted by ankelee <an...@gmail.com>.
Nevermind, I'm stupid. Was using the wrong JaxbDataFormat.
-- 
View this message in context: http://old.nabble.com/How-to-use-JAXB-and-Java-DSL-tp27848546p27849539.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to use JAXB and Java DSL

Posted by ankelee <an...@gmail.com>.
Yeah well, UnmarshalTest.java in the jaxb test does this:

    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                DataFormat jaxb = new
JaxbDataFormat("org.apache.camel.example");

                from("direct:start").
                        unmarshal(jaxb).
                        to("mock:result");
            }
        };
    }

And I'm not able to replicate it:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
	The constructor JaxbDataFormat(String) is undefined
	Type mismatch: cannot convert from JaxbDataFormat to DataFormat
-- 
View this message in context: http://old.nabble.com/How-to-use-JAXB-and-Java-DSL-tp27848546p27849420.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: How to use JAXB and Java DSL

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 10, 2010 at 12:46 PM, ankelee <an...@gmail.com> wrote:
>
> http://camel.apache.org/jaxb.html
>
> That example doesnt work, looking at the API it doesn't even take a String
> in the constructor?
>
> DataFormat jaxb = new JaxbDataFormat("com.acme.model");
> from("activemq:My.Queue").unmarshal(jaxb).to("mqseries:Another.Queue");
>
> I tried this:
>
> JaxbDataFormat jaxb = new JaxbDataFormat();
> jaxb.setContextPath("package.with.annotated.java.classes");
>
> .to("xslt://file:dir/some.xsl")
> .unmarshal(jaxb)
> .marshal(jaxb)
> .to("file://dir");
>
> ...doesn't work:
>
> SEVERE: Failed delivery for exchangeId:
> 06fc3c4f-3f8a-4322-9c07-416e3e25b464. Exhausted after delivery attempt: 1
> caught: java.io.IOException
> --

Look at the caught exception. Its an IOException which could be
something like file not found etc.
You have to dig into the stacktrace to see the real problem.

And check in camel-jaxb in the src/test/java for unit tests to see how
to use it.

> View this message in context: http://old.nabble.com/How-to-use-JAXB-and-Java-DSL-tp27848546p27848546.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus