Issue
I'm currently trying to build a legacy project which has been migrated from Ant to Maven. This project uses the xmlbeans-maven-plugin
to build java classes from .xsd
source files. Everything works fine until a get...List()
method gets called. All List-getters seem to be missing. All the information I could find points to a Java version being used that does not support Lists. The solution that worked for most people was changing the javaSource
tag in the plugin configuration to 1.5
. This did not solve my problem.
The relevant part of my pom.xml
currently looks like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<configuration>
<javaSource>1.8</javaSource>
<schemaDirectory>src/main/xsd</schemaDirectory>
</configuration>
</plugin>
Another stackoverflow thread (Maven2:List return type methods not getting generated from .xsd files while using xmlbeans plugin), from 2011 mind you, suggests to set the Java version to 1.5 instead. This gives me another error:
Failed to execute goal org.codehaus.mojo:xmlbeans-maven-plugin:2.3.3:xmlbeans (default) on project ...: XmlBeans compile failed:
xml ErrorLoading schema file ...
xml ErrorLoading schema file ...
xml ErrorLoading schema file ...
xml ErrorLoading schema file ...
xml ErrorLoading schema file ...
The solution for this problem I found here tells me this is a problem with Java 11 and that I should set the Java version to 1.8.
Here's a snippet of one of the .xsd
files:
<xs:element name="DbcFile" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="path" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
This should generate a method called getDbcFileList()
. However, as you can see from this error message, it does not do that:
... cannot find symbol
symbol: method getDbcFileList()
It does generate getDbcFileArray()
. I have tried a lot of combinations of changing Java versions, removing the build folder every time to get a clean build, you name it. I'm honestly out of ideas.
I'm using Maven 3.6.3 and OpenJDK 13.0.2+8_2. I'm running maven commands from IntelliJ 2020.1. The only thing I haven't tried is downgrading my JDK, but I feel like that won't make a difference.
Solution
I solved it. The solution was to downgrade to JDK 1.8, for some reason.
Answered By - YSbakker
Answer Checked By - Robin (JavaFixing Admin)