Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Pointer Exception - Need better error message #344

Closed
JenCoston opened this issue Jun 22, 2016 · 2 comments
Closed

Null Pointer Exception - Need better error message #344

JenCoston opened this issue Jun 22, 2016 · 2 comments

Comments

@JenCoston
Copy link

My code is throwing a null pointer exception when I add the swagger-maven-plugin to my pom.xml file. It runs without it and I can access both the api and the swagger ui. From the console output it looks like the error may be thrown when trying to scan the target classes. Is there a way to get a more helpful error message?

Here is the console output:
[DEBUG] going to scan these urls:
file:/C:/Swagger/HelloService/MyApp/HelloService/target/classes/
[INFO] Reflections took 124 ms to scan 1 urls, producing 17 keys and 29 values
[DEBUG] resolveProperty void
[DEBUG] resolveProperty [simple type, class void]
[DEBUG] resolve [simple type, class void]
[DEBUG] trying extension com.github.kongchen.swagger.docgen.reader.ModelModifier@5ee77baf
[DEBUG] Can't check class [simple type, class void], void
[DEBUG] defineModel void io.swagger.models.ModelImpl@bafd15c1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.039 s
[INFO] Finished at: 2016-06-22T09:04:41-04:00
[INFO] Final Memory: 27M/409M
[INFO] ------------------------------------------------------------------------

Here is the error message:
[ERROR] Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.2:generate (default) on project HelloService: null: MojoExecutionException: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.2:generate (default) on project HelloService: null
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
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:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
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: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.MojoExecutionException
at com.github.kongchen.swagger.docgen.mavenplugin.ApiDocumentMojo.execute(ApiDocumentMojo.java:114)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.lang.NullPointerException
at com.github.kongchen.swagger.docgen.reader.AbstractReader.updateApiResponse(AbstractReader.java:470)
at com.github.kongchen.swagger.docgen.reader.JaxrsReader.parseMethod(JaxrsReader.java:318)
at com.github.kongchen.swagger.docgen.reader.JaxrsReader.read(JaxrsReader.java:93)
at com.github.kongchen.swagger.docgen.reader.JaxrsReader.read(JaxrsReader.java:50)
at com.github.kongchen.swagger.docgen.reader.JaxrsReader.read(JaxrsReader.java:41)
at com.github.kongchen.swagger.docgen.mavenplugin.MavenDocumentSource.loadDocuments(MavenDocumentSource.java:46)
at com.github.kongchen.swagger.docgen.mavenplugin.ApiDocumentMojo.execute(ApiDocumentMojo.java:84)
... 22 more
[ERROR]

Here is the plugin from the pom.xml file:
<!-- Swagger Plugin to Generate YAML/JSON Files at Compile Time --> <plugin> <groupId>com.github.kongchen</groupId> <artifactId>swagger-maven-plugin</artifactId> <version>3.1.2</version> <configuration> <apiSources> <apiSource> <springmvc>false</springmvc> <locations>com.mt.company.swagger.api</locations> <info> <title>Swagger Generated Files Example</title> <version>v1</version> <description>This is an example of the generated swagger files</description> </info> <outputFormats>json,yaml</outputFormats> <swaggerDirectory>${basedir}\src\main\resources</swaggerDirectory><!--directory the generated file will be put in --> <attachSwaggerArtifact>true</attachSwaggerArtifact> </apiSource> </apiSources> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin>

@JenCoston
Copy link
Author

Hello,

When I updated the jar from version 3.1.2 to 3.1.3 this error went away. Is version 3.1.2 no longer supported?

Thanks!

@carlosjgp
Copy link
Contributor

Maybe this version changed is related with some bug fixes...? And probably NullPointerException is one of them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants