Open
Description
The workaround is for now to force using java 8 in pom.xml as follows:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<schemaDirectory>src/main/xsd</schemaDirectory>
<compiler>/usr/lib/jvm/java-8-openjdk-amd64/bin/javac</compiler>
</configuration>
</plugin>
the compiler
parameter should specify an alternative path to a java 8 compiler.
Activity
tuanho22 commentedon Aug 10, 2019
Hello chevalleyc. Is there a fix for this xml-beans compile error against Java 11 or are you still using the workaround? The error I am getting is:
Failed to execute goal org.codehaus.mojo:xmlbeans-maven-plugin:2.3.3:xmlbeans (default) on project : XmlBeans compile failed: xml ErrorLoading schema file
torbjornsk commentedon Aug 29, 2019
To be able to use the xmlbeans-maven-plugin with Java 11, add the following configuration element:
<javaSource>1.8</javaSource>
swwyatt commentedon Jan 21, 2021
When I added 1.8, the source did not have the List methods.
chevalleyc commentedon Jan 22, 2021
Have you evaluated migrating to EHRbase? EHRbase 1.0 (early April 21) will support FLAT json format along with canonical JSON and XML. There has been a tremendous development effort on this platform since 1 1/2 year. I would recommend you give it a try if not already done. Cheers!
robbytx commentedon Jul 14, 2021
There has been recent activity in the XmlBeans project, but I was unable to successfully use the
org.codehaus.mojo:xmlbeans-maven-plugin[:2.3.3]
plugin with newer versions.Apparently one of the changes in XmlBeans 5 is its own Maven plugin, which seems like the long-term solution, but I'm not prepared to make the switch just yet.
However, I've actually found an interim workaround to stick with the older XmlBeans 2.x library, by combining the following two options:
In this configuration, XmlBeans will generate its binary information, along with its Java 1.5-compatible source (including List<...> methods). Meanwhile, the
noJavac
option avoids the internal Javac call that results in the unsupported error on Java 11:In my configuration, the generated source code is attached as a source directory that is processed by the standard
maven-compiler-plugin
, which happily accepts the older source code with whateversource
version you have configured (or is automatically selected) in your project.mpet commentedon Dec 14, 2021
@robbytx could you share your pom.xml since I don't know how to include the bean files that is needed for compilation.
robbytx commentedon Feb 1, 2022
Sorry @mpet, I've changed companies since my comment and I no longer have access to the project where this was in use.
I believe the POM at the top of this issue shows how to generate the sources using the older plugin. Many Maven plugins that generate source code will automatically "attach" the generated source code directory to the project so that it will be included in compilation. If that's not happening for you, then you can use the build-helper-maven-plugin to explicitly add the directory where XmlBeans emits its sources. Hope that helps.
Himaja77 commentedon Nov 14, 2022
Hi, can anyone help me regarding this matter
I was trying to update my code to java 11 but can't able to build due to this XML beans
The error I am getting
Error: bootstrap class path not set in conjunction with - source 1.4
Error: source option 1.4 is no longer supported. Use 6 or later
Error: Target option 1.4 is no longer supported. Use 6 or later
Org.codehaus.mojo.xmlbeans.xmlbeansexception: compile failed
robbytx commentedon Nov 15, 2022
@himukk did you try adding
<noJavac>true</noJavac>
to your<configuration>
element for the plugin? I discussed this issue in my comment above.Himaja77 commentedon Nov 15, 2022
It worked
Himaja77 commentedon Nov 15, 2022
Thank you