繁体   English   中英

Docker:由于未找到 JAXB-API,Jenkins-jdk11 无法连接到 Nexus

[英]Docker: Jenkins-jdk11 fails to connect to Nexus due to JAXB-API has not been found

尝试将jenkins-jdk11连接到在基于 JDK8 的主机系统上的 docker-compose 中运行相同网络的nexus3容器时出现以下错误。 单击“测试连接”后在此处输入图片说明

错误:

Nexus Repository Manager 3.x connection failed
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
    at com.sonatype.nexus.api.zz.ex.a(SourceFile:33)
    at com.sonatype.nexus.api.zz.ex.b(SourceFile:24)
    at com.sonatype.nexus.api.zz.ez.handleResponse(SourceFile:54)
    at org.apache.http.impl.client.CloseableHttpClient.execute(SourceFile:223)
    at org.apache.http.impl.client.CloseableHttpClient.execute(SourceFile:165)
    at com.sonatype.nexus.api.zz.et.a(SourceFile:84)
    at com.sonatype.nexus.api.zz.es.getVersion(SourceFile:126)
    at com.sonatype.nexus.api.repository.v3.RepositoryManagerV3Client$getVersion.call(Unknown Source)

docker-compose.yml

version: "3"
services:
  jenkins-jdk11:
    user: root
    image: 'jenkins/jenkins:jdk11'
    ports:
      - '10000:8080'
      - '50000:50000'
    environment:
      - TZ=Europe/Warsaw
      - "JAVA_OPTS=-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory"
    links:
      - nexus3
    volumes:
      - 'jenkins-data:/var/jenkins_home'
      - '/var/run/docker.sock:/var/run/docker.sock'
    deploy:
      restart_policy:
         condition: on-failure
    networks:
      - backend
  nexus3:
    container_name: nexus3
    image: 'sonatype/nexus3'
    ports:
      - '50001:8081'
    volumes:
      - 'local-nexus-data-volume:/nexus-data'
    networks:
      - backend
volumes:
  jenkins-data:
    driver: local
  local-nexus-data-volume:
    driver: local
networks:
  backend:
    driver: overlay

似乎是什么问题以及如何成功连接到 Nexus?

编辑我安装的 JAXB 插件: 在此处输入图片说明

这是 Jenkins wiki 上列出的关于 Jenkins 与 Java 11 兼容性问题的问题。这是链接

一种可能的解决方案是在运行 Jenkins 时在 JAVA_OPTS 中添加-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory 您可以通过使用--env选项将 env 变量传递给容器来做到这一点:

--env JAVA_OPTS=-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory

或者在 docker compose 中使用environment

services:
  jenkins:
    image: 'jenkins/jenkins:jdk11'
    environment:
     - JAVA_OPTS=-Djavax.xml.bind.JAXBContextFactory=com.sun.xml.bind.v2.ContextFactory

问题在于 Jenkins 和 nexus 使用的 java 版本冲突,请确保将 Java 环境设置为与 java -version 相同,如下所示

java -version openjdk version "11.0.8" 2020-07-14 OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 11.0.8+10-post- Ubuntu-0ubuntu120.04,混合模式,共享)

cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games: /snap/bin”

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

#JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-amd64"

在满足此要求后,这为我解决了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM