[BUG][JAVA][Spring] Missing javax classes when using Java > 8
Created by: debovema
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
The generated project with spring
generator is not working with Java version greater than 8 (see https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j)
openapi-generator version
4.0.2
OpenAPI declaration file content or url
Command line used for generation
npx @openapitools/openapi-generator-cli@cli-4.0.2 generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g spring -o ./src
Steps to reproduce
Use Java > 8 with Maven 3.6+
$ java -version
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
$ mvn -version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.3, vendor: AdoptOpenJDK, runtime: /home/mathieu/.sdkman/candidates/java/11.0.3.hs-adpt
Default locale: fr_FR, platform encoding: UTF-8
OS name: "linux", version: "5.0.0-16-generic", arch: "amd64", family: "unix"
Then, steps to reproduce:
npx @openapitools/openapi-generator-cli@cli-4.0.2 generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g spring -o ./src
cd src
mvn spring-boot:run
will cause following error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.1.RELEASE:run (default-cli) on project openapi-spring: An exception occurred while running. null: InvocationTargetException: Error creating bean with name 'xmlModelPlugin': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.schema.XmlModelPlugin] from ClassLoader [java.net.URLClassLoader@2582b0ef]: javax/xml/bind/annotation/XmlType: javax.xml.bind.annotation.XmlType -> [Help 1]
Related issues/PRs
Related to #940
Suggest a fix
Fixed by #3188