Unsupported binding namespace “”

后端 未结 1 959
情深已故
情深已故 2021-01-20 23:09

I have a schema for which JAXB is able to generate java classes perfectly every time. I am trying to get hyperjaxb to process the same schema. Towards

相关标签:
1条回答
  • 2021-01-20 23:50

    The error that you see is due to missing the prefix on tag <property name="xsid"/>. The correct tag is below

    <jaxb:bindings node="//xs:complexType[@name='Section']/xs:attribute[@name='ID']">
        <jaxb:property name="xsid"/>
    </jaxb:bindings>
    

    Anyway your XSDs have some problem because by maven-jaxb2-plugin is possible to generates all classes and maven-hyperjaxb3-plugin is not possible.


    I suggest a work around for your entire problem. If you don't needed to mark as @Entity or @Table all class that you generated, you could use below configuration.

    XJB

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <jaxb:bindings
        version="2.1"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:annox="http://annox.dev.java.net"  >
    
        <jaxb:bindings schemaLocation="schema.xsd" node="/xs:schema">
            <jaxb:globalBindings generateIsSetMethod="true"/>
            <jaxb:schemaBindings>
                <jaxb:package name="org.jvnet.hyperjaxb3.ejb.tests.pocustomized"/>
            </jaxb:schemaBindings>
            <jaxb:bindings node="//xs:complexType[@name='InfrastructureRoot.typeId']">
                <annox:annotate>
                    <annox:annotate annox:class="javax.persistence.Entity">
                    </annox:annotate>
                    <annox:annotate annox:class="javax.persistence.Table" name="typeId">
                    </annox:annotate>
                </annox:annotate>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:complexType[@name='ObservationMedia']/xs:attribute[@name='ID']">
                <jaxb:property name="xsid"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:complexType[@name='RegionOfInterest']/xs:attribute[@name='ID']">
                <jaxb:property name="xsid"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:complexType[@name='Section']/xs:attribute[@name='ID']">
                <jaxb:property name="xsid"/>
            </jaxb:bindings>
    
    
        </jaxb:bindings>
    
    </jaxb:bindings>
    

    Maven Plugin

    <plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.8.1</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
                <version>1.0.1.Final</version>
            </dependency>
        </dependencies>
        <configuration>
            <args>
                <arg>-Xannotate</arg>
                <arg>-nv</arg>
            </args>
            <extension>true</extension>
            <schemaDirectory>src/main/resources/</schemaDirectory>
            <schemaIncludes>
                <schemaInclude>schema.xsd</schemaInclude>
            </schemaIncludes>
            <bindingDirectory>src/main/resources/</bindingDirectory>
            <bindingIncludes>
                <include>*.xjb</include>
            </bindingIncludes>
            <debug>true</debug>
            <verbose>true</verbose>
            <episode>true</episode>
            <forceRegenerate>true</forceRegenerate>
            <plugins>
                <plugin>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.6.3</version>
                </plugin>
                <plugin>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-annotate</artifactId>
                    <version>0.6.3</version>
                </plugin>
            </plugins>
        </configuration>
    </plugin>
    

    Ain't a best practices but works fine.

    0 讨论(0)
提交回复
热议问题