詹金斯使用了错误的公地 - io

时间:2015-02-02 10:17:25

标签: java jenkins

好的我只是用我发现的新线索重新构建我的问题,因为我没有得到前一个答案。 所以! 詹金斯正在使用错误的公共资源。 我正在运行Jenkins的1.598版本。在“关于”部分,我可以看到它使用的是commons-io版本2.4。

当我在Jenkins上运行我的maven项目时,项目构建是成功的,但是当Jenkins开始运行PMD或checkstyle分析时,我有以下错误:

java.lang.NoSuchMethodError: org.apache.commons.io.IOUtils.lineIterator(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Lorg/apache/commons/io/LineIterator;
    at hudson.plugins.analysis.util.JavaPackageDetector.detectPackageName(JavaPackageDetector.java:34)
    at hudson.plugins.analysis.util.AbstractPackageDetector.detectPackageName(AbstractPackageDetector.java:25)
    at hudson.plugins.analysis.util.PackageDetectors.detectPackageName(PackageDetectors.java:30)
    at hudson.plugins.checkstyle.parser.CheckStyleParser.convert(CheckStyleParser.java:96)
    at hudson.plugins.checkstyle.parser.CheckStyleParser.parse(CheckStyleParser.java:72)
    at hudson.plugins.analysis.core.AbstractAnnotationParser.parse(AbstractAnnotationParser.java:54)
    at hudson.plugins.analysis.core.FilesParser.parseFile(FilesParser.java:323)
    at hudson.plugins.analysis.core.FilesParser.parseFiles(FilesParser.java:281)
    at hudson.plugins.analysis.core.FilesParser.parseSingleFile(FilesParser.java:239)
    at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:198)
    at hudson.plugins.analysis.core.FilesParser.invoke(FilesParser.java:31)
    at hudson.FilePath.act(FilePath.java:989)
...

这个方法(lineIterator(Ljava / io / InputStream; Ljava / nio / charset / Charset;))存在于commons-io 2.4中,所以我的猜测是Jenkins正在使用另一个jar。

我在服务器上为commons-io运行了一个locate,结果如下:

/etc/nexus/2.10/nexus/WEB-INF/lib/commons-io-2.4.jar
/etc/nexus/sonatype-work/nexus/storage/central/commons-io
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/1.4
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/2.2
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/2.4
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/1.4/commons-io-1.4.jar
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/1.4/commons-io-1.4.pom
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/2.2/commons-io-2.2.jar
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/2.2/commons-io-2.2.pom
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/2.4/commons-io-2.4.jar
/etc/nexus/sonatype-work/nexus/storage/central/.nexus/attributes/commons-io/commons-io/2.4/commons-io-2.4.pom
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/1.4
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/2.2
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/2.4
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/1.4/commons-io-1.4.jar
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/1.4/commons-io-1.4.pom
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/2.2/commons-io-2.2.jar
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/2.2/commons-io-2.2.pom
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/2.4/commons-io-2.4.jar
/etc/nexus/sonatype-work/nexus/storage/central/commons-io/commons-io/2.4/commons-io-2.4.pom
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/jars
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/poms
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/jars/commons-io-1.4.jar
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/jars/commons-io-2.2.jar
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/jars/commons-io-2.4.jar
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/poms/commons-io-1.4.pom
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/poms/commons-io-2.2.pom
/etc/nexus/sonatype-work/nexus/storage/central-m1/.nexus/attributes/commons-io/poms/commons-io-2.4.pom
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/jars
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/poms
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/jars/commons-io-1.4.jar
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/jars/commons-io-2.2.jar
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/jars/commons-io-2.4.jar
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/poms/commons-io-1.4.pom
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/poms/commons-io-2.2.pom
/etc/nexus/sonatype-work/nexus/storage/central-m1/commons-io/poms/commons-io-2.4.pom
/home/jenkins/.m2/repository/commons-io
/home/jenkins/.m2/repository/commons-io/commons-io
/home/jenkins/.m2/repository/commons-io/commons-io/1.4
/home/jenkins/.m2/repository/commons-io/commons-io/1.4/_maven.repositories
/home/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar
/home/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar.md5
/home/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.pom
/home/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.pom.md5
/home/sonarqube-4.5.2/lib/common/commons-io-2.4.jar
/root/nexus-2.10.0-02/nexus/WEB-INF/lib/commons-io-2.4.jar
/usr/share/doc/libcommons-io-java
/usr/share/doc/libcommons-io-java/NOTICE.txt
/usr/share/doc/libcommons-io-java/RELEASE-NOTES.txt.gz
/usr/share/doc/libcommons-io-java/changelog.Debian.gz
/usr/share/doc/libcommons-io-java/copyright
/usr/share/java/commons-io-1.4.jar
/usr/share/java/commons-io.jar
/usr/share/maven-repo/commons-io
/usr/share/maven-repo/commons-io/commons-io
/usr/share/maven-repo/commons-io/commons-io/1.4
/usr/share/maven-repo/commons-io/commons-io/debian
/usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.jar
/usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.pom
/usr/share/maven-repo/commons-io/commons-io/debian/commons-io-debian.jar
/usr/share/maven-repo/commons-io/commons-io/debian/commons-io-debian.pom
/var/cache/jenkins/war/WEB-INF/lib/commons-io-2.4.jar
/var/lib/dpkg/info/libcommons-io-java.list
/var/lib/dpkg/info/libcommons-io-java.md5sums
/var/lib/jenkins/.m2/repository/commons-io
/var/lib/jenkins/.m2/repository/commons-io/commons-io
/var/lib/jenkins/.m2/repository/commons-io/commons-io/1.4
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.2
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.4
/var/lib/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar
/var/lib/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar.sha1
/var/lib/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.pom
/var/lib/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.pom.sha1
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar.sha1
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.pom
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.pom.sha1
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar.sha1
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.pom
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.pom.sha1
/var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/commons-io-2.2.jar

正如你所看到的那样,有一些commons-io 1.4的出现,它不包含丢失的方法!所以它必须是詹金斯使用的那个。

在项目的日志中,我可以看到:

java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven-agent-1.6.jar:/usr/share/maven2/boot/classworlds.jar hudson.maven.agent.Main /usr/share/maven2/ /var/cache/jenkins/war/WEB-INF/lib/remoting-2.49.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven-interceptor-1.6.jar 56025

在locate:

/home/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar
/usr/share/java/commons-io-1.4.jar
/usr/share/maven-repo/commons-io/commons-io/1.4/commons-io-1.4.jar
/var/cache/jenkins/war/WEB-INF/lib/commons-io-2.4.jar
/var/lib/jenkins/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4.jar
/var/lib/jenkins/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar

所以我猜问题就在这附近,但我不知道如何解决它! 我不能只是从服务器中删除commons-io 1.4的出现,因为其他一些程序可能会使用它们。 谢谢您的帮助, 纪尧姆

1 个答案:

答案 0 :(得分:0)

我们找到了解决方案! 这似乎是由服务器上使用的maven版本引起的(2.2)。 我在Jenkins中将它升级到3.2.2,它现在完美无缺!