Swagger-codegen: "package javax.xml.bind.annotation does not exist" error when java-12-openjdk is used

Created on 26 Jun 2019  路  4Comments  路  Source: swagger-api/swagger-codegen

Description

There is
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[17,33] package javax.xml.bind.annotation does not exist
error using java-12-openjdk

Swagger-codegen version

last master

Command line used for generation
git clone https://github.com/swagger-api/swagger-codegen
mvn clean package -DskipTests
........................
[INFO] Copying aether-util-1.0.0.v20140518.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/aether-util-1.0.0.v20140518.jar
[INFO] Copying swagger-codegen-2.4.6-SNAPSHOT.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/swagger-codegen-2.4.6-SNAPSHOT.jar
[INFO] Copying maven-settings-3.2.5.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/maven-settings-3.2.5.jar
[INFO] Copying uri-template-0.9.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/uri-template-0.9.jar
[INFO] Copying jackson-annotations-2.9.8.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/jackson-annotations-2.9.8.jar
[INFO] Copying slf4j-ext-1.7.12.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/slf4j-ext-1.7.12.jar
[INFO] Copying rhino-1.7R4.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/rhino-1.7R4.jar
[INFO] Copying jackson-coreutils-1.6.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/jackson-coreutils-1.6.jar
[INFO] Copying snakeyaml-1.23.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/snakeyaml-1.23.jar
[INFO] Copying commonmark-0.9.0.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/commonmark-0.9.0.jar
[INFO] Copying httpcore-4.4.4.jar to /home/aim/tmp/swagger-codegen/modules/swagger-codegen-maven-plugin/target/lib/httpcore-4.4.4.jar
[INFO] 
[INFO] --------------------< io.swagger:swagger-generator >--------------------
[INFO] Building swagger-generator 2.4.6-SNAPSHOT                          [5/5]
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ swagger-generator ---
[INFO] Deleting /home/aim/tmp/swagger-codegen/modules/swagger-generator/target
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) @ swagger-generator ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ swagger-generator ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ swagger-generator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- download-maven-plugin:1.2.1:wget (swagger-ui) @ swagger-generator ---
[INFO] Got from cache: /home/aim/.m2/repository/.cache/maven-download-plugin/master.tar.gz
[INFO] Expanding: /home/aim/tmp/swagger-codegen/modules/swagger-generator/target/master.tar.gz into /home/aim/tmp/swagger-codegen/modules/swagger-generator/target
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ swagger-generator ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 18 source files to /home/aim/tmp/swagger-codegen/modules/swagger-generator/target/classes
[INFO] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java: Some input files use or override a deprecated API.
[INFO] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/resource/SwaggerResource.java: Recompile with -Xlint:deprecation for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[17,33] package javax.xml.bind.annotation does not exist
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[19,27] package javax.xml.bind.annotation does not exist
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[58,6] cannot find symbol
  symbol:   class XmlTransient
  location: class io.swagger.generator.model.ApiResponse
[INFO] 3 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for swagger-codegen-project 2.4.6-SNAPSHOT:
[INFO] 
[INFO] swagger-codegen-project ............................ SUCCESS [  5.393 s]
[INFO] swagger-codegen (core library) ..................... SUCCESS [ 22.003 s]
[INFO] swagger-codegen (executable) ....................... SUCCESS [  4.181 s]
[INFO] swagger-codegen (maven-plugin) ..................... SUCCESS [  3.820 s]
[INFO] swagger-generator .................................. FAILURE [  1.044 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  38.291 s
[INFO] Finished at: 2019-06-26T09:32:59+04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project swagger-generator: Compilation failure: Compilation failure: 
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[17,33] package javax.xml.bind.annotation does not exist
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[19,27] package javax.xml.bind.annotation does not exist
[ERROR] /home/aim/tmp/swagger-codegen/modules/swagger-generator/src/main/java/io/swagger/generator/model/ApiResponse.java:[58,6] cannot find symbol
[ERROR]   symbol:   class XmlTransient
[ERROR]   location: class io.swagger.generator.model.ApiResponse
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :swagger-generator

````



##### Suggest a fix/enhancement

switch to java-10-openjdk

via 
sudo archlinux-java set java-10-openjdk

aim-server[~]$ sudo archlinux-java status
Available Java environments:
java-10-openjdk (default)
java-11-openjdk
java-12-openjdk
java-8-openjdk/jre
aim-server[~]$

```

related
https://stackoverflow.com/questions/52502189/java-11-package-javax-xml-bind-does-not-exist

Most helpful comment

Answer to my question above:

Just add those to your project:

                implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
                implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
                implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
                implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

as in #9637

All 4 comments

Did you solve your issue? If yes, how?

Answer to my question above:

Just add those to your project:

                implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
                implementation group: 'com.sun.xml.bind', name: 'jaxb-core', version: '2.3.0'
                implementation group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.3.0'
                implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'

as in #9637

@spaszek Can you help me understand what you mentioned? What is the implementation group and where should it go? I'm transitioning a project from JDK 8 to JDK 11 (long term support releases only), and I'm wondering if this is still a swagger codgen impediment. I appreciate your help (and following up on the original post that was several months old).

Was this page helpful?
0 / 5 - 0 ratings