tags:

views:

4791

answers:

3

Hi people,

While trying to generate classes from a xsd, i got this error:

java.lang.IllegalArgumentException: Illegal class inheritance loop.  Outer class OrderPropertyList may not subclass from inner class: OrderPropertyList

My xsd define a element to group a unbounded element like this:

  <element minOccurs="0" name="orderPropertyList">
    <complexType>
      <sequence>
        <element maxOccurs="unbounded" name="orderProperty" type="tns:orderProperty" />
      </sequence>
    </complexType>
  </element>

And my customization binding follows as specified on this page, but it doesn´t work. Here my binding:

<jaxb:bindings schemaLocation="../xsd/Schema.xsd" node="/xs:schema">
 <jaxb:bindings node="//xs:element[@name='orderPropertyList']">
  <jaxb:class name="OrderPropertyList"/>
 </jaxb:bindings>
</jaxb:bindings>

My intention is to generate a individual class for orderPropertyList, not the default behave that is generating a inner class inside the root element of the xsd.

I´ve watched someone with the same intention here and here, but it doesn´t work properly for me. :(

JAXB version:

Specification-Version: 2.1
Implementation-Version: 2.1.8

Any help?

A: 

I believe this is happening because it's likely that the generated Java class representing the sequence of "orderProperty" is itself named "OrderPropertyList".

What I would do is first generate it without any custom bindings, and look at the class names and hierarchies that it generates. Then, consider what you want to override, and how.

David M. Karr
Actually, when i remove the binding i have the default behave: OrderPropertyList as a inner class of the root element. I´m using a custom binding to scape (even without succeed) from this situation.
paulosuzart
A: 

This is a kind of horror situation, how to always generate classes without the use of inner classes? Oh god! If you use Weblogic 10 with jax-ws, you can't have inner classes inside you request/response types. Sad!

paulosuzart
+1  A: 

I believe what you need to to is set:

<jaxb:globalBindings localScoping="toplevel"/>

This will generate standalone classes instead of nested classes.

Doing

<jaxb:bindings schemaLocation="../xsd/Schema.xsd" node="/xs:schema">
    <jaxb:bindings node="//xs:element[@name='orderPropertyList']">
            <jaxb:class name="OrderPropertyList"/>
    </jaxb:bindings>
</jaxb:bindings>

is a redundant binding, since orderPropertyList will map by default to OrderPropertyList. The name of the package includes the outer class name it is nested in by default, so you're not changing that.

Also, if you did want to change the name of the generated class, I think the XPath would actually be:

<jaxb:bindings node="<outer>//xs:element[@name='orderPropertyList']//xs:complexType">

with complexType on the end. I think excluding this was what was causing the error message you got.

Without effect! I´ve tried to use toplevel and many combinations for xPath expression.When I use the toplevel localScoping I get: [xjc] [ERROR] A class/interface with the same name "order.OrderLineList" is already in use. Use a class customization to resolve this conflict.
paulosuzart
After override all definitions with the same name, one-by-one it worked! Urf! Lot of work involving more than 15 xsds to generate classes and solve conflicts...Thanks!
paulosuzart