sdaschner / jaxrs-analyzer

Creates REST documentation for JAX-RS projects
Apache License 2.0
319 stars 101 forks source link

Maven plugin fails with NullPointerException for module in 0.17, worked in 0.16. #182

Open dirtylabcoat opened 5 years ago

dirtylabcoat commented 5 years ago

Our project has two modules, both with JAX-RS resources. With 0.16 we could generate docs for both modules, but since upgrading to 0.17 generating for one of them fails with a NullPointerException like this: [ERROR] Failed to execute goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.17:analyze-jaxrs (rest-resources-swagger-ui) on project module1: Execution rest-resources-swagger-ui of goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.17:analyze-jaxrs failed.: NullPointerException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.17:analyze-jaxrs (rest-resources-swagger-ui) on project module1: Execution rest-resources-swagger-ui of goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.17:analyze-jaxrs failed. at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) 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:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) 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.PluginExecutionException: Execution rest-resources-swagger-ui of goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.17:analyze-jaxrs failed. at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) 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:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) 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: java.lang.NullPointerException at java.util.Objects.requireNonNull (Objects.java:203) at com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier.<init> (MethodIdentifier.java:49) at com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier.of (MethodIdentifier.java:180) at com.sebastian_daschner.jaxrs_analyzer.model.methods.MethodIdentifier.ofNonStatic (MethodIdentifier.java:161) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocParserVisitor.calculateMethodIdentifier (JavaDocParserVisitor.java:181) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocParserVisitor.recordMethodComment (JavaDocParserVisitor.java:115) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocParserVisitor.lambda$visit$2 (JavaDocParserVisitor.java:110) at java.util.Optional.ifPresent (Optional.java:159) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocParserVisitor.visit (JavaDocParserVisitor.java:110) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocParserVisitor.visit (JavaDocParserVisitor.java:38) at com.github.javaparser.ast.body.MethodDeclaration.accept (MethodDeclaration.java:118) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.lambda$visit$61 (VoidVisitorAdapter.java:267) at java.util.ArrayList.forEach (ArrayList.java:1257) at com.github.javaparser.ast.NodeList.forEach (NodeList.java:255) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit (VoidVisitorAdapter.java:267) at com.github.javaparser.ast.body.EnumDeclaration.accept (EnumDeclaration.java:91) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.lambda$visit$40 (VoidVisitorAdapter.java:192) at java.util.ArrayList.forEach (ArrayList.java:1257) at com.github.javaparser.ast.NodeList.forEach (NodeList.java:255) at com.github.javaparser.ast.visitor.VoidVisitorAdapter.visit (VoidVisitorAdapter.java:192) at com.github.javaparser.ast.CompilationUnit.accept (CompilationUnit.java:126) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzer.parseJavaDoc (JavaDocAnalyzer.java:64) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzer.lambda$invokeParser$0 (JavaDocAnalyzer.java:58) at java.lang.Iterable.forEach (Iterable.java:75) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzer.invokeParser (JavaDocAnalyzer.java:58) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzer.invokeParser (JavaDocAnalyzer.java:38) at com.sebastian_daschner.jaxrs_analyzer.analysis.javadoc.JavaDocAnalyzer.analyze (JavaDocAnalyzer.java:31) at com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzer.analyze (ProjectAnalyzer.java:107) at com.sebastian_daschner.jaxrs_analyzer.JAXRSAnalyzer.analyze (JAXRSAnalyzer.java:47) at com.sebastian_daschner.jaxrs_analyzer.maven.JAXRSAnalyzerMojo.execute (JAXRSAnalyzerMojo.java:226) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) 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:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:309) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:194) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:107) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:955) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290) at org.apache.maven.cli.MavenCli.main (MavenCli.java:194) 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)

I can't post any code from the module due to agreement with client, but I need help to get this to work. Where do I start debugging this? Is anybody else experiencing this issue with 0.17?

rmpestano commented 5 years ago

Hi @dirtylabcoat,

the NPE is being raised here which is being called here.

So these are good points to debug.

To debug you'll need to clone v0.17 and import it on your workspace then do a mvnDebug jaxrs-analyzer:analyze-jaxrs on your project and use a remote debug on port 8000.

If you provide a reproducer project I can try to help fixing the issue.

Thank you for reporting.

dizzzz commented 5 years ago

I encounter the same issue here (see attachment) ; How to create a reproducible project.... that will be tricky for me. trace.txt

dizzzz commented 5 years ago

@rmpestano about the NPE... it looks to fail on a maven (sub)module which does not have any JAXRS annotations. Still investigating....

dizzzz commented 5 years ago

Here is the problem... className == null

image

dizzzz commented 5 years ago

at least the following makes sure the proces continues :-)

image

I can't figure out the flow yet why 'className' is not set... or if it is a wrong assumption it should be set ....@rmpestano

jerith666 commented 3 years ago

This looks to be duplicated by #191.