google / shipshape

Program analysis platform
Apache License 2.0
269 stars 35 forks source link

Jenkins Plugin fails with "java.lang.NoClassDefFoundError: [...]ProtocolStringList #42

Closed hansjoergschurr closed 9 years ago

hansjoergschurr commented 9 years ago

I tried to build and run the Jenkins plug-in. After building and uploading the plug-in I was able to configure a build step (PRE_BUILD stage), but forcing a build results in the following error:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/Test JS/workspace
[Shipshape] Creating Shipshape request ...
FATAL: com/google/protobuf/ProtocolStringList
java.lang.NoClassDefFoundError: com/google/protobuf/ProtocolStringList
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.constructShipshapeRequest(ShipshapeSlave.java:179)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.call(ShipshapeSlave.java:154)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.call(ShipshapeSlave.java:47)
    at hudson.FilePath.act(FilePath.java:1078)
    at com.google.jenkins.plugins.analysis.AnalysisRunner.perform(AnalysisRunner.java:118)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1744)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.ProtocolStringList
    at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1376)
    at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1326)
    at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1079)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 14 more
Finished: FAILURE

This seems not to be specific to my setup

llbit commented 9 years ago

I think this is caused by using an old version of protobuf. protobuf-java-2.5.0.jar does not contain a ProtocolStringList.class but protobuf-java-2.6.1.jar does.

collinw commented 9 years ago

We have two ways of specifying the version of protobuf to use: one in third_party, and one in the Jenkins plugin's pom.xml file. If they don't match, they should be made to.

llbit commented 9 years ago

After upgrading to protobuf 2.6.1 I get the following error:

FATAL: com/google/devtools/kythe/proto/AnyOuterClass
java.lang.NoClassDefFoundError: com/google/devtools/kythe/proto/AnyOuterClass
    at com.google.devtools.kythe.proto.Analysis.<clinit>(Analysis.java:9628)
    at com.google.shipshape.proto.ShipshapeContextProto.<clinit>(ShipshapeContextProto.java:4411)
    at com.google.shipshape.proto.ShipshapeRpcProto.<clinit>(ShipshapeRpcProto.java:6079)
    at com.google.shipshape.proto.ShipshapeRpcProto$ShipshapeRequest.internalGetFieldAccessorTable(ShipshapeRpcProto.java:4368)
    at com.google.protobuf.GeneratedMessage.getAllFieldsMutable(GeneratedMessage.java:107)
    at com.google.protobuf.GeneratedMessage.getAllFields(GeneratedMessage.java:155)
    at com.google.protobuf.TextFormat$Printer.print(TextFormat.java:298)
    at com.google.protobuf.TextFormat$Printer.access$400(TextFormat.java:273)
    at com.google.protobuf.TextFormat.print(TextFormat.java:76)
    at com.google.protobuf.TextFormat.printToString(TextFormat.java:143)
    at com.google.protobuf.AbstractMessage.toString(AbstractMessage.java:79)
    at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2886)
    at java.util.Formatter$FormatSpecifier.print(Formatter.java:2763)
    at java.util.Formatter.format(Formatter.java:2520)
    at java.util.Formatter.format(Formatter.java:2455)
    at java.lang.String.format(String.java:2928)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.call(ShipshapeSlave.java:155)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.call(ShipshapeSlave.java:47)
    at hudson.FilePath.act(FilePath.java:1076)
    at com.google.jenkins.plugins.analysis.AnalysisRunner.perform(AnalysisRunner.java:118)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
    at hudson.model.Build$BuildExecution.build(Build.java:203)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Caused by: java.lang.ClassNotFoundException: com.google.devtools.kythe.proto.AnyOuterClass
    at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1375)
    at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1325)
    at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1078)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 29 more
llbit commented 9 years ago

The current version for protobuf in third_party is 3.0.0-alpha-1, so I guess it's best to update the dependency in pom.xml to that version.

llbit commented 9 years ago

Protobuf 3.0.0-alpha-1 is not available on maven-central, but alpha-2 and alpha-3 are available.

collinw commented 9 years ago

Kythe defines its own Any message in third_party/kythe/proto/any.proto. Is that what the ClassNotFoundException is related to?

llbit commented 9 years ago

The libany_proto_java.jar is missing in the Maven build for the Jenkins plugin.

llbit commented 9 years ago

After adding libany_proto_java.jar to the build I seem to get past the ClassNotFoundException. Now I'm getting unrelated problems (docker not available in my test Jenkins).

[Shipshape] Running cmd: [docker, -H, unix:///var/run/docker.sock, pull, gcr.ioshipshape_releases/service:prod]
[Shipshape] Running command failed: Cannot run program "docker": error=2, No such file or directory
[Shipshape] Error: null
java.lang.NullPointerException
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.runCommand(ShipshapeSlave.java:485)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.makeShippingContainerRequest(ShipshapeSlave.java:287)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.call(ShipshapeSlave.java:156)
    at com.google.jenkins.plugins.analysis.ShipshapeSlave.call(ShipshapeSlave.java:47)
    at hudson.FilePath.act(FilePath.java:1076)
    at com.google.jenkins.plugins.analysis.AnalysisRunner.perform(AnalysisRunner.java:118)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
    at hudson.model.Build$BuildExecution.build(Build.java:203)
    at hudson.model.Build$BuildExecution.doRun(Build.java:160)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:536)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Build step 'Google Analysis Plugin' marked build as failure

Note: I'm running Jenkins in the Jenkins docker image.

collinw commented 9 years ago

Cool! I can review the patch to add the missing jar file.