java.lang.noclassdeffounderror:java/sql/date

envsm3lx  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(277)

我正在尝试使用 mvn hpi:run 但Jenkins的创业失败了 java.lang.NoClassDefFoundError: java/sql/Date .
docker容器内的maven安装在版本3.6.0中:

$ mvn -v
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "5.4.0-56-generic", arch: "amd64", family: "unix"

我调用的完整命令:

mvn -Dmaven.javadoc.skip=true \
    -Dmaven.test.skip=true \
    -Dfindbugs.skip=true \
    -Denforcer.skip=true \
    -Danimal.sniffer.skip=true hpi:run

但jenkins的启动失败,错误如下:

Dec 10, 2020 8:04:16 AM jenkins.model.Jenkins <clinit>
SEVERE: Failed to load Jenkins.class
java.lang.NoClassDefFoundError: java/sql/Date

... Some stacktrace output

[INFO] Started ServerConnector@61874f5d{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.154 s
[INFO] Finished at: 2020-12-10T08:04:16Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jenkins-ci.tools:maven-hpi-plugin:2.2:run (default-cli) on 
project <myproject>: Execution default-cli of goal org.jenkins-ci.tools:maven-hpi-plugin:2.2:run
failed: A required class was missing while executing org.jenkins-ci.tools:maven-hpi-
plugin:2.2:run: java/sql/Date

...

我如何处理这个错误?
注意:插件本身的构建正在运行。调用下面的命令,生成.hpi包,通过上传该包,可以将其部署到已经运行的jenkins安装上。

mvn  -Dmaven.javadoc.skip=true \
     -Dmaven.test.skip=true \
     -Dfindbugs.skip=true \
     -Denforcer.skip=true \
     -Danimal.sniffer.skip=true package  # 'mvn verify' also works
``` `pom-xml` 文件:
<parent>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>plugin</artifactId>
    <version>3.4</version>
    <relativePath />
</parent>

<properties>
    <revision>0.1</revision>
    <changelist></changelist>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <java.level>8</java.level>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
    <jenkins.version>2.204.1</jenkins.version>
    <no-test-jar>false</no-test-jar>
    <useBeta>true</useBeta>
    <linkXRef>false</linkXRef>
    <configuration-as-code.version>1.36</configuration-as-code.version>
    <slf4jVersion>1.7.26</slf4jVersion>
    <spotbugs.failOnError>false</spotbugs.failOnError>
</properties>

<build>
  <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
        <resource><!-- copy all Java source files as resources -->
            <directory>src/main/java</directory>
        </resource>
    </resources>
</build>

<repositories>
    <repository>
        <id>repo.jenkins-ci.org</id>
        <url>https://repo.jenkins-ci.org/public/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
    <groupId>org.kohsuke.metainf-services</groupId>
    <artifactId>metainf-services</artifactId>
    <version>1.1</version>
    </dependency>
    <dependency>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>credentials</artifactId>
    <version>2.3.12</version>
    </dependency> 
    <dependency>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>ssh-credentials</artifactId>
    <version>1.18.1</version>
    </dependency> 
    <dependency>
    <groupId>org.jenkins-ci.plugins</groupId>
    <artifactId>git-client</artifactId>
    <version>3.3.1</version>
    </dependency> 
    <dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.6</version>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
    <dependency>
        <groupId>io.jenkins.tools.bom</groupId>
        <artifactId>bom-2.204.x</artifactId>
        <version>11</version>
        <scope>import</scope>
        <type>pom</type>
    </dependency>
    </dependencies>
</dependencyManagement>

<scm>
    <connection>scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
    <developerConnection>scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git</developerConnection>
    <url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
    <tag>${scmTag}</tag>
</scm>

<pluginRepositories>
    <pluginRepository>
    <id>repo.jenkins-ci.org</id>
    <url>https://repo.jenkins-ci.org/public/</url>
    </pluginRepository>
</pluginRepositories>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题