私は自分のjarファイルの1つを使用するJenkinsプラグインを書いています。最後のものにはJDOMが必要です。したがって、POMには2つの依存関係があります。
- JDOMを使用する自分のJAR
- JDOM
正常にビルドされますmvn clean install
が()、実行中に次のエラーが発生します:org.jdom.JDOMException: java.lang.NoClassDefFoundError: org/jdom/Parent
。
JDOM jarは、実際にHPIの次の場所にありますWEB-INF\lib\jdom-1.0.jar
。また、TomcatでJenkinsを実行しようとしました。そして、 POMでJDOMをマスククラスとして構成しようとしました。
<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<version>1.94</version>
<configuration>
<maskClasses>org.jdom.</maskClasses> <!-- HERE -->
<pluginFirstClassLoader>true</pluginFirstClassLoader>
</configuration>
</plugin>
</plugins>
</build>
成功せずに。
プラグインのpom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.500</version><!-- which version of Jenkins is this plugin built against? -->
</parent>
<groupId>***</groupId>
<artifactId>***</artifactId>
<version>1.0</version>
<packaging>hpi</packaging>
<!-- get every artifact through repo.jenkins-ci.org, which proxies all the artifacts that we need -->
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>com.***</groupId>
<artifactId>***</artifactId>
<version>12.2.01</version>
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
mvn依存関係:分析
[WARNING] Used undeclared dependencies found:
[WARNING] org.mortbay.jetty:servlet-api:jar:2.5-20081211:test
[WARNING] commons-lang:commons-lang:jar:2.6:provided
[WARNING] org.kohsuke.stapler:json-lib:jar:2.1-rev7:provided
[WARNING] commons-io:commons-io:jar:1.4:provided
[WARNING] org.jvnet.hudson.dom4j:dom4j:jar:1.6.1-hudson-3:provided
[WARNING] org.kohsuke.stapler:stapler:jar:1.199:provided
[WARNING] Unused declared dependencies found:
[WARNING] jdom:jdom:jar:1.0:compile
[WARNING] org.jenkins-ci.main:jenkins-war:war:1.500:test
[WARNING] org.jenkins-ci.main:ui-samples-plugin:jar:1.500:test
[WARNING] javax.servlet:servlet-api:jar:2.4:provided
[WARNING] org.codehaus.mojo:animal-sniffer-annotations:jar:1.9:provided
[WARNING] junit:junit:jar:3.8:test
スタックトレース
org.jdom.JDOMException: java.lang.NoClassDefFoundError: org/jdom/Parent: org/jdom/Parent
at org.jdom.xpath.XPath.newInstance(XPath.java:139)
at com.***.util.IOFile.scriptBlock(IOFile.java:449)
at com.***.util.IOFile.scriptBlock(IOFile.java:502)
at com.***.util.IOFile.createFileFromTemplate(IOFile.java:211)
at com.***.util.IOFile.createFileFromTemplate(IOFile.java:176)
at com.***.delivery.task.BuildFromTemplates.execute(BuildFromTemplates.java:89)
at com.***.delivery.DeliveryThread.integrateSuite(DeliveryThread.java:1586)
at com.***.delivery.DeliveryThread.run(DeliveryThread.java:363)
at com.***.pmj.DeliveryBuilder.perform(DeliveryBuilder.java:303)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:593)
at hudson.model.Run.execute(Run.java:1568)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.NoClassDefFoundError: org/jdom/Parent
at org.jaxen.jdom.JDOMXPath.<init>(JDOMXPath.java:91)
at org.jdom.xpath.JaxenXPath.setXPath(JaxenXPath.java:281)
at org.jdom.xpath.JaxenXPath.<init>(JaxenXPath.java:99)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jdom.xpath.XPath.newInstance(XPath.java:129)
... 17 more
Caused by: java.lang.ClassNotFoundException: org.jdom.Parent
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at winstone.classLoader.WebappClassLoader.loadClass(WebappClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 25 more
Caused by: java.lang.NoClassDefFoundError: org/jdom/Parent
at org.jaxen.jdom.JDOMXPath.<init>(JDOMXPath.java:91)
at org.jdom.xpath.JaxenXPath.setXPath(JaxenXPath.java:281)
at org.jdom.xpath.JaxenXPath.<init>(JaxenXPath.java:99)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jdom.xpath.XPath.newInstance(XPath.java:129)
at com.***.util.IOFile.scriptBlock(IOFile.java:449)
at com.***.util.IOFile.scriptBlock(IOFile.java:502)
at com.***.util.IOFile.createFileFromTemplate(IOFile.java:211)
at com.***.util.IOFile.createFileFromTemplate(IOFile.java:176)
at com.***.delivery.task.BuildFromTemplates.execute(BuildFromTemplates.java:89)
at com.***.delivery.DeliveryThread.integrateSuite(DeliveryThread.java:1586)
at com.***.delivery.DeliveryThread.run(DeliveryThread.java:363)
at com.***.pmj.DeliveryBuilder.perform(DeliveryBuilder.java:303)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:593)
at hudson.model.Run.execute(Run.java:1568)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.ClassNotFoundException: org.jdom.Parent
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at winstone.classLoader.WebappClassLoader.loadClassmaven (WebappClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 25 more
Caused by: java.lang.NoClassDefFoundError: org/jdom/Parent
at org.jaxen.jdom.JDOMXPath.<init>(JDOMXPath.java:91)
at org.jdom.xpath.JaxenXPath.setXPath(JaxenXPath.java:281)
at org.jdom.xpath.JaxenXPath.<init>(JaxenXPath.java:99)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.jdom.xpath.XPath.newInstance(XPath.java:129)
at com.***.util.IOFile.scriptBlock(IOFile.java:449)
at com.***.util.IOFile.scriptBlock(IOFile.java:502)
at com.***.util.IOFile.createFileFromTemplate(IOFile.java:211)
at com.***.util.IOFile.createFileFromTemplate(IOFile.java:176)
at com.***.delivery.task.BuildFromTemplates.execute(BuildFromTemplates.java:89)
at com.***.delivery.DeliveryThread.integrateSuite(DeliveryThread.java:1586)
at com.***.delivery.DeliveryThread.run(DeliveryThread.java:363)
at com.***.pmj.DeliveryBuilder.perform(DeliveryBuilder.java:303)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:814)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:593)
at hudson.model.Run.execute(Run.java:1568)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:237)
Caused by: java.lang.ClassNotFoundException: org.jdom.Parent
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at winstone.classLoader.WebappClassLoader.loadClass(WebappClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 25 more
さらに詳しい情報が必要な場合は、コメントでお知らせください。ありがとうございました!