swagger-codegen-maven-plugin generated SDK is corrupted

Created on 18 Apr 2017  路  26Comments  路  Source: swagger-api/swagger-codegen

I am using currently stable (2.2.2) swagger-codegen-maven-plugin to generate client code. But it gave me error, my plugin is,

<plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <language>java</language>
                            <inputSpec>http://localhost:8080/api/v2/api-docs</inputSpec>
                            <configOptions>
                                <sourceFolder>src/gen/java/main</sourceFolder>
                            </configOptions>
                            </configuration>
                    </execution>
                </executions>
            </plugin>

error is,

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/ParticipantType.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/ParticipantType.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[16,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[17,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[18,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[19,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[20,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[21,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[22,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[23,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[24,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[25,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[26,41] package com.squareup.okhttp.internal.http does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[27,35] package com.squareup.okhttp.logging does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[28,58] package com.squareup.okhttp.logging.HttpLoggingInterceptor does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[74,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[75,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[16,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[17,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[21,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[22,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[23,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[24,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[25,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[27,43] cannot find symbol
  symbol: class ResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[16,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[17,27] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[21,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[22,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[23,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[24,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[25,12] package okio does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[27,42] cannot find symbol
  symbol: class RequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[59,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[100,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/ResourceReference.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/ResourceReference.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[150,31] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[177,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[218,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[260,31] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[287,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[329,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[379,31] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[406,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[447,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/ParticipantTypeApi.java:[497,31] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[131,13] cannot find symbol
  symbol:   class OkHttpClient
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[134,13] cannot find symbol
  symbol:   class HttpLoggingInterceptor
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[193,12] cannot find symbol
  symbol:   class OkHttpClient
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[203,36] cannot find symbol
  symbol:   class OkHttpClient
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[802,30] cannot find symbol
  symbol:   class Response
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[861,12] cannot find symbol
  symbol:   class RequestBody
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[888,42] cannot find symbol
  symbol:   class Response
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[907,37] cannot find symbol
  symbol:   class Response
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[951,39] cannot find symbol
  symbol:   class Call
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[966,39] cannot find symbol
  symbol:   class Call
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[983,34] cannot find symbol
  symbol:   class Call
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[997,34] cannot find symbol
  symbol:   class Call
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[1028,33] cannot find symbol
  symbol:   class Response
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[1064,12] cannot find symbol
  symbol:   class Call
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[1145,78] package Request does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[1177,12] cannot find symbol
  symbol:   class RequestBody
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ApiClient.java:[1192,12] cannot find symbol
  symbol:   class RequestBody
  location: class io.swagger.client.ApiClient
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[33,19] cannot find symbol
  symbol:   class ResponseBody
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[35,13] cannot find symbol
  symbol:   class BufferedSource
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[37,33] cannot find symbol
  symbol:   class ResponseBody
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[43,12] cannot find symbol
  symbol:   class MediaType
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[53,12] cannot find symbol
  symbol:   class BufferedSource
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[60,27] cannot find symbol
  symbol:   class Source
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressResponseBody.java:[60,13] cannot find symbol
  symbol:   class Source
  location: class io.swagger.client.ProgressResponseBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[33,19] cannot find symbol
  symbol:   class RequestBody
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[37,13] cannot find symbol
  symbol:   class BufferedSink
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[39,32] cannot find symbol
  symbol:   class RequestBody
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[45,12] cannot find symbol
  symbol:   class MediaType
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[55,25] cannot find symbol
  symbol:   class BufferedSink
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[65,23] cannot find symbol
  symbol:   class Sink
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/ProgressRequestBody.java:[65,13] cannot find symbol
  symbol:   class Sink
  location: class io.swagger.client.ProgressRequestBody
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Plan.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Plan.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Amount.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Amount.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Service.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Service.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/SummarisationCriteria.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/SummarisationCriteria.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/SummarisationApi.java:[59,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/SummarisationApi.java:[100,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/SummarisationApi.java:[150,31] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/SummarisationApi.java:[177,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/SummarisationApi.java:[219,32] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/api/SummarisationApi.java:[269,31] package com.squareup.okhttp does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/AggregationCriteria.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/AggregationCriteria.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Subscription.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Subscription.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Participant.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/Participant.java:[19,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/SubscriptionDefinition.java:[18,30] package io.swagger.annotations does not exist
[ERROR] /data/n_ame/ame/core/target/generated-sources/swagger/src/main/java/io/swagger/client/model/SubscriptionDefinition.java:[19,30] package io.swagger.annotations does not exist
[INFO] 100 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Aepona monetization Engine ......................... SUCCESS [  2.334 s]
[INFO] Aepona monetization Engine - Core .................. FAILURE [  2.240 s]
[INFO] Aepona monetization Engine - API ................... SKIPPED
[INFO] Aepona monetization Engine - Input Processing ...... SKIPPED
[INFO] Aepona monetization Engine - Pre Processing ........ SKIPPED
[INFO] Aepona monetization Engine - Settlement ............ SKIPPED
[INFO] Aepona monetization Engine - Reporting ............. SKIPPED
[INFO] Aepona monetization Engine - API - Docs ............ SKIPPED
[INFO] Aepona monetization Engine - Release ............... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.334 s
[INFO] Finished at: 2017-04-24T10:47:17+05:30
[INFO] Final Memory: 50M/410M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project com.aepona.monetization.core: Compilation failure: Compilation failure
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project com.aepona.monetization.core: Compilation failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 20 more

This happen when i use mvn clean install -e.
I can create client code without using the maven plugin using this,

java -jar /data/Swagger/swagger-codegen-cli.jar generate \
  -i http://localhost:8080/api/v2/api-docs \
  -l java\
  -o /data/SDK

so i think the error is in the plugin, so can someone help me to fix it, thanks!

UsagInstallation Swagger Codegen Maven Plugin help wanted

Most helpful comment

I face the same issue, here is the workaround.
Copy [dependencies from the generated pom.xml in target/generated-sources/swagger/pom.xml + 2 others identified manually by imports in the code] into your pom.xml:

<dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
      <version>${swagger-core-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>okhttp</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>logging-interceptor</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson-version}</version>
    </dependency>

    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>${jodatime-version}</version>
    </dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.5.4</version>
</dependency>

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <type>jar</type>
      <version>1.1.0.Final</version>
    </dependency>

All 26 comments

@wing328 can you help

@cmb28 I wanted to but had no clue why it's not working given that the swagger-codegen-cli works without issue.

I face the same issue, here is the workaround.
Copy [dependencies from the generated pom.xml in target/generated-sources/swagger/pom.xml + 2 others identified manually by imports in the code] into your pom.xml:

<dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
      <version>${swagger-core-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>okhttp</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.squareup.okhttp</groupId>
      <artifactId>logging-interceptor</artifactId>
      <version>${okhttp-version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson-version}</version>
    </dependency>

    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>${jodatime-version}</version>
    </dependency>

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.5.4</version>
</dependency>

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <type>jar</type>
      <version>1.1.0.Final</version>
    </dependency>

I have the same problem. Allthough the workaround works, it is weird and cumbersome. There should be a way to include the generated pom as a dependency and get all the other dependencies transitively

I am using this plugin in version 2.3.1 and I still needed to import the dependencies manually.

im facing a similar issue - but my error is :
package io.swagger.configuration does not exist
this is my config :

 <configuration>
                            <inputSpec>${swagger.spec.url}</inputSpec>
                            <configOptions>
                                <bigDecimalAsString>true</bigDecimalAsString>
                                <dateLibrary>java8</dateLibrary>
                                <java8>true</java8>
                            </configOptions>
                            <language>spring</language>
                            <library>spring-cloud</library>
                            <generateApis>true</generateApis>
                            <generateModels>true</generateModels>
                            <generateApiDocumentation>false</generateApiDocumentation>
                            <generateModelDocumentation>false</generateModelDocumentation>
                            <modelPackage>${project.groupId}.esi.model</modelPackage>
                            <apiPackage>${project.groupId}.esi.api</apiPackage>
                            <invokerPackage>${project.groupId}.esi.invoker</invokerPackage>
                            <output>${project.basedir}</output>
                            <generateSupportingFiles>false</generateSupportingFiles>
                            <addCompileSourceRoot>false</addCompileSourceRoot>

                        </configuration>

oh and : the workaround doesnt work for me - most likely because i am using spring and spring-cloud. Im guessing there is some wild dependency-clash or something

are you able to fix the issue?
i am also facing same error package io.swagger.configuration does not exist
with similar configuration using springand spring-cloud.

sadly, the generator seems to be defunct right now - you need to download the swagger-codegen-cli (which seems to work in most parts) and generate your API class files manually, the maven package simply doesnt work whatsoever

@ppalsamy @InternetPseudonym thanks guys to check this. i'm going to prioritize this issue and let you know any update here.

@HugoMario any update?

is there any news on this?

Any update?

I was able to make 2.4.1 work after adding those config options to the plugin configuration

<configOptions> <dateLibrary>java8</dateLibrary> <java8>true</java8> </configOptions>

Still broken.

I have the same issue as well

Same problem here, but with the gradle (using swagger-codegen-cli:3.0.5) instead of maven. Work-around above also worked for me, but I had to convert the maven dependencies into gradle equivalents:

compile "org.springframework.boot:spring-boot-starter-web:2.1.+"
compile "org.springframework.boot:spring-boot-starter-tomcat:2.1.+"
compile "io.springfox:springfox-swagger2:2.7.0"
compile "io.springfox:springfox-swagger-ui:2.7.0"
compile "com.github.joschi.jackson:jackson-datatype-threetenbp:2.6.4"
compile "javax.validation:validation-api"
testCompile "org.springframework.boot:spring-boot-starter-test:2.1.+"

Also still getting this issue on maven 2.3.1, the workaround works but on top of that the generateSupportingFiles flag needs to be set to true. Or else I am getting errors along the line of cannot find symbol symbol: class ApiCallback

Managed to work on 2.2.2 with dependencies from above. 2.4.7 is broken.

I have the same issue with plugin version 2.3.2
```

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project auditlog: Compilation failure: Compilation failure:
[ERROR] /home/ahmed/PROJECTS/X_PROJECT/auditlog_test/src/main/java/com/orange/auditLog/controller/AuditLogController.java:[8,34] error: cannot find symbol
[ERROR] package com.orange.swagger.resource
[ERROR] /home/ahmed/PROJECTS/X_PROJECT/auditlog_test/src/main/java/com/orange/auditLog/controller/AuditLogController.java:[25,43] error: cannot find symbol
[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```

Indeed, I am experiencing the same issue with 2.4.8 ... :(

I added below dependency to my pom, and it worked:

    <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>jsr250-api</artifactId>
      <version>${javax-annotation-version}</version>
    </dependency>

It's weired , because javax.annotaion is already in rt.jar. Can someone explain why?

Is it fixed?
I'm trying to generate a client code (input.yml with one GET method) using the maven plugin, hitting mvn dependencies issues, It working fine if I manually copy the dependencies into the POM file. Is there anyway can i generate it without adding the the dependencies?

@java-guru yes, just generate the code to somewhere that's not in your maven source folders

In the configuration, just specify a different output folder beyond the scope of your maven compilation, and it won't be included.

If you want to reuse the code it generated, then you can republish to somewhere your CI will build it, and then include it as a (test) dependency in your own application pom, so that you can use it for integration tests.

You need to specify a different output folder (as @tadhgpearson said) or exclude the swagger output folder from compilation:

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <excludes>
            <exclude>**/swagger/**/*.java</exclude>
        </excludes>
    </configuration>
</plugin>

Otherwise, the resources generated by the Swagger plugin are compiled twice and the dependencies are not found.

The workaround provided (use the CLI) is not viable in a CI/CD process. I need the generated SDK to be automatically created, compiled, and pushed to a repository.

It worked with Java 8. The javax.annotation-api dependency should be included in the generated pom.xml.

I had to add a pom.mustache template file to get this working. This one is working for my project... you may need to make adjustments.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>{{groupId}}</groupId>
    <artifactId>{{artifactId}}</artifactId>
    <packaging>jar</packaging>
    <name>{{artifactId}}</name>
    <version>{{artifactVersion}}</version>
    <url>{{artifactUrl}}</url>
    <description>{{artifactDescription}}</description>
    <scm>
        <connection>{{scmConnection}}</connection>
        <developerConnection>{{scmDeveloperConnection}}</developerConnection>
        <url>{{scmUrl}}</url>
    </scm>

    <licenses>
        <license>
            <name>{{licenseName}}</name>
            <url>{{licenseUrl}}</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>{{developerName}}</name>
            <email>{{developerEmail}}</email>
            <organization>{{developerOrganization}}</organization>
            <organizationUrl>{{developerOrganizationUrl}}</organizationUrl>
        </developer>
    </developers>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M1</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>2.2.0</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12</version>
                <configuration>
                    <systemProperties>
                        <property>
                            <name>loggerPath</name>
                            <value>conf/log4j.properties</value>
                        </property>
                    </systemProperties>
                    <argLine>-Xms512m -Xmx1500m</argLine>
                    <parallel>methods</parallel>
                    <forkMode>pertest</forkMode>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- attach test jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar</goal>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add_sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>
                                src/main/java</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add_test_sources</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>
                                src/test/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.4</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <source>8</source>
                    <additionalparam>-Xdoclint:none</additionalparam>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>sign-artifacts</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.5</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp</groupId>
            <artifactId>okhttp</artifactId>
            <version>2.7.5</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp</groupId>
            <artifactId>logging-interceptor</artifactId>
            <version>2.7.5</version>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>2.1.5</version>
        </dependency>

        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>${swagger-core-version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>${gson-version}</version>
        </dependency>
        <!-- JSON processing: jackson -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-version}</version>
        </dependency>
        {{#joda}}
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${jodatime-version}</version>
        </dependency>
        {{/joda}}
        {{#threetenbp}}
        <dependency>
            <groupId>org.threeten</groupId>
            <artifactId>threetenbp</artifactId>
            <version>${threetenbp-version}</version>
        </dependency>
        {{/threetenbp}}
        <dependency>
            <groupId>io.gsonfire</groupId>
            <artifactId>gson-fire</artifactId>
            <version>${gson-fire-version}</version>
        </dependency>
        <dependency>
            <groupId>com.squareup.okio</groupId>
            <artifactId>okio</artifactId>
        <version>${okio-version}</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <swagger-core-version>1.5.15</swagger-core-version>
        <gson-version>2.6.1</gson-version>
        <gson-fire-version>1.8.2</gson-fire-version>
        <maven-plugin-version>1.0.0</maven-plugin-version>
        {{#joda}}
        <jodatime-version>2.9.9</jodatime-version>
        {{/joda}}
        {{#threetenbp}}
        <threetenbp-version>1.3.5</threetenbp-version>
        {{/threetenbp}}
        <okio-version>1.13.0</okio-version>
        <jackson-version>2.11.3</jackson-version>
    </properties>
</project>

the issue described in title is not longer present, i guess it was fixed earlier releases. I'm going to close this, but if someone get this specific issue please let me know.

Please, for a different issue file a new one and ping me there.

Was this page helpful?
0 / 5 - 0 ratings