kongchen / swagger-maven-plugin

JAX-RS & SpringMVC supported maven build plugin, helps you generate Swagger JSON and API document in build phase.
http://kongchen.github.io/swagger-maven-plugin/
Apache License 2.0
761 stars 450 forks source link

Plugin fails with "java.lang.ClassNotFoundException: List" on spring boot project #844

Open mayurvpatil opened 3 years ago

mayurvpatil commented 3 years ago

Used this plugin in existing spring boot project, I used same plugin with non spring boot project and it's working perfect.

Plugin used in POM is as follows,

<plugin>
    <groupId>com.github.kongchen</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>3.1.7</version>
    <configuration>
        <apiSources>
            <apiSource>
                <springmvc>true</springmvc>
                 <basePath>/</basePath>
                <locations>com.project</locations>
                <schemes>http,https</schemes>
                <!-- <basePath>/api</basePath> -->
                <info>
                    <title>MyService</title>
                    <version>${project.version}</version>
                </info>
                <swaggerDirectory>swagger</swaggerDirectory>
            </apiSource>
        </apiSources>
    </configuration>
</plugin>

Error as follows,

java.lang.ClassNotFoundException: List
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
    at io.swagger.util.ReflectionUtils.loadClassByName(ReflectionUtils.java:49)
    at io.swagger.jackson.ModelResolver.getInnerType(ModelResolver.java:841)
    at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:441)
    at com.github.kongchen.swagger.docgen.reader.ModelModifier.resolve(ModelModifier.java:96)
    at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:185)
    at com.github.kongchen.swagger.docgen.reader.ModelModifier.resolve(ModelModifier.java:90)
    at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:100)
    at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:236)
    at com.github.kongchen.swagger.docgen.reader.ModelModifier.resolve(ModelModifier.java:96)
    at io.swagger.jackson.ModelResolver.resolve(ModelResolver.java:185)
    at com.github.kongchen.swagger.docgen.reader.ModelModifier.resolve(ModelModifier.java:90)
    at io.swagger.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:100)
    at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:161)
    at io.swagger.jackson.ModelResolver.resolveProperty(ModelResolver.java:112)
    at com.github.kongchen.swagger.docgen.reader.ModelModifier.resolveProperty(ModelModifier.java:76)
    at io.swagger.converter.ModelConverterContextImpl.resolveProperty(ModelConverterContextImpl.java:80)
    at io.swagger.converter.ModelConverters.readAsProperty(ModelConverters.java:58)
    at com.github.kongchen.swagger.docgen.reader.AbstractReader.isPrimitive(AbstractReader.java:297)
    at com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader.parseMethod(SpringMvcApiReader.java:236)
    at com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader.read(SpringMvcApiReader.java:127)
    at com.github.kongchen.swagger.docgen.reader.SpringMvcApiReader.read(SpringMvcApiReader.java:70)
    at com.github.kongchen.swagger.docgen.AbstractDocumentSource.loadDocuments(AbstractDocumentSource.java:118)
    at com.github.kongchen.swagger.docgen.mavenplugin.ApiDocumentMojo.execute(ApiDocumentMojo.java:96)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    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:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.081 s
[INFO] Finished at: 2020-12-02T15:53:51+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.6:generate (default-cli) on project test-service: Unrecognized Type: [null] -> [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/MojoExecutionException
junaid88 commented 2 years ago

I am facing the same problem Any update?