修复上下文的docBase时出现异常-引发错误,但部署成功



我已经构建了一个基于tomcat基本映像的docker映像,并将MyExample.war文件复制到我的自定义dockerFile中的tomcat/webapp文件夹中,并构建了映像。它成功地部署了war文件,并能够在我的系统上使用docker运行。

但是当我在kubernetes服务器中部署相同的映像时。它成功地部署了应用程序。然后吊舱就升起了。但我在日志中看到一个错误,如下所示。

{"type":"log", "level":"ERROR", "time":"2022-03-03T12:18:38.081Z", "message":"Exception fixing docBase for context [/MyExample]"}

并且没有可用的堆栈跟踪,我启用了调试日志并进行了检查。这个错误的原因是什么还不清楚,因为我没有任何堆栈。

以下是打印此错误时的完整堆栈跟踪。

{"type":"log",  "level":"DEBUG", "time":"2022-03-03T12:18:38.078Z", "log":{"message":"IntrospectionUtils:org.apache.catalina.core.StandardContext.addWatchedResource( WEB-INF/tomcat-web.xml)"}}
{"type":"log","level":"DEBUG",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"characters(n    )"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"startElement(,,WatchedResource)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"  New match='Context/WatchedResource'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"  Fire begin() for CallMethodRule[methodName=addWatchedResource, paramCount=0, paramTypes={java.lang.String}]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"characters(${catalina.base}/conf/web.xml)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"endElement(,,WatchedResource)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"  match='Context/WatchedResource'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"  bodyText='${catalina.base}/conf/web.xml'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"  Fire body() for CallMethodRule[methodName=addWatchedResource, paramCount=0, paramTypes={java.lang.String}]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"  Fire end() for CallMethodRule[methodName=addWatchedResource, paramCount=0, paramTypes={java.lang.String}]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"[CallMethodRule]{Context/WatchedResource} Call org.apache.catalina.core.StandardContext.addWatchedResource(/opt/tomcat/conf/web.xml/java.lang.String)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"IntrospectionUtils:org.apache.catalina.core.StandardContext.addWatchedResource( /opt/tomcat/conf/web.xml)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.078Z", "log":{"message":"characters(nn    )"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"characters(n    )"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"characters(n)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"endElement(,,Context)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"  match='Context'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"  bodyText='nn    n    n    n    n    nn    n    n'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"  Fire body() for SetPropertiesRule[]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"  Fire end() for SetPropertiesRule[]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"endDocument():  2 elements left"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"Successfully processed context [/MyExample] configuration file [file:/opt/tomcat/conf/context.xml]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.079Z", "log":{"message":"Setting state for [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MyExample]] to [STARTING_PREP]"}}
{"type":"log",  "level":"ERROR", "neid":"0",  "time":"2022-03-03T12:18:38.081Z", "log":{"message":"Exception fixing docBase for context [/MyExample]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.081Z", "log":{"message":"Starting MyExample"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.087Z", "log":{"message":"Configuring default Resources"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.091Z", "log":{"message":"Setting state for [org.apache.catalina.webresources.StandardRoot@6b587673] to [INITIALIZING]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.091Z", "log":{"message":"Managed= Catalina:type=WebResourceRoot,host=localhost,context=/MyExample"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.091Z", "log":{"message":"Looking for descriptor "}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.092Z", "log":{"message":"Found jar:file:/opt/tomcat/lib/catalina.jar!/org/apache/catalina/webresources/mbeans-descriptors.xml"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.092Z", "log":{"message":"setDocumentLocator(com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy@1bbae752)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.092Z", "log":{"message":"startDocument()"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.092Z", "log":{"message":"resolveEntity('-//Apache Software Foundation//DTD Model MBeans Configuration File', 'http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd', 'null')"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.093Z", "log":{"message":" Resolving to alternate DTD 'jar:file:/opt/tomcat/lib/tomcat-coyote.jar!/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"startElement(,,mbeans-descriptors)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"  New match='mbeans-descriptors'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"No rules found matching [mbeans-descriptors]"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"ignorableWhitespace(nn  )"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"startElement(,,mbean)"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"  New match='mbeans-descriptors/mbean'"}}
{"type":"log",  "level":"DEBUG", "neid":"0",  "time":"2022-03-03T12:18:38.094Z", "log":{"message":"  Fire begin() for ObjectCreateRule[className=org.apache.tomcat.util.modeler.ManagedBean, attributeName=null]"}}

当我在系统上的本地docker中运行它时,不会看到这个错误,因为只有在kubernetes集群上部署它时,我才会看到这个错误。但应用程序在错误发生后部署成功,我可以访问这些服务。此外,tomcat初始化和部署应用程序所花费的时间超过5分钟。和当地码头工人一样,它在几秒钟内到达。不知道这个错误是否导致了延迟。任何帮助都将不胜感激。

这是由于kubernetes pod中的权限问题。我用root用户将war文件复制到tomcat/webapps目录中,然后在dockerFile中切换到tomcat用户。不知何故,它曾经在我的系统中的本地docker中工作,但在kubernetes pod中失败了。

最新更新