users@jaxb.java.net

Re: No ObjectFactory with an _at_XmlElementDecl for...

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 05 Jun 2007 16:21:16 -0700

Don Walling wrote:
> I'm updating an application from JAXB 1.0 to 2.1 and getting the error
> "There's no ObjectFactory with an @XmlElementDecl for..." error on a
> variety of methods. The issue seems to be related the use of implClass
> in the bindings file. I'm wondering if there might be a bug in the
> portion of XJC that creates the ObjectFactory method.
>
> The bindings looks like:
> <jaxb:bindings node="//xs:complexType[@name='PDFResultType']">
> <jaxb:class implClass="com.adobe.internal.ddxm.ddx.pdf.PDFResult"/>
> </jaxb:bindings>
> <jaxb:bindings node="//xs:complexType[@name='TitleType']">
> <jaxb:class implClass="com.adobe.internal.ddxm.ddx.metadata.Title"/>
> </jaxb:bindings>
>
> The TitleType is used in within several complexType elements in the
> schema, including the PDFResultType, so the generated method in
> ObjectFactory
> looks like:
>
> @XmlElementDecl(namespace = "http://ns.adobe.com/DDX/1.0/", name =
> "Title", scope = PDFResult.class)
> public JAXBElement<TitleType> createPDFResultTypeTitle(TitleType
> value) {
> return new JAXBElement<TitleType>(_PackageFilesTypeTitle_QNAME,
> ((Class) Title.class), PDFResult.class, ((Title) value));
> }
>
> This yields the error "There's no ObjectFactory with an @XmlElementDecl
> for the element {http://ns.adobe.com/DDX/1.0/}Title." at runtime while
> parsing the XML.
>
> I get further by hand-editing the generated code to use
> PDFResultType.class base class that JAXB generates rather than the
> implClass as follows:
> @XmlElementDecl(namespace = "http://ns.adobe.com/DDX/1.0/
> <http://ns.adobe.com/DDX/1.0/> ", name = "Title", scope =
> PDFResultType.class)
> public JAXBElement<TitleType> createPDFResultTypeTitle(TitleType
> value) {
> return new JAXBElement<TitleType>(_PackageFilesTypeTitle_QNAME,
> ((Class) Title.class), PDFResultType.class, ((Title) value));
> }
> The above code - changing PDFResult.class to PDFResultType.class -
> seems to work (or at least I get past that error and on to the next). Is
> this a problem in XJC or have I overlooked some configuration setting
> that controls use of the base class verses the implClass in the
> generated ObjectFactory? Or, is this just a symptom of some other issue?

Thanks for filing https://jaxb.dev.java.net/issues/show_bug.cgi?id=367
See my comment to the issue.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com