You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dresden <is...@gmail.com> on 2010/09/08 22:46:14 UTC

Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

I downgraded from 2.4.0 to 2.3.0 and the error seems to go away.

I have no desire to use and older version. If anyone has insight, please
comment.

Now I get a different error. Not sure if this is Camel related or Jaxb.
Again - help appreciated...


org.apache.camel.RuntimeCamelException: java.io.IOException:
"com.mycompany.connector.jms.TestBean" doesnt contain ObjectFactory.class or
jaxb.index
-- 
View this message in context: http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-suggestions-tp2814620p2815791.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by Jason Chaffee <jc...@ebates.com>.
Well, you have an example of the contextPath being
"com.mycompany.connector.jms" yet your bean example that worked had the
package of "com.mycompany.connector.bean" for the TestBean. Those don't
look the same to me.  From this, it would guess that your contextPath in
the example below is not correct and that it should be
"com.mycompany.connector.bean".  



-----Original Message-----
From: dresden [mailto:isaacvoth@gmail.com] 
Sent: Wednesday, September 08, 2010 2:25 PM
To: users@camel.apache.org
Subject: RE: Solution?? JAXB Unmarshalling - DataFormat error ...
suggestions?


Yes. I have an annotated class in that package that I want to
"unmarshall
into".

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="test")
public class TestBean {
...

Now, it is not an ObjectFactory, but it is annotated. Am I using the
Jaxb
bean correctly?

<route>
	<from uri="amq2:queue:take" />

	<unmarshal>
		<jaxb id="myJaxb" prettyPrint="true"
contextPath="com.mycompany.connector.jms" />
	</unmarshal>

	<bean ref="consumer" />
	<to uri="amq2:queue:taken" />
</route>
-- 
View this message in context:
http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-su
ggestions-tp2814620p2818518.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by Mark <ja...@gmail.com>.
JDK 1.5 or 1.6 ?

On 8 September 2010 22:24, dresden <is...@gmail.com> wrote:
>
> Yes. I have an annotated class in that package that I want to "unmarshall
> into".
>
> import javax.xml.bind.annotation.XmlElement;
> import javax.xml.bind.annotation.XmlRootElement;
>
> @XmlRootElement(name="test")
> public class TestBean {
> ...
>
> Now, it is not an ObjectFactory, but it is annotated. Am I using the Jaxb
> bean correctly?
>
> <route>
>        <from uri="amq2:queue:take" />
>
>        <unmarshal>
>                <jaxb id="myJaxb" prettyPrint="true"
> contextPath="com.mycompany.connector.jms" />
>        </unmarshal>
>
>        <bean ref="consumer" />
>        <to uri="amq2:queue:taken" />
> </route>
> --
> View this message in context: http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-suggestions-tp2814620p2818518.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

RE: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by dresden <is...@gmail.com>.
Yes. I have an annotated class in that package that I want to "unmarshall
into".

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="test")
public class TestBean {
...

Now, it is not an ObjectFactory, but it is annotated. Am I using the Jaxb
bean correctly?

<route>
	<from uri="amq2:queue:take" />

	<unmarshal>
		<jaxb id="myJaxb" prettyPrint="true"
contextPath="com.mycompany.connector.jms" />
	</unmarshal>

	<bean ref="consumer" />
	<to uri="amq2:queue:taken" />
</route>
-- 
View this message in context: http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-suggestions-tp2814620p2818518.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by Jason Chaffee <jc...@ebates.com>.
And all of your jaxb classes are in this package
"com.mycompany.connector.jms"?

-----Original Message-----
From: dresden [mailto:isaacvoth@gmail.com] 
Sent: Wednesday, September 08, 2010 2:10 PM
To: users@camel.apache.org
Subject: Re: Solution?? JAXB Unmarshalling - DataFormat error ...
suggestions?


Thanks for the response.

I am hoping to get this to work from Spring config xml. So my JAXB
Context
is configured like this:


<dataFormats> 
    <jaxb id="myJaxb" prettyPrint="true"
contextPath="com.mycompany.connector.jms"/> 
  </dataFormats> 

I tried specifying both the package and the package and class name. Both
get
the error.

I found a different way to achieve unmarshalling, which I am going to
post
next, but this is concerning as I should be able to get JAXB to work.
-- 
View this message in context:
http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-su
ggestions-tp2814620p2817298.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by Jason Chaffee <jc...@ebates.com>.
Well based on this example and the jaxb contextPath you gave earlier, it
appears they aren't the same package.  If jaxb can't find annotated
classes or an ObjectFactory in the contetPath then you will get the
error you were seeing.

-----Original Message-----
From: dresden [mailto:isaacvoth@gmail.com] 
Sent: Wednesday, September 08, 2010 2:19 PM
To: users@camel.apache.org
Subject: Re: Solution?? JAXB Unmarshalling - DataFormat error ...
suggestions?


I was able to achieve unmarshalling using a different approach. I found
the
suggestion here:

http://stackoverflow.com/questions/2631662/using-apache-camel-how-do-i-u
nmarshal-my-deserialized-object-that-comes-in-throug

My Spring config looks like this:

<route>

	<from uri="amq2:queue:eat" />
	<to
uri="xslt:file:src/com/mycompany/connector/resources/test.xslt" />
	<convertBodyTo type="com.mycompany.connector.bean.TestBean" />

	<bean ref="consumer" />
	<to uri="amq2:queue:eaten" />

</route>

Currently this method is working. My TestBean class is annotated with
JAXB
(XmlRootElement). The consumer bean receives a POJO, not an XML message
or
String. 

However, if anyone has an example of using an explicit Jaxb DataFormat
from
a Spring configuration, that would be great.
-- 
View this message in context:
http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-su
ggestions-tp2814620p2817914.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by dresden <is...@gmail.com>.
I was able to achieve unmarshalling using a different approach. I found the
suggestion here:

http://stackoverflow.com/questions/2631662/using-apache-camel-how-do-i-unmarshal-my-deserialized-object-that-comes-in-throug

My Spring config looks like this:

<route>

	<from uri="amq2:queue:eat" />
	<to uri="xslt:file:src/com/mycompany/connector/resources/test.xslt" />
	<convertBodyTo type="com.mycompany.connector.bean.TestBean" />			
	<bean ref="consumer" />
	<to uri="amq2:queue:eaten" />

</route>

Currently this method is working. My TestBean class is annotated with JAXB
(XmlRootElement). The consumer bean receives a POJO, not an XML message or
String. 

However, if anyone has an example of using an explicit Jaxb DataFormat from
a Spring configuration, that would be great.
-- 
View this message in context: http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-suggestions-tp2814620p2817914.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Solution?? JAXB Unmarshalling - DataFormat error ... suggestions?

Posted by dresden <is...@gmail.com>.
Thanks for the response.

I am hoping to get this to work from Spring config xml. So my JAXB Context
is configured like this:


<dataFormats> 
    <jaxb id="myJaxb" prettyPrint="true"
contextPath="com.mycompany.connector.jms"/> 
  </dataFormats> 

I tried specifying both the package and the package and class name. Both get
the error.

I found a different way to achieve unmarshalling, which I am going to post
next, but this is concerning as I should be able to get JAXB to work.
-- 
View this message in context: http://camel.465427.n5.nabble.com/JAXB-Unmarshalling-DataFormat-error-suggestions-tp2814620p2817298.html
Sent from the Camel - Users mailing list archive at Nabble.com.