jaxb2-basics: Interface inheritance not working for complexTypes with mixed=true

Hi.

I’m having an issue with attaching a custom interface to a complexContent element which is set to mixed=true.

I modified the cxf sample project to reproduce the error.

<xs:complexType name="FaultType">
    <xs:complexContent mixed="true">
      <xs:extension base="xs:anyType">
        <xs:attribute name="id" type="xs:anyURI" use="required"/>
        <xs:anyAttribute processContents="lax"/>
      </xs:extension>
    </xs:complexContent>
</xs:complexType>

The binding file:

<jaxb:bindings schemaLocation="schema.xsd" node="/xsd:schema">
    <jaxb:schemaBindings>
        <jaxb:package name="org.jvnet.jaxb2_commons.tests.cxf.schema"/>
    </jaxb:schemaBindings>      
    <jaxb:bindings node="//xsd:complexType[@name='FaultType']">
        <inheritance:implements>org.sample.test.MyInterface</inheritance:implements>
    </jaxb:bindings>
</jaxb:bindings>

And the simple interface:

public interface MyInterface {
    default void sayHello(){
      System.out.println("Hello world");
    }   
}

When I try the compilation I get the following error:

[WARNING] Exception in thread "main" org.apache.cxf.tools.common.ToolException: file:/C:/tmp/jaxb2-basics-sample-cxf-0.11.0/src/main/resources/bindings.xjb [42,28]: compiler was unable to honor this inheritance:implements customization. It is attached to a wrong place, or its inconsistent with other bindings.
[WARNING] file:/C:/tmp/jaxb2-basics-sample-cxf-0.11.0/src/main/resources/schema.xsd [43,2]: (the above customization is attached to the following location in the schema)

The interesting thing is, when I remove the attribute “mixed=true” from the complexContent in the xsd, everything works fine. Unfortunately I need this flag to allow simple string and xml content.

Do you have any idea what’s causing this error? All the other custom interfaces like Copy2, Equals2 work even with mixed set to true.

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (12 by maintainers)

Most upvoted comments

Here you go.