Giter Club home page Giter Club logo

Comments (6)

jpdigital avatar jpdigital commented on August 15, 2024

No real idea what is happening here. Does the project contain any XML mapping files for Hibernate? Also, it would be helpful if you can provide an example project with the error. That would be helpful do investigate this error.

from hibernate5-ddl-maven-plugin.

heruan avatar heruan commented on August 15, 2024

I don't have any XML files, just annotations. But debugging I see Envers creates mapping files on the fly (in memory maybe) and then parses them. Worth noting I'm on Java 9 which needs to have an explicit dependency on java.xml.bind, but all works running the app normally and fails only with the plugin. Maybe Hibernate tricks the parsing process somehow?

from hibernate5-ddl-maven-plugin.

heruan avatar heruan commented on August 15, 2024

I've tested the plugin and it works if run with Java 1.8, but it fails with Java 9 throwing that exception. You can test this with just a simple entity annotated with @Audited and run the plugin with Java 9 (adding some additional dependencies [1]).

I've also recreated a bare-bone plugin to replicate the issue: https://github.com/heruan/hibernate-ddl-generator but unfortunately I didn't find a solution yet.

So currently this plugin does not work with Java 9 if there are Envers entities, maybe you wish to add a note for this in the README.

[1] Dependencies needed for the plugin to run with Java 9:

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.3.0</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.3.0</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>javax.activation-api</artifactId>
    <version>1.2.0</version>
</dependency>

from hibernate5-ddl-maven-plugin.

jwgmeligmeyling avatar jwgmeligmeyling commented on August 15, 2024

What if you add

<!DOCTYPE hibernate-mapping PUBLIC 
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

To your hbm file? Not sure if http://www.hibernate.org/xsd/orm/hbm is a valid DTD uri.

Edit I am aware that the hbm file in question is generated by envers. Perhaps we can try to see if we can reproduce the issue for various DTDs?

from hibernate5-ddl-maven-plugin.

jwgmeligmeyling avatar jwgmeligmeyling commented on August 15, 2024

Also, the 5.2 plugin is dependent on Hibernate 5.2.10, any post 5.2.10 fixes for Java 9+ support will not be available unless you specify the exact Hibernate artifact as plugin dependency.

(you may have to override hibernate-entitymanager as the plugin is dependent on that and not hibernate-core).

from hibernate5-ddl-maven-plugin.

heruan avatar heruan commented on August 15, 2024

Thanks to HHH-12893 and highsource/jaxb-tools#120 seems the issue is related to the Maven plugin runtime in Java 9 and 10 not binding XML schema.

Preloading the bindings as done by maven-jaxb2-plugin works around this:

void setupBindInfoPackage() {
    String nsuri = "http://www.hibernate.org/xsd/orm/hbm";
    String packageInfoClassName = "org.hibernate.boot.jaxb.hbm.spi.package-info";
    try {
        final Class<?> packageInfoClass = Class
                .forName(packageInfoClassName);
        final XmlSchema xmlSchema = packageInfoClass
                .getAnnotation(XmlSchema.class);
        if (xmlSchema == null) {
            this.getLog().warn(MessageFormat.format(
                    "Class [{0}] is missing the [{1}] annotation. Processing bindings will probably fail.",
                    packageInfoClassName, XmlSchema.class.getName()));
        } else {
            final String namespace = xmlSchema.namespace();
            if (nsuri.equals(namespace)) {
                this.getLog().warn(MessageFormat.format(
                        "Namespace of the [{0}] annotation does not match [{1}]. Processing bindings will probably fail.",
                        XmlSchema.class.getName(), nsuri));
            }
        }
    } catch (ClassNotFoundException cnfex) {
        this.getLog().warn(MessageFormat.format(
                "Class [{0}] could not be found. Processing bindings will probably fail.",
                packageInfoClassName), cnfex);
    }
}

from hibernate5-ddl-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.