Skip to content
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

xml-beans doesn't compile with Java 11 #1

Open
chevalleyc opened this issue Feb 13, 2019 · 11 comments
Open

xml-beans doesn't compile with Java 11 #1

chevalleyc opened this issue Feb 13, 2019 · 11 comments

Comments

@chevalleyc
Copy link

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.

@tuanho22
Copy link

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
Copy link

torbjornsk commented 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
Copy link

swwyatt commented Jan 21, 2021

When I added 1.8, the source did not have the List methods.

@chevalleyc
Copy link
Author

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
Copy link

robbytx commented 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:

<javaSource>1.5</javaSource><!-- only "1.5" is actually recognized, others values revert to "1.4" code -->
<noJavac>true</noJavac><!-- prevent XmlBeans from calling javac directly with "-source 1.5", which is unsupported on new Java versions -->

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:

warning: [options] bootstrap class path not set in conjunction with -source 5
error: Source option 5 is no longer supported. Use 6 or later.
error: Target option 1.5 is no longer supported. Use 1.6 or later.

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 whatever source version you have configured (or is automatically selected) in your project.

@mpet
Copy link

mpet commented 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
Copy link

robbytx commented 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
Copy link

Himaja77 commented 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
Copy link

robbytx commented 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
Copy link

It worked

@Himaja77
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants