Search code examples
mavenwebweb-fragment

Error deploing web application using two web fragments


Im trying to use two web-fragments in my web aplication and in deploy time i got the follow error:

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

I tried to change the name and diplay tag value of web-fragment.xml but the error persist. When i use only one web-fragment in my pom it works fine.

Here is the two web-fragment: 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>

This is the block of pom with both dependencies.

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

I think thar the problem is in web-fragment.xml. Can someone can help me?


Solution

  • After many attempts i did discover that the element <display>in web-fragment.xml cannot be present in two or more web fragments components (in each web-fragment.xml). In moment of generating web.xml cannot place two times the tag <displayName>, causing a conflict merge. The tag <name> is required and can be repeated e many web-fragment.xml