升级Open Liberty至23.0.0.1后K8部署报microProfile-5.0未找到错误
问题解决:MicroProfile 5.0特性定义找不到
核心原因
- Java版本不兼容:MicroProfile 5.0要求运行环境为Java 11及以上,当前使用的Java 8镜像无法适配,Java 8最高仅支持MicroProfile 4.1版本。
- 镜像特性缺失:
open-liberty:kernel-slim-java8-openj9-ubi是轻量核心镜像,默认不包含任何MicroProfile特性包,需手动安装或换用预集成特性的镜像。
解决方案
方案一:降级MicroProfile版本适配Java 8
保留Java 8环境,调整server.xml中的MicroProfile版本为Java 8支持的最高版本:
<server description="Sample Liberty server"> <featureManager> <!-- Java 8最高支持MicroProfile 4.1 --> <feature>microProfile-4.1</feature> </featureManager> ... </server>
同时修改Dockerfile,添加特性安装命令:
FROM registry.access.redhat.com/ubi8/openjdk-8:1.14-14.1675788284 AS builder LABEL maintainer="IBM Java Engineering at IBM Cloud" # Copy the war file over to the open liberty image FROM icr.io/appcafe/open-liberty:kernel-slim-java8-openj9-ubi # disable vulnerable TLS algorithms USER root RUN sed -i 's/jdk.tls.disabledAlgorithms=/jdk.tls.disabledAlgorithms=SSLv2Hello, DES40_CBC, RC4_40, SSLv2, TLSv1, TLSv1.1, /g' /opt/java/openjdk/jre/lib/security/java.security USER 1001 # 安装MicroProfile 4.1特性 RUN features.sh install microProfile-4.1 COPY target/liberty/wlp/usr/servers/defaultServer /config/ COPY target/*.war /config/apps/ RUN chmod g+w /config/apps RUN chmod -R g+w /opt/ibm/wlp/bin/tools USER 1001
方案二:升级Java版本适配MicroProfile 5.0
若需保留MicroProfile 5.0,切换到Java 11及以上的Liberty镜像,同时使用预集成MicroProfile特性的版本:
- 修改Dockerfile的基础镜像为
open-liberty:microProfile5-java11-openj9-ubi(该镜像已包含MicroProfile 5.0特性):
FROM registry.access.redhat.com/ubi8/openjdk-11:1.14-14.1675788284 AS builder LABEL maintainer="IBM Java Engineering at IBM Cloud" # Copy the war file over to the open liberty image FROM icr.io/appcafe/open-liberty:microProfile5-java11-openj9-ubi # disable vulnerable TLS algorithms USER root RUN sed -i 's/jdk.tls.disabledAlgorithms=/jdk.tls.disabledAlgorithms=SSLv2Hello, DES40_CBC, RC4_40, SSLv2, TLSv1, TLSv1.1, /g' /opt/java/openjdk/jre/lib/security/java.security USER 1001 COPY target/liberty/wlp/usr/servers/defaultServer /config/ COPY target/*.war /config/apps/ RUN chmod g+w /config/apps RUN chmod -R g+w /opt/ibm/wlp/bin/tools USER 1001
- 保持
server.xml中的microProfile-5.0特性配置不变即可。
额外说明
- Liberty的
slim系列镜像仅包含核心运行时,所有业务特性需通过features.sh install命令手动安装; - MicroProfile版本与Java版本对应关系:
- Java 8:支持MicroProfile 1.0 ~ 4.1
- Java 11+:支持MicroProfile 3.0 ~ 6.1
内容的提问来源于stack exchange,提问作者RAK
相关产品推荐
相关产品推荐

