我是 docker 和 AWS 的新手。我正在尝试使用信任库证书(cassandra_truststore.jks)连接 AWS 密钥空间,我将证书保存在项目根级别。gradlew bootRun
我可以通过在本地执行应用程序(使用)来连接 aws 键空间。但是当我构建 docker 映像(使用gradlew docker
)并运行映像(使用winpty docker run -it product-service-app
)时,它会抛出异常“java.nio.file.NoSuchFileException”./cassandra_truststore.jks。这是我的堆栈跟踪..
Caused by: java.lang.IllegalStateException: Cannot initialize SSL Context
at com.datastax.oss.driver.internal.core.ssl.DefaultSslEngineFactory.<init>(DefaultSslEngineFactory.java:74) ~[java-driver-core-4.13.0.jar!/:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
at com.datastax.oss.driver.internal.core.util.Reflection.resolveClass(Reflection.java:329) ~[java-driver-core-4.13.0.jar!/:na]
... 19 common frames omitted
Caused by: java.nio.file.NoSuchFileException: ./cassandra_truststore.jks
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92) ~[na:na]
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) ~[na:na]
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) ~[na:na]
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219) ~[na:na]
at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420) ~[na:na]
at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
at com.datastax.oss.driver.internal.core.ssl.DefaultSslEngineFactory.buildContext(DefaultSslEngineFactory.java:119) ~[java-driver-core-4.13.0.jar!/:n
a]
at com.datastax.oss.driver.internal.core.ssl.DefaultSslEngineFactory.<init>(DefaultSslEngineFactory.java:72) ~[java-driver-core-4.13.0.jar!/:na]
... 24 common frames omitted
下面是我的码头文件
FROM openjdk:11
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
下面是我的 gradle.build 文件 docker 任务
buildscript {
repositories {
mavenCentral()
}
}
plugins {
id 'org.springframework.boot' version '2.4.4'
id 'com.palantir.docker' version '0.30.0'
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'jacoco'
apply plugin: 'application'
apply plugin: 'io.spring.dependency-management'
group = 'com.capone.lab.product'
version = '1.0'
repositories {
mavenCentral()
}
bootJar {
enabled = true
mainClassName = 'com.capone.lab.product.ProductApplication'
}
sourceCompatibility = 11
targetCompatibility = 11
docker {
name "product-service-app"
dockerfile file('Dockerfile')
copySpec.from(jar).rename(".*","app.jar")
buildArgs(['JAR_FILE': "app.jar"])
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-cassandra'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
implementation 'software.aws.mcs:aws-sigv4-auth-cassandra-java-driver-plugin:4.0.4'
implementation 'com.datastax.oss:java-driver-core:4.13.0'
implementation 'com.datastax.oss:java-driver-query-builder:4.13.0'
implementation 'com.datastax.oss:java-driver-mapper-runtime:4.13.0'
implementation 'com.datastax.oss:native-protocol:1.5.0'
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
testImplementation 'org.mockito:mockito-core:2.1.0'
testImplementation 'org.mockito:mockito-junit-jupiter:4.1.0'
testImplementation 'org.mockito:mockito-core:4.1.0'
implementation 'org.junit.platform:junit-platform-commons:1.8.1'
compile 'org.springframework:spring-context'//:5.0.1.RELEASE'
implementation 'org.springframework.boot:spring-boot-test-autoconfigure:1.4.0.RELEASE'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
我检查了我没有.dockerignore
文件。
我尝试了很多方法,但无法解决这个问题..这里的任何线索对我都有很大的帮助。提前致谢。