You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Colm O hEigeartaigh <co...@progress.com> on 2008/10/14 18:35:36 UTC

Question on JAXB/DOM

Hi guys,

I have a JAXB object generated by xsdtojava in CXF that has the
following attribute:

@XmlAnyElement(lax = true)
protected Object any;

This has a setAny accessor with the comment that the allowed object
argument is a DOM Element or an Object. However, I get the following
error when I assign a DOM Element to "any", and the JAXB object gets
marshalled out:

SEVERE: EXCEPTION 
java.lang.AssertionError
com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl.declareNsUri(Nam
espaceContextImpl.java:189)
...
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshaller
Impl.java:75)
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.ja
va:378)
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:
154)
...

Has anyone ever tried doing anything similar, or does it even make sense
to do so? I need to preserve the DOM Element "as is", as it's a signed
SAML assertion. I'd rather avoid having to manually marshal the JAXB
object itself to DOM, and then insert the "any" in the right place, if
at all possible.

Thanks,

Colm.

Re: Question on JAXB/DOM

Posted by Daniel Kulp <dk...@apache.org>.
Colm,

Looking at that spot in the JAXB code, it's trying to do some funky stuff 
around re-assign the default namespace to something else.   If you can, can 
you avoid using the default namespace in your code?   (qualified elements and 
such)  That MIGHT help.

That said, if you can build up a small JAXB only example that shows the 
problem, log it a jaxb.dev.java.net.   They might get around to fixing it if 
there is a sample.   They pretty much don't fix anything else if their isn't 
a  sample showing the problem.   In this case, the "assert" that is there 
might just be an invalid assertion.

Dan


On Tuesday 14 October 2008 12:35:36 pm Colm O hEigeartaigh wrote:
> Hi guys,
>
> I have a JAXB object generated by xsdtojava in CXF that has the
> following attribute:
>
> @XmlAnyElement(lax = true)
> protected Object any;
>
> This has a setAny accessor with the comment that the allowed object
> argument is a DOM Element or an Object. However, I get the following
> error when I assign a DOM Element to "any", and the JAXB object gets
> marshalled out:
>
> SEVERE: EXCEPTION
> java.lang.AssertionError
> com.sun.xml.bind.v2.runtime.output.NamespaceContextImpl.declareNsUri(Nam
> espaceContextImpl.java:189)
> ...
> javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshaller
> Impl.java:75)
> org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.ja
> va:378)
> org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:
> 154)
> ...
>
> Has anyone ever tried doing anything similar, or does it even make sense
> to do so? I need to preserve the DOM Element "as is", as it's a signed
> SAML assertion. I'd rather avoid having to manually marshal the JAXB
> object itself to DOM, and then insert the "any" in the right place, if
> at all possible.
>
> Thanks,
>
> Colm.



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