WebSphere liberty - docker 图片上的共享库

WebSphere liberty - shared libraries on docker image

我正在使用 websphere-liberty(https://hub.docker.com/_/websphere-liberty/) 映像来部署我的应用程序,但我在共享库方面遇到问题。我需要将 jar 从 util 项目转换为自由服务器上的共享库。我陷入了这个错误:

SchedulerApplication- 加载正常 - 来自 Scheduler 应用程序,但它正在扩展 class 来自 util 项目

[ERROR   ] SRVE0276E: Error while initializing Servlet [Scheduler]: 

    javax.servlet.UnavailableException: SRVE0203E: Servlet [Scheduler]: com.scheduler.SchedulerApplication was found, but is missing another required class.
    SRVE0206E: This error typically implies that the servlet was originally compiled with classes which cannot be located by the server.
    SRVE0187E: Check your class path to ensure that all classes required by the servlet are present.SRVE0210I: This problem can be debugged by recompiling the servlet using only the classes in the application's runtime class path
    SRVE0234I: Application class path=[com.ibm.ws.classloading.internal.ThreadContextClassLoader@3c27eabb]
            at com.ibm.ws.webcontainer.servlet.ServletWrapper.run(ServletWrapper.java:1575)
            at [internal classes]

Basic project structure
    app - Scheduler/...
                /pom.xml
        - myapp2/...
                /pom.xml
        - util/...
              /pom.xml
        - pom.xml
    Dockerfile
    server.xml

Dockerfile

FROM maven:3.8.4-ibmjava-8 as maven_build
COPY --chown=1001:0 app./app
WORKDIR app
RUN mvn clean install

FROM websphere-liberty:21.0.0.12-full-java8-ibmjava
COPY --chown=1001:0  server.xml /config/
COPY --chown=1001:0 --from=maven_build /app/Scheduler/target/Scheduler.ear /config/dropins/ 
COPY --chown=1001:0 --from=maven_build /app/myapp2/target/myapp2.ear /config/dropins/

#util -> libraries used in both Scheduler & myapp2
COPY --chown=1001:0 --from=maven_build /app/util/target/util.jar /opt/ibm/wlp/usr/servers/defaultServer/lib/
RUN configure.sh

server.xml

.....
<library id="SharedLibraries" apiTypeVisibility="spec, ibm-api, stable, third-party">
    <fileset dir="/opt/ibm/wlp/usr/servers/defaultServer/lib/" includes="*.jar" scanInterval="5s" />
</library>

<application id="Scheduler" name="Scheduler" type="ear" location="Scheduler.ear">
      <classloader apiTypeVisibility="spec, ibm-api, stable, third-party" commonLibraryRef="SharedLibraries" />   
</application>
.....

将 ear 文件移出后已修复 config/dropins => 停止自动部署

看起来应用已安装 2 次 - 从 config/dropins 自动部署并从 server.xml

部署
COPY --chown=1001:0 --from=maven_build /app/Scheduler/target/Scheduler.ear /opt/ibm/wlp/usr/servers/defaultServer/apps