jaxbhyperjaxb

ServiceConfigurationError when including HyperJaxb3 as a Maven dependency


I understand that the Hyperjaxb3 library will be quite useful for my project, read a couple of descriptions across multiple sites, and decided to embed it into my Spring-Hibernate project.

I have found a reference to Hyperjaxb3 in https://jaxb.java.net/, which looks pretty official, but the hyperlink - http://confluence.highsource.org/display/HJ3/Home - doesn't open.

I have found some old POM examples, included it into my project, and located some of the old versions references, tried to eliminate them, but right now it seems that I am bumping into a dependency on an old Hibernate version, the error is like this:

java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: Provider org.jvnet.hyperjaxb3.hibernate.plugin.HibernatePlugin could not be instantiated: java.lang.NoClassDefFoundError: org/hibernate/type/MutableType

I am wondering if there is better Maven entry, if the project is alive and how do I use it with moder Hibernate.

This is my pom excerpt about Hyperjaxb3, where I exclude some outdated links and specify the latest versions of other dependencies:

    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-core</artifactId>
        <version>${jaxb-version}</version>
    </dependency>        
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-xjc</artifactId>
        <version>${jaxb-version}</version>
    </dependency>  
    <!--<dependency>
        <groupId>org.jvnet.hyperjaxb3</groupId>
        <artifactId>hyperjaxb3</artifactId>
        <version>0.6.1</version>
    </dependency>        -->
    <dependency>
        <groupId>org.jvnet.hyperjaxb3</groupId>
        <artifactId>hyperjaxb3-hibernate-plugin</artifactId>
        <version>0.1</version>
        <exclusions>
            <exclusion>
                <groupId>hsqldb</groupId>
                <artifactId>hsqldb</artifactId>
            </exclusion>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.sf.saxon</groupId>
                <artifactId>saxon</artifactId>
            </exclusion>
            <exclusion>
                <groupId>net.sf.saxon</groupId>
                <artifactId>saxon-dom</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-xjc</artifactId>
            </exclusion>
        </exclusions>
    </dependency>  
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm</artifactId>
        <version>3.3.1</version>
    </dependency>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm-attrs</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.2.1</version>
    </dependency>

    <dependency>
        <groupId>commons-beanutils</groupId>   
        <artifactId>commons-beanutils</artifactId>
        <version>1.9.2</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>   
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>   
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>

I am not currently trying to generate annotated Hibernate entity classes, but POJOs from the PurchaseOdrer example. This is what I currently do:

public void initializeModel(String name, InputStream src, String dir) throws IOException, URISyntaxException{
    dir = Paths.get(new URL(dir).toURI()).toString();
    File directory = new File(dir);
    directory.mkdirs();

    SchemaCompiler sc = XJC.createSchemaCompiler();
    sc.setDefaultPackageName(this.getClass().getPackage().getName() + ".generated");

    InputSource is = new InputSource(src);
    is.setSystemId(name);

    sc.parseSchema(is);
    S2JJAXBModel model = sc.bind();
    JCodeModel codeModel = model.generateCode(null, null);

    CodeWriter cw = new FileCodeWriter(directory);        
    codeModel.build(cw);
}

Solution

  • Disclaimer: I'm the author of Hyperjaxb3.

    The project is hosted on GitHub:

    The latest version 0.6.1 is functional, works as it should.

    However, I don't develop it actively anymore.

    Will it work with the current version of hibernate?

    Version 0.6.1 works was tested with Hibernate 4.1.7. HJ3 is just a code generator which produces standard JPA-annotated classes. So chances are pretty good that it will work with latest versions of Hibernate.

    I just can't get the 0.6.1 jar from Maven. Seems like it was eliminated from maven repositories.

    Really? Still there.

    http://repo1.maven.org/maven2/org/jvnet/hyperjaxb3/hyperjaxb3-ejb-plugin/0.6.1/

    An I don't understand if I need the "hyperjaxb3-hibernate-plugin" 0.1 from the year 2011.

    You definitely don't.

    Or do you aware of any fork or an analog?

    Unfortunately, nothing comes close.