You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Tim Clotworthy <tc...@integratedsecure.com> on 2011/02/24 19:59:41 UTC

JAXB Unmarshalling Exception when Encountering < and >

ello,

I am getting unmarshalling exceptions at any encounter of sequences &lt; and &gt; in my xml. I tried wrappering the corresponding pieces with CDATA like <![CDATA[&gt;]]>, but the exception still occurs.

I am using the following classes for performing the unmarshalling activities:

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;

and the exception takes place in the "f = (Filter) u.unmarshal(s);" part of the code below:

JAXBContext jbc = null;
Unmarshaller u = null;
Filter f = null;
try {
jbc = JAXBContext.newInstance(Filter.class);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
u = jbc.createUnmarshaller();
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StringReader sr_xml = new StringReader(filter);
Source s = new StreamSource(sr_xml);
try {
f = (Filter) u.unmarshal(s);
} catch (JAXBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

I would be grateful for any insights into how to resolve this. thank you for any response!

Re: JAXB Unmarshalling Exception when Encountering < and >

Posted by Daniel Kulp <dk...@apache.org>.
Can you create a small test case for this?   This definitely seems strange as 
the XML parser should be decoding those just fine.    JAXB shouldn't ever even 
see the encoded form of them.

Dan


On Thursday 24 February 2011 1:59:41 PM Tim Clotworthy wrote:
> ello,
> 
> I am getting unmarshalling exceptions at any encounter of sequences &lt;
> and &gt; in my xml. I tried wrappering the corresponding pieces with CDATA
> like <![CDATA[&gt;]]>, but the exception still occurs.
> 
> I am using the following classes for performing the unmarshalling
> activities:
> 
> import javax.xml.bind.JAXBContext;
> import javax.xml.bind.JAXBException;
> import javax.xml.bind.Unmarshaller;
> import javax.xml.transform.Source;
> import javax.xml.transform.stream.StreamSource;
> 
> and the exception takes place in the "f = (Filter) u.unmarshal(s);" part of
> the code below:
> 
> JAXBContext jbc = null;
> Unmarshaller u = null;
> Filter f = null;
> try {
> jbc = JAXBContext.newInstance(Filter.class);
> } catch (JAXBException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> try {
> u = jbc.createUnmarshaller();
> } catch (JAXBException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> StringReader sr_xml = new StringReader(filter);
> Source s = new StreamSource(sr_xml);
> try {
> f = (Filter) u.unmarshal(s);
> } catch (JAXBException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> 
> I would be grateful for any insights into how to resolve this. thank you
> for any response!

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com

Re: JAXB Unmarshalling Exception when Encountering < and >

Posted by Aki Yoshida <sa...@googlemail.com>.
Hi,
this should not happen in the normal out-of-the-box setup. Maybe you
are using some special XML parser or JAXB implementation that does not
resolve these references?

Regard, aki

On Thu, Feb 24, 2011 at 7:59 PM, Tim Clotworthy
<tc...@integratedsecure.com> wrote:
> ello,
>
> I am getting unmarshalling exceptions at any encounter of sequences &lt; and &gt; in my xml. I tried wrappering the corresponding pieces with CDATA like <![CDATA[&gt;]]>, but the exception still occurs.
>
> I am using the following classes for performing the unmarshalling activities:
>
> import javax.xml.bind.JAXBContext;
> import javax.xml.bind.JAXBException;
> import javax.xml.bind.Unmarshaller;
> import javax.xml.transform.Source;
> import javax.xml.transform.stream.StreamSource;
>
> and the exception takes place in the "f = (Filter) u.unmarshal(s);" part of the code below:
>
> JAXBContext jbc = null;
> Unmarshaller u = null;
> Filter f = null;
> try {
> jbc = JAXBContext.newInstance(Filter.class);
> } catch (JAXBException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> try {
> u = jbc.createUnmarshaller();
> } catch (JAXBException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> StringReader sr_xml = new StringReader(filter);
> Source s = new StreamSource(sr_xml);
> try {
> f = (Filter) u.unmarshal(s);
> } catch (JAXBException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> I would be grateful for any insights into how to resolve this. thank you for any response!
>