deployment - WebLogic 12c 在部署期间不遵守“prefer-web-inf-classes”或“prefer-application-packages”
问题描述
我在使用 WebLogic 12.1.3.0.0 时遇到了一个非常奇怪的问题。我有一个应用程序在部署期间导致NullPointerException
内部出现错误,但该应用程序在出现错误后运行良好。AdminServer
NullPointerException
部署期间发生是因为部署过程不遵守我的部署描述符中的以下设置:
AppName.war/WEB-INF/weblogic.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app>
<context-root>AppName</context-root>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
并且AppName.ear/META-INF/weblogic-application.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application>
<prefer-application-packages>
<package-name>javax.faces.*</package-name>
</prefer-application-packages>
</weblogic-application>
由于这些设置被忽略,javax.faces.webapp.FacesServlet
类由系统类加载器 ( sun.misc.Launcher$AppClassLoader
)加载$WL_HOME/wlserver/modules/glassfish.jsf_2.0.0.0_2-1-20.jar
,而不是从 WAR 类加载器加载。这最终导致NPE
由于一些写得不好的代码 in weblogic.servlet.internal.WebAnnotationProcessor
,它假设javax.faces.webapp.FacesServlet
将用 注释@MultipartConfig
,它不在glassfish.jsf_2.0.0.0_2-1-20.jar
. 此类的正确版本位于AppName.ear/AppName.war/WEB-INF/lib/jsf-api-2.2.16.jar
.
我已经通过远程调试 AdminServer 和打开 Classloader Logging 验证了所有这些,这表明:
GCL[61ba0535][AppName.ear@AppName.war] GCL.loadClass(javax.faces.webapp.FacesServlet)>
FCL[10d372cb][] FCL.loadClass(javax.faces.webapp.FacesServlet)>
FCL[10d372cb][] FCL.findClass(javax.faces.webapp.FacesServlet)>
GCL[75bc8d74][DomainLib] GCL.loadClass(javax.faces.webapp.FacesServlet)>
这个问题使得无法AppName
在管理控制台中打开部署,b/c 它总是抛出错误(在日志中有前面提到的 NPE):
The configuration for AppName is still being loaded from your last request, please wait a moment and retry.
与此相反,当我在部署它的服务器中运行 EAR 时,完全相同的 EAR 工作得很好。为了证明类加载工作正常,这里是日志:
CACL[6eb4b4ad][AppName@AppName] CACL.loadClass(javax.faces.webapp.FacesServlet)>
CACL[6eb4b4ad][AppName@AppName] GCL.loadClass(javax.faces.webapp.FacesServlet)>
FCL[37ee3b94][AppName@AppName] FCL.loadClass(javax.faces.webapp.FacesServlet)>
FCL[37ee3b94][AppName@AppName] FCL.findClass(javax.faces.webapp.FacesServlet)>
GCL[3cc63f62][AppName@] GCL.loadClass(javax.faces.webapp.FacesServlet)>
FCL[770e8d03][] FCL.loadClass(javax.faces.webapp.FacesServlet)>
FCL[770e8d03][] FCL.findClass(javax.faces.webapp.FacesServlet)>
FCL[770e8d03][] FCL.matchesClassFilterList(javax.faces.webapp.FacesServlet): javax.faces. index : 0 end : 12>
FCL[770e8d03][] FCL.findClass(javax.faces.webapp.FacesServlet): Found match>
GCL[3cc63f62][AppName@] GCL.findClass(javax.faces.webapp.FacesServlet)>
GCL[3cc63f62][AppName@] GCL.findLocalClass(javax.faces.webapp.FacesServlet): Classpath in use: <LIST OF ALL JARS IN MY EAR>
GCL[3cc63f62][AppName@] GCL.findLocalClass(javax.faces.webapp.FacesServlet): not found>
CACL[6eb4b4ad][AppName@AppName] CACL.findClass(javax.faces.webapp.FacesServlet)>
CACL[6eb4b4ad][AppName@AppName] CACL.findClass(javax.faces.webapp.FacesServlet): About to loadClass>
CACL[6eb4b4ad][AppName@AppName] GCL.findClass(javax.faces.webapp.FacesServlet)>
CACL[6eb4b4ad][AppName@AppName] GCL.findLocalClass(javax.faces.webapp.FacesServlet): Classpath in use: <LIST OF ALL JARS IN MY WAR>
CACL[6eb4b4ad][AppName@AppName] GCL.findLocalClass(javax.faces.webapp.FacesServlet): Found class>
CACL[6eb4b4ad][AppName@AppName] GCL.defineClass(javax.faces.webapp.FacesServlet)>
我不知道如何解决这个问题...为什么 AdminServer 完全忽略了我的 EAR 中的部署描述符,而运行 EAR 的服务器正确设置了所有内容?
任何想法,将不胜感激。
解决方案
推荐阅读
- javascript - 如何使用 Node.js 将法语口音写入文件
- android-layout - Android GridView:以父级为中心的两个相等宽度和高度的列
- python - RuntimeError:读取网络时出错:无法解析未来版本:10
- c - 试图理解我的代码中的问题
- python - 循环遍历熊猫数据框并分配值
- sql - 从 csv 导入的数据的 SQLite 时间格式问题。多个尾随零
- javascript - Smart Paypal Button 在我的 React 应用程序中发出 SameSite cookie 警告
- python - 如何过滤熊猫数据框中的数字?
- c++ - 类成员函数参数列表是否可能依赖于模板参数?
- cordova - 为什么cordova plugin camera plugin不能与ionic 4一起使用?