我有一个springboot应用程序,它连接到一个DB2数据库,然后检索一些数据,并为其提供一个REST端点。为了促进这一点,在应用程序的类路径中添加了一个许可证,允许它与DB2数据库通信。这是可行的。但是,当我在本地构建、镜像和运行该镜像时,我得到一个错误,指出许可证不在那里。
{
"timestamp": 1569854043909,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.jdbc.CannotGetJdbcConnectionException",
"message": "Could not get JDBC Connection; nested exception is com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][t4][10509][13454][4.26.14] Connection to the data server failed. The IBM Data Server for JDBC and SQLJ license was invalid \nor was not activated for the DB2 for z/OS subsystem. If you are connecting directly to \nthe data server and using DB2 Connect Unlimited Edition for System z, perform the \nactivation step by running the activation program in the license activation kit. \nIf you are using any other edition of DB2 Connect, obtain the license file, \ndb2jcc_license_cisuz.jar, from the license activation kit, and follow the installation \ndirections to include the license file in the class path. ERRORCODE=-4230, SQLSTATE=42968",
"path": "/test"
}
我假设这是因为许可证现在不包括在Docker容器类路径中。我已经对此进行了相当多的研究,但看不到任何关于我将如何做到这一点的指示。因此,任何帮助都将不胜感激。
我的许可证保存在项目根目录下的lib文件夹中,是一个jar文件。
我的docker文件:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY target/mydb2jdbcproject-1.jar mydb2jdbcproject-1.jar
COPY lib/db2jcc_license_cisuz.jar db2jcc_license_cisuz.jar
#CLASSPATH: lib/db2jcc_license_cisuz.jar/
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","mydb2jdbcproject-1.jar"]
发布于 2019-10-14 16:58:20
在运行之前,我不得不更改用于手动设置多个类路径的CMD,由于某些原因,它在-jar中不起作用,所以我不得不通过launcher类运行。
生成的dockerfile如下所示:
FROM openjdk:8-jdk-alpine
RUN mkdir -p /opt/mvp2/db2jdbc /opt/mvp2/app
COPY target/db2new-0.1.jar /opt/mvp2/app/
COPY jdbc/db2jcc4.jar /opt/mvp2/db2jdbc/
COPY jdbc/db2jcc_license_cisuz.jar /opt/mvp2/db2jdbc/
CMD ["java","-classpath","/opt/mvp2/db2jdbc/db2jcc4.jar:/opt/mvp2/db2jdbc/db2jcc_license_cisuz.jar:/opt/mvp2/app/db2new-0.1.jar:.","org.springframework.boot.loader.JarLauncher"]
https://stackoverflow.com/questions/58170235
复制相似问题