metadatacenter / cedar-submission-server

CEDAR server to handle submissions to metadata repositories
Other
0 stars 1 forks source link

Fails to compile with Java 16.0.1 #47

Open martinjoconnor opened 3 years ago

martinjoconnor commented 3 years ago

Works with Java version 15. Following error with Java 16.0.1:

[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.14.0:generate (default) on project cedar-submission-server-core: Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.14.0:generate failed: Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null -> [Help 1]
martinjoconnor commented 3 years ago

Note that this is an issue with the maven-jaxb2-plugin (latest version 0.14.0, https://mvnrepository.com/artifact/org.jvnet.jaxb2.maven2/maven-jaxb2-plugin), which is used only by the submission server - not the Mojo jaxb2-maven-plugin (https://www.mojohaus.org/jaxb2-maven-plugin/Documentation/v2.2/), which is used elsewhere in CEDAR.

johardi commented 2 years ago

What is the solution for this? I got the same error when compiling with Java 11

johardi commented 2 years ago

The error message is gone now-- all good!

marcosmro commented 2 years ago

I'm not having issues with Java 11. Are you getting exactly that error or maybe this one (related to jaxb2-maven-plugin) https://github.com/mojohaus/jaxb2-maven-plugin/issues/115? Our workaround is explained at https://github.com/metadatacenter/cedar-project/issues/1015 and https://github.com/metadatacenter/cedar-mkdocs-developer/blob/develop/site/index.html (in short, you just have to just run createjaxb2workaround)

johardi commented 2 years ago

I've executed createjaxb2workaround but the error still persists. In addition, I got this error message as well:

...
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
    at java.base/java.lang.Class.getMethod(Class.java:2227)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:201)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:197)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
    ... 140 more

After browsing around, I found this workaround and I can compile the submission server. Basically you added <dependencies> to maven-jaxb-plugin in the submission-server-core's POM.

    <build>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.14.0</version>
                <dependencies>
                    <dependency>
                        <groupId>org.glassfish.jaxb</groupId>
                        <artifactId>jaxb-runtime</artifactId>
                        <version>2.3.3</version>
                    </dependency>
                </dependencies>
                <executions>
                                ...
johardi commented 2 years ago

This also fixes the same error for the impex server

marcosmro commented 2 years ago

It would be good to know if this fix has any effects on the model transformations done by the submissions and impex servers. It's good that the projects compile, but if we want consider merging this to develop we have to be sure that there are no side effects

johardi commented 2 years ago

Let me make a pull request so you can test it and do the merge when you see it fits