bmw0128
bmw0128

Reputation: 13698

Compile Error on JAXB generated class

I'm getting the following error after I generated the following class. Do I need to run xjc differently?

Error(261,30): interface foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType is already defined as a class or interface enclosing this scope

class file:

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference   Implementation, v1.0.2-b15-fcs 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2011.03.03 at 04:15:50 PST 
//


package foo.bbs.tbi.firstresponse;


/**
 * Java content class for anonymous complex type.
 * <p>The following schema fragment specifies the expected content contained within   this java content object. (defined at file:/D:/tools/trang/trang-  20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 11)
 * <p>
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="Header">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="rule">
 *                     &lt;complexType>
 *                       &lt;complexContent>
 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema} anyType">
 *                           &lt;sequence>
 *                             &lt;element name="customer"  type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                             &lt;element name="schemaName" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
 *                             &lt;element name="schemaVersion" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
 *                           &lt;/sequence>
 *                         &lt;/restriction>
 *                       &lt;/complexContent>
 *                     &lt;/complexType>
 *                   &lt;/element>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *         &lt;element name="Body">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;choice>
 *                   &lt;element name="RTVL_RQST_ID"  type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                   &lt;element name="Fault">
 *                     &lt;complexType>
 *                       &lt;complexContent>
 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                           &lt;sequence>
 *                             &lt;element name="fault">
 *                               &lt;complexType>
 *                                 &lt;complexContent>
 *                                   &lt;restriction  base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                                     &lt;sequence>
 *                                       &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                                       &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *                                     &lt;/sequence>
 *                                   &lt;/restriction>
 *                                 &lt;/complexContent>
 *                               &lt;/complexType>
 *                             &lt;/element>
 *                           &lt;/sequence>
 *                         &lt;/restriction>
 *                       &lt;/complexContent>
 *                     &lt;/complexType>
 *                   &lt;/element>
 *                 &lt;/choice>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
*/
public interface EnvelopeType {


/**
 * 
 * @return
 *     possible object is
 *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType}
 */
foo.bbs.tbi.firstresponse.EnvelopeType.BodyType getBody();

/**
 * 
 * @param value
 *     allowed object is
 *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType}
 */
void setBody(foo.bbs.tbi.firstresponse.EnvelopeType.BodyType value);

/**
 * 
 * @return
 *     possible object is
 *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType}
 */
foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType getHeader();

/**
 * 
 * @param value
 *     allowed object is
 *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType}
 */
void setHeader(foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType value);


/**
 * Java content class for anonymous complex type.
 * <p>The following schema fragment specifies the expected content contained within  this java content object. (defined at file:/D:/tools/trang/trang- 20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 29)
 * <p>
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;choice>
 *         &lt;element name="RTVL_RQST_ID" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *         &lt;element name="Fault">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="fault">
 *                     &lt;complexType>
 *                       &lt;complexContent>
 *                         &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                           &lt;sequence>
 *                             &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                             &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *                           &lt;/sequence>
 *                         &lt;/restriction>
 *                       &lt;/complexContent>
 *                     &lt;/complexType>
 *                   &lt;/element>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/choice>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 */
public interface BodyType {


    /**
     * 
     * @return
     *     possible object is
     *     {@link java.math.BigInteger}
     */
    java.math.BigInteger getRTVLRQSTID();

    /**
     * 
     * @param value
     *     allowed object is
     *     {@link java.math.BigInteger}
     */
    void setRTVLRQSTID(java.math.BigInteger value);

    /**
     * 
     * @return
     *     possible object is
     *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType}
     */
    foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType getFault();

    /**
     * 
     * @param value
     *     allowed object is
     *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType}
     */
    void setFault(foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType value);


    /**
     * Java content class for anonymous complex type.
     * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at file:/D:/tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 33)
     * <p>
     * <pre>
     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="fault">
     *           &lt;complexType>
     *             &lt;complexContent>
     *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *                 &lt;sequence>
     *                   &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
     *                   &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
     *                 &lt;/sequence>
     *               &lt;/restriction>
     *             &lt;/complexContent>
     *           &lt;/complexType>
     *         &lt;/element>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     */
    public interface FaultType {


        /**
         * 
         * @return
         *     possible object is
         *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType}
         */
        foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType getFault();

        /**
         * 
         * @param value
         *     allowed object is
         *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType}
         */
        void setFault(foo.bbs.tbi.firstresponse.EnvelopeType.BodyType.FaultType.FaultType value);


        /**
         * Java content class for anonymous complex type.
         * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at file:/D:/tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 36)
         * <p>
         * <pre>
         * &lt;complexType>
         *   &lt;complexContent>
         *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
         *       &lt;sequence>
         *         &lt;element name="faultcode" type="{http://www.w3.org/2001/XMLSchema}integer"/>
         *         &lt;element name="faultstring" type="{http://www.w3.org/2001/XMLSchema}string"/>
         *       &lt;/sequence>
         *     &lt;/restriction>
         *   &lt;/complexContent>
         * &lt;/complexType>
         * </pre>
         * 
         */
        public interface FaultType {


            /**
             * 
             * @return
             *     possible object is
             *     {@link java.math.BigInteger}
             */
            java.math.BigInteger getFaultcode();

            /**
             * 
             * @param value
             *     allowed object is
             *     {@link java.math.BigInteger}
             */
            void setFaultcode(java.math.BigInteger value);

            /**
             * 
             * @return
             *     possible object is
             *     {@link java.lang.String}
             */
            java.lang.String getFaultstring();

            /**
             * 
             * @param value
             *     allowed object is
             *     {@link java.lang.String}
             */
            void setFaultstring(java.lang.String value);

        }

    }

}


/**
 * Java content class for anonymous complex type.
 * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at file:/D:/tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 14)
 * <p>
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="rule">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="customer" type="{http://www.w3.org/2001/XMLSchema}integer"/>
 *                   &lt;element name="schemaName" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
 *                   &lt;element name="schemaVersion" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 */
public interface HeaderType {


    /**
     * 
     * @return
     *     possible object is
     *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType}
     */
    foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType getRule();

    /**
     * 
     * @param value
     *     allowed object is
     *     {@link foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType}
     */
    void setRule(foo.bbs.tbi.firstresponse.EnvelopeType.HeaderType.RuleType value);


    /**
     * Java content class for anonymous complex type.
     * <p>The following schema fragment specifies the expected content contained within this java content object. (defined at file:/D:/tools/trang/trang-20091111/tbi/firstResponseOnly/jaxb2/firstCombined.xsd line 17)
     * <p>
     * <pre>
     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="customer" type="{http://www.w3.org/2001/XMLSchema}integer"/>
     *         &lt;element name="schemaName" type="{http://www.w3.org/2001/XMLSchema}NCName"/>
     *         &lt;element name="schemaVersion" type="{http://www.w3.org/2001/XMLSchema}decimal"/>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     */
    public interface RuleType {


        /**
         * 
         * @return
         *     possible object is
         *     {@link java.math.BigDecimal}
         */
        java.math.BigDecimal getSchemaVersion();

        /**
         * 
         * @param value
         *     allowed object is
         *     {@link java.math.BigDecimal}
         */
        void setSchemaVersion(java.math.BigDecimal value);

        /**
         * 
         * @return
         *     possible object is
         *     {@link java.lang.String}
         */
        java.lang.String getSchemaName();

        /**
         * 
         * @param value
         *     allowed object is
         *     {@link java.lang.String}
         */
        void setSchemaName(java.lang.String value);

        /**
         * 
         * @return
         *     possible object is
         *     {@link java.math.BigInteger}
         */
        java.math.BigInteger getCustomer();

        /**
         * 
         * @param value
         *     allowed object is
         *     {@link java.math.BigInteger}
         */
        void setCustomer(java.math.BigInteger value);

    }

}

}

Upvotes: 3

Views: 1445

Answers (2)

mmuller
mmuller

Reputation: 798

Just completing Christian's answer. You can customize the name that JAXB will use for a specific element by using bindings (either inside the schema or in an external bindings file (.xjb)). See class binding declarations to customize the class that is generated for a given type:

If the complex type is named:

  • Use <jxb:bindings node="//xs:complexType[@name=’TypeName’]"> to specify the type to customize using XPath syntax, and:
  • Use <jxb:class name="CustomizedClassName"> to customize the generated class name.

If the complex type is not named, as in your case, you can try customizing the property of a type (I did not try this and cannot certify this will work):

  • Use <jxb:bindings node=".//xs:element[@name=’elementName’]"> to specify the element to customize (still XPath syntax), and:
  • Use <jxb:property name="customizedPropertyName"/> to customize the generated property.

Upvotes: 2

Christian Semrau
Christian Semrau

Reputation: 9013

The problem you're facing here is caused by Java not letting you declare an inner class with the same simple name as an outer class. You have a class FaultType within a class FaultType, which is forbidden, and caused by having a "fault" element inside a "Fault" element.

I don't know if you can tell JAXB to use a different naming strategy. Maybe it helps to extract named types in the XSD, which should cause JAXB to generate top level classes instead of nested classes.

Upvotes: 2

Related Questions