-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepare jaxb2-maven-plugin to run on JDK 11 #43
Comments
At the moment, some plugins which we depend upon are not yet updated for Java9.
|
We're seeing a similar issue for Drools, when running a build, that works on JDK 8, on JDK 9: https://issues.jboss.org/browse/DROOLS-1170 |
This is not an unimportant issue by any means. However, I am tempted to defer starting fixing it until this autumn to give |
@lennartj A lot of high profile projects are now in full throttle in testing against JDK 9, as part of the "JDK 9 quality outreach" program started a few months ago. Here's a list of those projects: That has been direct cause for us to start testing against JDK 9. |
For now I'm not using the jaxb2-maven-plugin for my Java 9 experiments as I couldn't get it to work. For some reason it would ignore the JAXB binding file I need to use (and which always was applied when using the plug-in with JDK 8). So I'm invoking xjc explicitly now with some Maven trickery. I'm going to share it here, maybe it's helpful to others:
|
I am quite aware of this; although we will include support for JDK9 within the plugin I will start with a much-needed release (2.3) handling enums, enhanced schema generation and various other fixes. After that, we should approach 2 things:
|
And also - Thanks @gunnarmorling for sharing the Exec-plugin recipe. |
For the 2.4 version of the plugin (or perhaps we should move to 3.0 for this feature), we should support JDK 9. |
I am getting this error with 2.3.1 version:
Any plan to fix this issue ? is there a schedule for 2.4 ? |
There are clear plans to fix it. ... so this issue requires a tad more attention to detail than usual, to enable the plugin to run both on JDK8 and earlier and (using the same codebase) JDK9 |
thank you @lennartj for your quick reply. I see your point, I will wait. |
On that specific one, it may be a good idea to produce a multi-release JAR, allowing to have different versions of specific classes, each tied to one Java version. I've blogged about building MR JARs recently. |
The workaround with exec-maven-plugin is not working in my (current) environment, it throws: "A type incompatibility occurred while executing org.codehaus.mojo:exec-maven-plugin:1.6.0:exec: java.base/java.lang.String cannot be cast to org.codehaus.mojo.exec.Modulepath"... And jaxb2-maven-plugin is still not runnable with Java 9 (it uses classes which are moved to an internal package, so it is not even possible to just open the visibility...). You have 2,5 months at maximum to get this working. ;-) Update: Ok, it is working when version 1.5 of the exec-maven-plugin instead of the newer version 1.6. And I had to set the -encoding parameter. And I had require the deprecated java.xml.bind module. Now the project is working with Java 9. |
https://stackoverflow.com/questions/46356092/jaxb2-maven-plugin-failing-on-java-9 is a good hint. For these java.se.ee modules we should find the matching dependency in Central. Most should be there, and it will also work with earlier java version(s). |
I fixed this issue by launching
Maybe this helps in finding a solution for jaxb2-maven-plugin that is downwards compatible. Also, if you get the error |
Is there progress in resolving this problem when using Java 9 ?
|
Any news on this? |
Will start the development transition from the Maven2 compliant plugin to the Maven3 (and Java9) compliant plugin next week. |
Currently, there are a few plugins and/or code quality dependencies which are not Java 9 compliant. Among those are Cobertura and Checkstyle. |
Java10 on the horizon, you guys still lack support for Java9 :( |
I'm also a bit worried about the fact that this plugin does not work for Java 9. The main problems seem to be related to schema bindings (#104) and the episode generation. These issues are seen in the Obviously I'd prefer if the maven plugin ecosystem would be fully Java 9 compliant - but apparently that is easier said then done. |
FYI: Found that http://cxf.apache.org/cxf-xjc-plugin.html (version 3.2.1) - does honor schemaBindings correctly. So these guys apparently have fixed the issue ~ which they also ran into. |
I've released xjc-maven-plugin to Maven Central and it's working well for me. I did use @subes' approach (fork a process and call The plugin is unit tested on Oracle JDK 8, 9, 10, 11 and OpenJDK 10, 11 (using Travis). Hope that's useful for others too while jaxb2-maven-plugin is getting sorted out. |
@davidmoten : Thanks a lot for your solution. It's working almost fine on my project generating sources from xsds. Unfortunately, the xjc plugin generates its output in windows default encoding rather than UTF-8. Is there any way do configure it to produce UTF-8? |
@chrlembeck I think you can just change the system property file.encoding and xjc will pick it up: https://stackoverflow.com/questions/361975/setting-the-default-java-character-encoding Maybe you can do this inside your pom.xml with a simple property tag, otherwise a configuration option needs to be added to the plugin. |
@subes, @davidmoten: I tried both: Adding |
Ok, it seems XJC has an option to set the encoding: https://docs.oracle.com/javase/9/tools/xjc.htm#JSWOR741
So using a configuration option and passing this as the parameter should solve the issue. Or maybe just pass the file.encoding property value as the option. |
I got the current version of this plugin working on JDK 8, 9, 10, 11 just by explicitly declaring all the necessary dependencies: <dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>......</packageName>
</configuration>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build> |
Doesn't work for me. "[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.4:xjc (XJC Build) on project test-backend: Prefix '' is already bound to '' -> [Help 1] |
Hi all, I got the solution thanks to the excellent work of @davidmoten . |
Glad to hear it's working @RickDeckard76, I've migrated the xjc-maven-plugin code to a more generic plugin jax-maven-plugin that supports |
I confirm that @edwardxia solution works for OpenJDK 10. (After 4 hours looking everywhere... I finally got it working on java 10. Hope it will works for 11 when we migrate to 11 :/ |
I confirm, it works on JDK11 (I used openJDK11 and AdoptOpenJDK11) |
For me the solution provided by @edwardxia didn't work without adding a special workaround - I needed to add an extra, dummy XSD file to my project to get rid of the error: I've described the full solution here: https://artofcode.wordpress.com/2019/02/26/jaxb2-maven-plugin-2-4-and-java-11/ This workaround was verified for OpenJDK 11 . |
Also move Xalan to the runtime dependencies: some integration tests appear to be sensitive to subtle differences in the transformer output between Java versions.
Also move Xalan to the runtime dependencies: some integration tests appear to be sensitive to subtle differences in the transformer output between Java versions. Finally, add Java >= 9 to the Travis config to prevent regression.
Also move Xalan to the runtime dependencies: some integration tests appear to be sensitive to subtle differences in the transformer output between Java versions. Finally, add Java >= 9 to the Travis config to prevent regression.
Also move Xalan to the runtime dependencies: some integration tests appear to be sensitive to subtle differences in the transformer output between Java versions. Finally, add Java 9 and 10 to the Travis config to prevent regression. Java 11 will require an additional fix.
Also move Xalan to the runtime dependencies: some integration tests appear to be sensitive to subtle differences in the transformer output between Java versions. Finally, add Java 9 and 10 to the Travis config to prevent regression. Java 11 will require an additional fix.
- Upgrade the JAXB implementation to 2.3.2. - Remove the profiles that were used to work around Java compatibility issues in previous JAXB versions. - Remove some direct dependencies and instead rely on transitive dependencies from JAXB (so that we don't need to adjust them when upgrading to a new JAXB version). - Update the integration tests to add the relevant dependencies for APIs that were removed from the JRE in Java 11. Fixes mojohaus#43.
Hi, I am using OpenJDK 11.0.2 and I tried your approach but I am getting the following error: org.xml.sax.SAXParseException: External parsing is disabled. Cannot parse URI: file:/Path_to_my/my.dtd I checked the permissions of my.dtd, and it should be able to read it, I even changed them to all read, write and execute. It still fails, any suggestions for OpenJDK 11 ? |
Updated all JAXB-API dependencies to the Jakarta artifacts (see #138), and got the full suite of IT tests to build on JDK 11 as well. However, it implies that one adds the dependency below (since the javax.xml.bind is not in the JDK any longer): <dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency> |
@edwardxia magic mate! such a minefield to get this plugin working with java 11. i just wanted to use schema gen... |
Hi , Java - 17 In properties Tag add below version , In Build Tag ,
After this JAXB-2 Implementation was successfully generated . Make sure to add below dependency as well helpful to provide implementation during runtime (When we run the main class)
This should work for all those struggling with Java 17 and spring boot version 2.7.4+ with jabxb2 maven plugin. |
Hi, when running the jaxb2-maven-plugin on JDK 9 I am getting quite a handful of errors due to the usage of classes previously present in tools.jar and now not exposed any longer.
I could make it work by adding the following dependencies to my plugin configuration:
I think the plug-in could be changed to always use these dependencies instead of relying on JDK-internal classes. Unfortunately, the POMs of these dependencies resolve to a non-existing variable ${tools}, so a warning about the POMs being invalid will be issued by mvn, but JAXB seems to work fine with them.
The text was updated successfully, but these errors were encountered: