From 09bfb77e5fdac357cd47df742cce3d1674a0f0b3 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Fri, 6 Apr 2018 09:18:47 +1000 Subject: [PATCH] Issue #2409 Ensure no duplicate config classes in osgi (#2416) Signed-off-by: Jan Bartel --- .../jetty/osgi/boot/AbstractWebAppProvider.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java index 1aa83a46841..2ac88bee6d0 100644 --- a/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java +++ b/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/AbstractWebAppProvider.java @@ -590,15 +590,20 @@ public abstract class AbstractWebAppProvider extends AbstractLifeCycle implement Configuration.ClassList defaults = Configuration.ClassList.serverDefault(_serverWrapper.getServer()); //add before JettyWebXmlConfiguration - if (annotationsAvailable()) + if (annotationsAvailable() && !defaults.contains("org.eclipse.jetty.osgi.annotations.AnnotationConfiguration")) defaults.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.osgi.annotations.AnnotationConfiguration"); //add in EnvConfiguration and PlusConfiguration just after FragmentConfiguration if (jndiAvailable()) - defaults.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", - "org.eclipse.jetty.plus.webapp.EnvConfiguration", - "org.eclipse.jetty.plus.webapp.PlusConfiguration"); + { + if (!defaults.contains("org.eclipse.jetty.plus.webapp.EnvConfiguration")) + defaults.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration", + "org.eclipse.jetty.plus.webapp.EnvConfiguration"); + if (!defaults.contains("org.eclipse.jetty.plus.webapp.PlusConfiguration")) + defaults.addAfter("org.eclipse.jetty.plus.webapp.EnvConfiguration", "org.eclipse.jetty.plus.webapp.PlusConfiguration"); + } + String[] asArray = new String[defaults.size()]; return defaults.toArray(asArray); }