有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何使用openjdk:7 Docker映像和Gradle包装器避免“EC参数错误”?

此Dockerfile:

FROM openjdk:7

WORKDIR /restdocs/
RUN git clone https://github.com/spring-projects/spring-restdocs.git /restdocs
RUN git checkout v1.1.2.RELEASE

RUN ./gradlew build

使用docker build . -t rest-notes构建会导致以下错误: Exception in thread "main" javax.net.ssl.SSLException: java.security.ProviderException: java.security.InvalidKeyException: EC parameters error

我可以在Dockerfile中做些什么来避免这种情况并使Gradle包装器工作


共 (2) 个答案

  1. # 1 楼答案

    多亏了埃里希·塞弗特和他在这里的承诺,我才得以摆脱困境。已更新的Dockerfile可正常工作:

    FROM openjdk:7
    
    RUN apt-get update && apt-get install sudo
    
    # Fix the EC parameters error: (ref https://github.com/travis-ci/travis-ci/issues/8503)
    RUN sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}"/jre/lib/ext/bcprov-ext-jdk15on-158.jar && \
      sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security && \
      echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security
    
    WORKDIR /restdocs/
    RUN git clone https://github.com/spring-projects/spring-restdocs.git /restdocs
    RUN git checkout v1.1.2.RELEASE
    
    RUN ./gradlew build
    

    (不要介意spring restdocs分支的构建失败——这与EC参数错误无关:)

  2. # 2 楼答案

    升级到后来的Maven docker映像为我解决了这个问题。我用maven:3.6-jdk-11替换了maven:3-jdk-7

    在我的例子中,我使用了一个较旧的示例GitLab CI脚本。我更新的GitLab CI脚本现在看起来像:

    image: maven:3.6-jdk-11
    
    build:
      script: "mvn install -B"