我需要将Wiremock作为WAR部署到Weblogic 12.2.1.2,但是在部署期间,我遇到了一个漫长的例外。
我使用git中sample-war project中的web.xml
文件。
在我的pom.xml中,我仅使用以下依赖项:
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.19.0</version>
</dependency>
我可以将WAR部署到Tomcat 9.x,并且一切正常。 但是我需要使用Weblogic,并且相同的WAR无法在其中运行。这是我得到的长异常的开始:
####<oct 16, 2018, 10:03:26,646 DU CEST> <Error> <Munger> <mylinux> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <weblogic> <> <00dcc5b7-e294-4d36-943a-2d6d188fdd23-00000013> <1539720206646> <[severity-value: 8] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-2156200> <Unable to load descriptor /home/user/servers/oracle/weblogic/12.2.1.2.0/user_projects/domains/base_domain/servers/AdminServer/tmp/.appmergegen_1539720205648_wire-mock-demo-1.0-SNAPSHOT.war/WEB-INF/web.xml of module wire-mock-demo-1.0-SNAPSHOT.war. The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
<7:11> problem: cvc-complex-type.2.4b: Element not allowed: description@http://xmlns.jcp.org/xml/ns/javaee in element listener@http://xmlns.jcp.org/xml/ns/javaee
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:245)
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:231)
at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:155)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:345)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:307)
at weblogic.application.descriptor.AbstractDescriptorLoader2.getDescriptorBeanFromReader(AbstractDescriptorLoader2.java:870)
at weblogic.application.descriptor.AbstractDescriptorLoader2.createDescriptorBean(AbstractDescriptorLoader2.java:445)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBeanWithoutPlan(AbstractDescriptorLoader2.java:832)
at weblogic.application.descriptor.AbstractDescriptorLoader2.loadDescriptorBean(AbstractDescriptorLoader2.java:841)
at weblogic.servlet.internal.WebAppDescriptor.getWebAppBean(WebAppDescriptor.java:145)
at weblogic.servlet.utils.WarUtils.getWebAppBean(WarUtils.java:201)
at weblogic.servlet.tools.WARModule.loadDescriptors(WARModule.java:451)
at weblogic.servlet.tools.WARModule.merge(WARModule.java:520)
at weblogic.application.compiler.ToolsModuleWrapper.merge(ToolsModuleWrapper.java:96)
at weblogic.application.utils.CustomModuleManager.merge(CustomModuleManager.java:78)
at weblogic.application.compiler.flow.SingleModuleMergeFlow.proecessModule(SingleModuleMergeFlow.java:27)
at weblogic.application.compiler.flow.SingleModuleFlow.compile(SingleModuleFlow.java:64)
at weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java:70)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
我已经检查了提到的web.xm
文件,但这完全可以。我也尝试过使用web.xml v3.0
和3.1
。他们两个都不工作。
似乎真正的问题不在web.xml文件中。它来自侦听器:com.github.tomakehurst.wiremock.servlet.WireMockWebContextListener
有什么主意在哪里,怎么解决?
答案 0 :(得分:0)
为了在WireMock 2.19.0中具有有效的WAR文件,需要执行以下步骤:
问题(1):
不允许的元素: 元素中的description @ http://xmlns.jcp.org/xml/ns/javaee 监听者@ http://xmlns.jcp.org/xml/ns/javaee
解决方案:从import Tkinter as tk
import ttk
import signal
class LoginUI:
def __init__(self, controller, frame):
self.controller = controller
self.frame = frame
self.dc_list = ['Login first']
self.button = tk.Button(self.frame, text='Login', command=self.change_combobox)
self.button.grid(column=0, row=0, pady=5)
def change_combobox(self):
self.controller.query.dc_combobox['values'] = ['Site_1', 'Site_2', 'Site_3']
self.controller.query.dc.set('Site_1')
class QueryUI:
def __init__(self, frame, dc_list):
self.frame = frame
self.dc = tk.StringVar()
tk.Label(self.frame, text='Site:').grid(column=0, row=0, sticky="w")
self.dc_combobox = ttk.Combobox(self.frame, textvariable=self.dc, width=20, state='readonly')
self.dc_combobox['values'] = dc_list
self.dc_combobox.grid(column=1, row=0, sticky="w")
class App:
def __init__(self, root):
self.root = root
self.root.title('Logging Handler')
self.root.columnconfigure(0, weight=1)
self.root.rowconfigure(0, weight=1)
left_frame = tk.Frame(self.root, padx=5, pady=5)
login_frame = tk.LabelFrame(left_frame, text="Login", borderwidth=2, relief="groove", padx=5, pady=5)
query_frame = tk.LabelFrame(left_frame, text="Query", borderwidth=2, relief="groove", padx=5, pady=5)
left_frame.grid(row=0, column=0, sticky="nw")
login_frame.grid(row=0, column=0, pady=5, sticky="nw")
query_frame.grid(row=1, column=0, pady=5, sticky="nw")
self.login = LoginUI(self, login_frame)
self.query = QueryUI(query_frame, self.login.dc_list)
self.root.protocol('WM_DELETE_WINDOW', self.quit)
self.root.bind('<Control-q>', self.quit)
signal.signal(signal.SIGINT, self.quit)
def quit(self, *args):
self.root.destroy()
if __name__ == '__main__':
root = tk.Tk()
app = App(root)
app.root.mainloop()
文件的description
部分删除listener
标记。
问题(2):
com.github.tomakehurst.wiremock.common.ServletContextFileSource.getRootFile(ServletContextFileSource.java:35)上的java.lang.NullPointerException
解决方案1:Weblogic管理控制台>域> Web应用程序>单击“已存档的实际路径已启用”复选框
解决方案2:将web.xml
文件添加到weblogic.xml
目录中,内容:
WEB_INF
问题(3):
类路径冲突
将<weblogic-web-app>
<container-descriptor>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
</weblogic-web-app>
添加到prefer-application-packages
文件中:
WEB_INF/weblogic.xml
问题(4):
更改<prefer-application-packages>
<package-name>com.fasterxml.jackson.*</package-name>
<package-name>com.google.common.*</package-name>
<package-name>com.google.thirdparty.*</package-name>
<package-name>net.minidev.json.*</package-name>
</prefer-application-packages>
的映射URL:
WireMockHandlerDispatchingServlet
问题(5):
排除与Jetty相关的依赖项:
<servlet>
<servlet-name>wiremock-mock-service-handler-servlet</servlet-name>
...
<init-param>
<param-name>mappedUnder</param-name>
<param-value>/mapping</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>wiremock-mock-service-handler-servlet</servlet-name>
<url-pattern>/mapping/*</url-pattern>
</servlet-mapping>
+1
删除WireMock管理服务。
从<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.19.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</exclusion>
</exclusions>
</dependency>
文件中删除wiremock-admin-handler-servlet
servlet及其servlet-mapping
配置。
通过上述步骤,您可以构建可部署到Weblogic 12.2.x服务器的WAR。