简体   繁体   English

将Wiremock作为战争部署到Weblogic时的验证问题

[英]Validation problem while deploying Wiremock to Weblogic as a war

I need to deploy Wiremock as a WAR to Weblogic 12.2.1.2 but during the deployment I get the a long exception. 我需要将Wiremock作为WAR部署到Weblogic 12.2.1.2,但是在部署期间,我遇到了一个漫长的例外。 I use web.xml file from the sample-war project from git. 我使用git的sample-war项目中的 web.xml文件。

In my pom.xml I only use the following dependency: 在我的pom.xml中,我仅使用以下依赖项:

<dependency>
    <groupId>com.github.tomakehurst</groupId>
    <artifactId>wiremock</artifactId>
    <version>2.19.0</version>
</dependency>

I can deploy my WAR to Tomcat 9.x and everything works fine. 我可以将WAR部署到Tomcat 9.x,并且一切正常。 But I need to use Weblogic and the same WAR does not work there. 但是我需要使用Weblogic,并且相同的WAR无法在其中运行。 This is the beginning of the long exception I get: 这是我得到的长异常的开始:

####<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)

I have checked the mentioned web.xm file but this totally okay. 我已经检查了提到的web.xm文件,但这完全可以。 I have tried to use web.xml v3.0 and 3.1 as well. 我也尝试过使用web.xml v3.03.1 Both of them not working. 他们两个都不工作。 It seems that the real problem is not with web.xml file. 似乎真正的问题不在web.xml文件中。 It comes from listener: com.github.tomakehurst.wiremock.servlet.WireMockWebContextListener 它来自侦听器: com.github.tomakehurst.wiremock.servlet.WireMockWebContextListener

Is there any idea what is wrong here and how to fix it? 有什么主意在哪里,怎么解决?

The following steps need to be performed in order to have a working WAR file with WireMock 2.19.0: 为了使WireMock 2.19.0中的WAR文件正常工作,需要执行以下步骤:

Issue (1) : 问题(1)

Element not allowed: description@ http://xmlns.jcp.org/xml/ns/javaee in element listener@ http://xmlns.jcp.org/xml/ns/javaee 不允许的元素:元素侦听器中的description @ http://xmlns.jcp.org/xml/ns/javaee@@ http://xmlns.jcp.org/xml/ns/javaee

Solution: Remove description tag from the listener section of the web.xml file. 解决方案:从web.xml文件的listener部分删除description标签。

Issue (2) : 问题(2)

java.lang.NullPointerException at com.github.tomakehurst.wiremock.common.ServletContextFileSource.getRootFile(ServletContextFileSource.java:35) com.github.tomakehurst.wiremock.common.ServletContextFileSource.getRootFile(ServletContextFileSource.java:35)上的java.lang.NullPointerException

Solution 1: Weblogic admin console > Domain > Web Applications > click the checkbox "Archived Real Path Enabled" 解决方案1:Weblogic管理控制台>“域”>“ Web应用程序”>单击“已归档实际路径已启用”复选框

Solution 2: add weblogic.xml file to WEB_INF dirrectory, content: 解决方案2:将weblogic.xml文件添加到WEB_INF目录中,内容:

<weblogic-web-app>
    <container-descriptor>
        <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
</weblogic-web-app>

Issue (3) : 问题(3)

Classpath conflicts 类路径冲突

Add prefer-application-packages to WEB_INF/weblogic.xml file: prefer-application-packages添加到WEB_INF/weblogic.xml文件中:

<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>

Issue (4) : 问题(4)

Change the mapping URL of the WireMockHandlerDispatchingServlet : 更改WireMockHandlerDispatchingServlet的映射URL:

<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>

Issue (5) : 问题(5)

Exclude Jetty related dependencies: 排除与Jetty相关的依赖项:

<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>

+1 +1

Remove WireMock admin service. 删除WireMock管理员服务。

Delete wiremock-admin-handler-servlet servlet and its servlet-mapping configuration from WEB_INF/weblogic.xml file. WEB_INF/weblogic.xml文件中删除wiremock-admin-handler-servlet servlet及其servlet-mapping配置。

With steps above you can build a WAR which is deployable to Weblogic 12.2.x server. 通过上述步骤,您可以构建可部署到Weblogic 12.2.x服务器的WAR。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM