jaxrs-analyzer
jaxrs-analyzer copied to clipboard
Stack underflow error faced with jaxrs-analyzer v0.15
I am a Java developer and I downloaded v0.15 of your jaxrs-analyzer.jar and tried generating swagger documentation for my restful APIs developed using JAX-RS. I have java jdk 1.8 on my system and my Restful API has been compiled with jdk 1.8 as well.
I executed the jaxrs analyzer using the following command:-
java -jar jaxrs-analyzer.jar C:\Users\prashanth\others\workspa ce\JaxRSProject\classes --renderSwaggerTags -o helloservice.swagger.json
However, it fails with a stack underflow error and the following stack trace. It would be great if u could let me know why this is so. I developed a sample API with 1 basic GET and POST method each and the analyzer works fine but when I run it against my entire set of classes I get the stack underflow error mentioned above with the following stack trace:-
Exception in thread “main” java.lang.IllegalStateException: Runtime stack under-flow occurred.
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.reduction.StackSizeSimulator.buildStackSizes(StackSizeSimulator.java:53)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.reduction.RelevantInstructionReducer.reduceInstructions(RelevantInstructionReducer.java:55)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.MethodContentAnalyzer.interpretRelevantInstructions(MethodContentAnalyzer.java:59)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.MethodContentAnalyzer.addProjectMethods(MethodContentAnalyzer.java:110)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.MethodContentAnalyzer.addProjectMethods(MethodContentAnalyzer.java:112)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.MethodContentAnalyzer.findProjectMethods(MethodContentAnalyzer.java:88)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.ResourceMethodContentAnalyzer.analyze(ResourceMethodContentAnalyzer.java:57)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.BytecodeAnalyzer.analyzeBytecode(BytecodeAnalyzer.java:26)
at java.lang.Iterable.forEach(Iterable.java:75)
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.BytecodeAnalyzer.analyzeBytecode(BytecodeAnalyzer.java:18)
at com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzer.analyze(ProjectAnalyzer.java:107)
at com.sebastian_daschner.jaxrs_analyzer.JAXRSAnalyzer.analyze(JAXRSAnalyzer.java:69)
at com.sebastian_daschner.jaxrs_analyzer.Main.main(Main.java:94)
Thanks for pointing this out. Do you have more information that you can share along with this error? Unfortunately, these types of errors require more information about the bytecode in order to be resolved... Some basic sample would be helpful
Hey, I finally managed to create a minimal example, where this error occurs. It seems like a least one cause for this exception is performing += on an entry of an array:
package de._125m125.ktv2.servlets.apiv2;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
@Path("users/{user}/something")
public class TradeRestAPI {
private final int[] intArray = new int[2];
@POST
public Response createSomething() {
this.intArray[0] = this.intArray[0] + 1; // works
this.intArray[0] += 1; // fails
return Response.status(200).build();
}
}
full output of maven build:
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ktv2 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ ktv2 ---
[INFO] Deleting /home/.../workspace/.../target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ktv2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ ktv2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/.../workspace/.../target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ktv2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ ktv2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- jaxrs-analyzer-maven-plugin:0.16:analyze-jaxrs (default) @ ktv2 ---
[INFO] analyzing JAX-RS resources, using Swagger backend
[INFO] Generating resources at /home/.../workspace/.../target/ktv2-0.0.1/static/documentation/jaxrs-analyzer/swagger.json
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.931 s
[INFO] Finished at: 2018-05-30T14:07:05+02:00
[INFO] Final Memory: 22M/169M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.16:analyze-jaxrs (default) on project ktv2: Execution default of goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.16:analyze-jaxrs failed: Runtime stack under-flow occurred. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.16:analyze-jaxrs (default) on project ktv2: Execution default of goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.16:analyze-jaxrs failed: Runtime stack under-flow occurred.
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: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 default of goal com.sebastian-daschner:jaxrs-analyzer-maven-plugin:0.16:analyze-jaxrs failed: Runtime stack under-flow occurred.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.IllegalStateException: Runtime stack under-flow occurred.
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.reduction.StackSizeSimulator.buildStackSizes(StackSizeSimulator.java:53)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.reduction.RelevantInstructionReducer.reduceInstructions(RelevantInstructionReducer.java:55)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.MethodContentAnalyzer.interpretRelevantInstructions(MethodContentAnalyzer.java:59)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.ResourceMethodContentAnalyzer.analyze(ResourceMethodContentAnalyzer.java:54)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.BytecodeAnalyzer.analyzeBytecode(BytecodeAnalyzer.java:26)
at java.lang.Iterable.forEach(Iterable.java:75)
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
at com.sebastian_daschner.jaxrs_analyzer.analysis.bytecode.BytecodeAnalyzer.analyzeBytecode(BytecodeAnalyzer.java:18)
at com.sebastian_daschner.jaxrs_analyzer.analysis.ProjectAnalyzer.analyze(ProjectAnalyzer.java:107)
at com.sebastian_daschner.jaxrs_analyzer.JAXRSAnalyzer.analyze(JAXRSAnalyzer.java:69)
at com.sebastian_daschner.jaxrs_analyzer.maven.JAXRSAnalyzerMojo.execute(JAXRSAnalyzerMojo.java:202)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 21 more
[ERROR]
[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/PluginExecutionException
configuration of jaxrs-analyzer in pom.xml:
<plugin>
<groupId>com.sebastian-daschner</groupId>
<artifactId>jaxrs-analyzer-maven-plugin</artifactId>
<version>0.16</version>
<executions>
<execution>
<goals>
<goal>analyze-jaxrs</goal>
</goals>
<configuration>
<backend>swagger</backend>
<deployedDomain>...</deployedDomain>
<swaggerSchemes>
<swaggerScheme>https</swaggerScheme>
</swaggerSchemes>
<resourcesDir>${project.build.finalName}/static/documentation/jaxrs-analyzer</resourcesDir>
</configuration>
</execution>
</executions>
</plugin>
Reproduced only once in my project, a mvn clean
then mvn install
fixed it.
Maybe adding more debug infos to the exception message could help understand the issue.