我试图在我的网络应用程序中使用两个网络片段,在部署时间我得到了以下错误:
INFO: Starting Servlet Engine: Apache Tomcat/8.0.21
mai 02, 2017 9:02:43 PM org.apache.tomcat.util.descriptor.web.WebXml merge
SEVERE: The display name was defined in multiple fragments with different values including fragment with name [wf2] located at [jar:file:/home/christian/christian/work/workspaces/neon2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/web1/WEB-INF/lib/wf2-0.0.1-SNAPSHOT.jar!/]
mai 02, 2017 9:02:43 PM org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)
mai 02, 2017 9:02:43 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
mai 02, 2017 9:02:43 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/web1] startup failed due to previous errors
mai 02, 2017 9:02:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
mai 02, 2017 9:02:43 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
mai 02, 2017 9:02:43 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 355 ms
我尝试更改web-fragment.xml的名称和diplay标记值,但错误仍然存在。当我在我的pom中只使用一个网络片段时,它可以正常工作。
这是两个网络片段: WF1
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment id="WebFragment_ID" version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd">
<display-name>wf1</display-name>
<name>wf1</name>
</web-fragment>
WF2
<?xml version="1.0" encoding="UTF-8"?>
<web-fragment id="WebFragment_ID" version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-fragment_3_1.xsd">
<display-name>wf2</display-name>
<name>wf2</name>
</web-fragment>
这是具有两个依赖项的pom块。
<dependency>
<groupId>wf1</groupId>
<artifactId>wf1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>wf2</groupId>
<artifactId>wf2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
我认为问题出在web-fragment.xml中。有人可以帮助我吗?
答案 0 :(得分:1)
经过多次尝试,我确实发现web-fragment.xml中的元素<display>
不能出现在两个或多个Web片段组件中(每个 web-fragment.xml
)。在生成web.xml的那一刻,不能将标记<displayName>
放置两次,从而导致冲突合并。标记<name>
是必需的,可以重复多次web-fragment.xml