classnotfoundexception

nfeuvbwi  于 2021-06-08  发布在  Redis
关注(0)|答案(1)|浏览(307)

我遵循这个教程,使我当前的wicket项目与redis会话管理一起工作。但是,我无法使context.xml正常工作。我用两个文件catalinaredissionstore和rediscache制作了一个jar,然后我把这个jar放在tomcat的lib文件夹中。
启动应用程序后,出现以下错误:

SEVERE [main] org.apache.tomcat.util.digester.Digester.startElement Begin event threw exception
    java.lang.ClassNotFoundException: com.company.web.wicket.redis.CatalinaRedisSessionStore

my context.xml如下所示:

<?xml version="1.0" ?>
<Context>
    <Manager className="org.apache.catalina.session.PersistentManager"
             maxIdleBackup="1"
             minIdleSwap="0"
             maxIdleSwap="0"
             processExpiresFrequency="1"
             saveOnRestart='true'>
        <Store className="com.company.web.wicket.redis.CatalinaRedisSessionStore"/>
    </Manager>
</Context>

我正在docker容器中运行我的应用程序,使用 azul/zulu-openjdk-alpine:11 当我检查docker容器时,jar文件在tomcat home的lib文件夹中,因此根据文档,应该足以让tomcat找到类。我把我的文件放在下面。
有人知道为什么找不到这个班吗?
dockerfile文件

FROM azul/zulu-openjdk-alpine:11

RUN apk update && apk add bash

# set timezone to "Europe/Amsterdam"

RUN apk add tzdata && cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime && echo "Europe/Amsterdam" >  /etc/timezone && apk del tzdata

COPY /build/distributions/Application*.zip /opt/application/

RUN unzip /opt/application/Application*zip -d /opt/application && rm /opt/application/Application*.zip && chmod 775 /opt/application/apache-tomcat/bin/catalina.sh && chmod 775 /opt/application/apache-tomcat/bin/docker-healthcheck.sh

WORKDIR /opt/application/apache-tomcat

EXPOSE 8080 9875 9000

# Define default command.

CMD ["/opt/application/apache-tomcat/bin/dockerstart.sh","arg1"]

HEALTHCHECK --interval=1m --timeout=10s --retries=3 --start-period=2m CMD /opt/application/apache-tomcat/bin/docker-healthcheck.sh

执行jar xf redis\u session.jar后,文件夹结构如下:

g9icjywg

g9icjywg1#

我假设您复制到docker映像中的应用程序*.zip文件包含tomcat安装。
按以下方式更改dockerfile可以解决此问题:

FROM azul/zulu-openjdk-alpine:11

RUN apk update && apk add bash

# set timezone to "Europe/Amsterdam"

RUN apk add tzdata && \
    cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime && \
    echo "Europe/Amsterdam" >  /etc/timezone && \
    apk del tzdata

COPY /build/distributions/Application*.zip /tmp/

# Setting CATALINA_HOME and updating the PATH env vars is crucial

# since you use an inofficial Tomcat base image

ENV CATALINA_HOME /usr/local/tomcat
ENV PATH ${CATALINA_HOME}/bin:${PATH}

# The default path of Tomcat is /usr/local/tomcat

# So, it's a good idea to extract your application to that folder

# rather than to a custom one to avoid an unexpected behaviour of the Tomcat

RUN unzip  /tmp/Application*.zip -d /usr/local && \
    rm /tmp/Application*.zip && \
    mv /usr/local/apache-tomcat ${CATALINA_HOME} && \
    chmod 775 ${CATALINA_HOME}/bin/catalina.sh && \
    chmod 775 ${CATALINA_HOME}/bin/dockerstart.sh && \
    chmod 775 ${CATALINA_HOME}/bin/docker-healthcheck.sh

WORKDIR ${CATALINA_HOME}

EXPOSE 8080 9875 9000

# Define default command.

# Everything inside /usr/local/tomcat/bin is exposed through the $PATH env var we defined at the beginning.

# So we can access them globally without having to specify the exact script path

CMD ["dockerstart.sh", "run"]

HEALTHCHECK --interval=1m --timeout=10s --retries=3 --start-period=2m CMD ${CATALINA_HOME}/bin/docker-healthcheck.sh

相关问题