diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java index e6882556ad39..312d0adc7f32 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebApp.java @@ -52,9 +52,8 @@ public static void main( String[] args ) throws Exception WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); File warFile = new File( - "../../jetty-distribution/target/distribution/test/webapps/test/"); + "../../tests/test-jmx/jmx-webapp/target/jmx-webapp"); webapp.setWar(warFile.getAbsolutePath()); - webapp.addAliasCheck(new AllowSymLinkAliasChecker()); // A WebAppContext is a ContextHandler as well so it needs to be set to // the server so it is aware of where to send the appropriate requests. diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java index 05bebef9845b..60e42d8c8e02 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java @@ -558,7 +558,7 @@ public void parse (Set handlers, String className, ClassNameR if (!isParsed(className) || resolver.shouldOverride(className)) { className = className.replace('.', '/')+".class"; - URL resource = Loader.getResource(this.getClass(), className); + URL resource = Loader.getResource(className); if (resource!= null) { Resource r = Resource.newResource(resource); @@ -593,7 +593,7 @@ public void parse (Set handlers, Class clazz, ClassNameRes if (!isParsed(cz.getName()) || resolver.shouldOverride(cz.getName())) { String nameAsResource = cz.getName().replace('.', '/')+".class"; - URL resource = Loader.getResource(this.getClass(), nameAsResource); + URL resource = Loader.getResource(nameAsResource); if (resource!= null) { Resource r = Resource.newResource(resource); @@ -652,7 +652,7 @@ public void parse (Set handlers, List classNames, Cla if ((resolver == null) || (!resolver.isExcluded(s) && (!isParsed(s) || resolver.shouldOverride(s)))) { s = s.replace('.', '/')+".class"; - URL resource = Loader.getResource(this.getClass(), s); + URL resource = Loader.getResource(s); if (resource!= null) { Resource r = Resource.newResource(resource); diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java index 6faa9590e344..7cb4dfd861f2 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/Util.java @@ -201,7 +201,7 @@ public static Class convertType (Type t) } case Type.OBJECT: { - return (Loader.loadClass(null, t.getClassName())); + return (Loader.loadClass(t.getClassName())); } case Type.SHORT: { diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java index 778d2284f49b..0d47c33db086 100644 --- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java +++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/JAASLoginService.java @@ -222,7 +222,7 @@ else if (callback instanceof RequestParameterCallback) } else { - Class clazz = Loader.loadClass(getClass(), _callbackHandlerClass); + Class clazz = Loader.loadClass(_callbackHandlerClass); callbackHandler = (CallbackHandler)clazz.newInstance(); } //set up the login context diff --git a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java index 86ca2349b713..fd20a1f3957f 100644 --- a/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java +++ b/jetty-jaas/src/main/java/org/eclipse/jetty/jaas/spi/JDBCLoginModule.java @@ -103,7 +103,7 @@ public void initialize(Subject subject, dbPassword = ""; if (dbDriver != null) - Loader.loadClass(this.getClass(), dbDriver).newInstance(); + Loader.loadClass(dbDriver).newInstance(); } catch (ClassNotFoundException e) { diff --git a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java index 33a3a59cf90d..0c6713cfcca8 100644 --- a/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java +++ b/jetty-jmx/src/main/java/org/eclipse/jetty/jmx/ObjectMBean.java @@ -129,8 +129,21 @@ public static Object mbeanFor(Object o) String mName = pName + ".jmx." + cName + "MBean"; try - { - Class mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName); + { + Class mClass; + try + { + // Look for an MBean class from the same loader that loaded the original class + mClass = (Object.class.equals(oClass))?oClass=ObjectMBean.class:Loader.loadClass(oClass,mName); + } + catch (ClassNotFoundException e) + { + // Not found, so if not the same as the thread context loader, try that. + if (Thread.currentThread().getContextClassLoader()==oClass.getClassLoader()) + throw e; + LOG.ignore(e); + mClass=Loader.loadClass(oClass,mName); + } if (LOG.isDebugEnabled()) LOG.debug("ObjectMbean: mbeanFor {} mClass={}", o, mClass); diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java index 129b300e9a61..1cd7570b5b19 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java @@ -127,7 +127,7 @@ public void callStartup(WebAppContext context) try { for (String s : _applicableTypeNames) - classes.add(Loader.loadClass(context.getClass(), s)); + classes.add(Loader.loadClass(s)); context.getServletContext().setExtendedListenerTypes(true); if (LOG.isDebugEnabled()) diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java index f226179e6732..16f555fd8aa3 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/LifeCycleCallback.java @@ -106,7 +106,7 @@ public void callback (Object instance) if (_target == null) { if (_targetClass == null) - _targetClass = Loader.loadClass(null, _className); + _targetClass = Loader.loadClass(_className); _target = _targetClass.getDeclaredMethod(_methodName, TypeUtil.NO_ARGS); } diff --git a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java index 2f26edfc7ac6..1a401d668903 100644 --- a/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java +++ b/jetty-plus/src/main/java/org/eclipse/jetty/plus/webapp/EnvConfiguration.java @@ -41,6 +41,7 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.webapp.AbstractConfiguration; import org.eclipse.jetty.webapp.Configuration; +import org.eclipse.jetty.webapp.WebAppClassLoader; import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.xml.XmlConfiguration; @@ -113,7 +114,7 @@ public Binding bind(NamingContext ctx, Binding binding) { localContextRoot.getRoot().addListener(listener); XmlConfiguration configuration = new XmlConfiguration(jettyEnvXmlUrl); - configuration.configure(context); + WebAppClassLoader.runWithServerClassAccess(()->{configuration.configure(context);return null;}); } finally { diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java b/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java index 089b89491175..4137a563ecf6 100644 --- a/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java +++ b/jetty-security/src/main/java/org/eclipse/jetty/security/JDBCLoginService.java @@ -164,7 +164,7 @@ protected void doStart() throws Exception + " = u." + _userRoleTableRoleKey; - Loader.loadClass(this.getClass(), _jdbcDriver).newInstance(); + Loader.loadClass(_jdbcDriver).newInstance(); super.doStart(); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java index d45e10082189..668df07f961e 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java @@ -1673,7 +1673,7 @@ public synchronized Class loadClass(String className) throws ClassNotFoundExc return null; if (_classLoader == null) - return Loader.loadClass(this.getClass(),className); + return Loader.loadClass(className); return _classLoader.loadClass(className); } @@ -2317,7 +2317,7 @@ public void addListener(String className) try { @SuppressWarnings({ "unchecked", "rawtypes" }) - Class clazz = _classLoader==null?Loader.loadClass(ContextHandler.class,className):(Class)_classLoader.loadClass(className); + Class clazz = _classLoader==null?Loader.loadClass(className):(Class)_classLoader.loadClass(className); addListener(clazz); } catch (ClassNotFoundException e) @@ -2410,7 +2410,7 @@ public ClassLoader getClassLoader() //classloader, or a parent of it try { - Class reflect = Loader.loadClass(getClass(), "sun.reflect.Reflection"); + Class reflect = Loader.loadClass("sun.reflect.Reflection"); Method getCallerClass = reflect.getMethod("getCallerClass", Integer.TYPE); Class caller = (Class)getCallerClass.invoke(null, 2); diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/BaseHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/BaseHolder.java index 5455b4ad5154..9d3f854b1184 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/BaseHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/BaseHolder.java @@ -92,7 +92,7 @@ public void doStart() { try { - _class=Loader.loadClass(Holder.class, _className); + _class=Loader.loadClass(_className); if(LOG.isDebugEnabled()) LOG.debug("Holding {} from {}",_class,_class.getClassLoader()); } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index f79803c8035f..da6dd7634c67 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -421,7 +421,7 @@ public ServletHolder addServlet(String className,String pathSpec) */ public ServletHolder addServlet(Class servlet,String pathSpec) { - return getServletHandler().addServletWithMapping(servlet.getName(), pathSpec); + return getServletHandler().addServletWithMapping(servlet,pathSpec); } /* ------------------------------------------------------------ */ diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java index 79b553b1b5ce..0bae106bb465 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHolder.java @@ -875,7 +875,7 @@ private void detectJspContainer () try { //check for apache - Loader.loadClass(Holder.class, APACHE_SENTINEL_CLASS); + Loader.loadClass(APACHE_SENTINEL_CLASS); if (LOG.isDebugEnabled())LOG.debug("Apache jasper detected"); _jspContainer = JspContainer.APACHE; } @@ -897,7 +897,7 @@ private String getNameOfJspClass (String jsp) jsp = jsp.substring(i); try { - Class jspUtil = Loader.loadClass(Holder.class, "org.apache.jasper.compiler.JspUtil"); + Class jspUtil = Loader.loadClass("org.apache.jasper.compiler.JspUtil"); Method makeJavaIdentifier = jspUtil.getMethod("makeJavaIdentifier", String.class); return (String)makeJavaIdentifier.invoke(null, jsp); } @@ -923,7 +923,7 @@ private String getPackageOfJspClass (String jsp) return ""; try { - Class jspUtil = Loader.loadClass(Holder.class, "org.apache.jasper.compiler.JspUtil"); + Class jspUtil = Loader.loadClass("org.apache.jasper.compiler.JspUtil"); Method makeJavaPackage = jspUtil.getMethod("makeJavaPackage", String.class); return (String)makeJavaPackage.invoke(null, jsp.substring(0,i)); } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/listener/ELContextCleaner.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/listener/ELContextCleaner.java index ed4987138f35..40303b1c26ed 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/listener/ELContextCleaner.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/listener/ELContextCleaner.java @@ -52,7 +52,7 @@ public void contextDestroyed(ServletContextEvent sce) try { //Check that the BeanELResolver class is on the classpath - Class beanELResolver = Loader.loadClass(this.getClass(), "javax.el.BeanELResolver"); + Class beanELResolver = Loader.loadClass("javax.el.BeanELResolver"); //Get a reference via reflection to the properties field which is holding class references Field field = getField(beanELResolver); diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java index 8730764072fc..37c3453a3a40 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java @@ -935,7 +935,7 @@ protected Object parseObject(Source source) { try { - Class c = Loader.loadClass(JSON.class,classname); + Class c = Loader.loadClass(classname); return convertTo(c,map); } catch (ClassNotFoundException e) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONCollectionConvertor.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONCollectionConvertor.java index 2f158b8921d2..22310d369b31 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONCollectionConvertor.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONCollectionConvertor.java @@ -36,7 +36,7 @@ public Object fromJSON(Map object) { try { - Collection result = (Collection)Loader.loadClass(getClass(), (String)object.get("class")).newInstance(); + Collection result = (Collection)Loader.loadClass((String)object.get("class")).newInstance(); Collections.addAll(result, (Object[])object.get("list")); return result; } diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java index 7f49daa61145..683e53bf10ef 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONEnumConvertor.java @@ -43,7 +43,7 @@ public class JSONEnumConvertor implements JSON.Convertor { try { - Class e = Loader.loadClass(getClass(),"java.lang.Enum"); + Class e = Loader.loadClass("java.lang.Enum"); _valueOf=e.getMethod("valueOf",Class.class,String.class); } catch(Exception e) @@ -68,7 +68,7 @@ public Object fromJSON(Map map) throw new UnsupportedOperationException(); try { - Class c=Loader.loadClass(getClass(),(String)map.get("class")); + Class c=Loader.loadClass((String)map.get("class")); return _valueOf.invoke(null,c,map.get("value")); } catch(Exception e) diff --git a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactory.java b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactory.java index 4f82d61c23cb..5d84e117597e 100644 --- a/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactory.java +++ b/jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSONPojoConvertorFactory.java @@ -65,7 +65,7 @@ public void toJSON(Object obj, Output out) { try { - Class cls=Loader.loadClass(JSON.class,clsName); + Class cls=Loader.loadClass(clsName); convertor=new JSONPojoConvertor(cls,_fromJson); _json.addConvertorFor(clsName, convertor); } @@ -91,7 +91,7 @@ public Object fromJSON(Map object) { try { - Class cls=Loader.loadClass(JSON.class,clsName); + Class cls=Loader.loadClass(clsName); convertor=new JSONPojoConvertor(cls,_fromJson); _json.addConvertorFor(clsName, convertor); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java index 062029cef45e..0280686a2a4c 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java @@ -46,107 +46,55 @@ public class Loader { /* ------------------------------------------------------------ */ - public static URL getResource(Class loadClass,String name) + public static URL getResource(String name) { - URL url =null; - ClassLoader context_loader=Thread.currentThread().getContextClassLoader(); - if (context_loader!=null) - url=context_loader.getResource(name); - - if (url==null && loadClass!=null) - { - ClassLoader load_loader=loadClass.getClassLoader(); - if (load_loader!=null && load_loader!=context_loader) - url=load_loader.getResource(name); - } - - if (url==null) - url=ClassLoader.getSystemResource(name); - - return url; + ClassLoader loader=Thread.currentThread().getContextClassLoader(); + return loader==null?ClassLoader.getSystemResource(name):loader.getResource(name); } /* ------------------------------------------------------------ */ /** Load a class. + *

Load a class either from the thread context classloader or if none, the system + * loader

+ * @param name the name of the new class to load * - * @param loadClass the class to use for the ClassLoader that was used - * @param name the name of the new class to load, using the same ClassLoader as the loadClass * @return Class * @throws ClassNotFoundException if not able to find the class */ @SuppressWarnings("rawtypes") - public static Class loadClass(Class loadClass,String name) + public static Class loadClass(String name) throws ClassNotFoundException { - ClassNotFoundException ex=null; - Class c =null; - ClassLoader context_loader=Thread.currentThread().getContextClassLoader(); - if (context_loader!=null ) - { - try { c=context_loader.loadClass(name); } - catch (ClassNotFoundException e) {ex=e;} - } - - if (c==null && loadClass!=null) - { - ClassLoader load_loader=loadClass.getClassLoader(); - if (load_loader!=null && load_loader!=context_loader) - { - try { c=load_loader.loadClass(name); } - catch (ClassNotFoundException e) {if(ex==null)ex=e;} - } - } - - if (c==null) - { - try { c=Class.forName(name); } - catch (ClassNotFoundException e) - { - if(ex!=null) - throw ex; - throw e; - } - } + ClassLoader loader=Thread.currentThread().getContextClassLoader(); + return (loader==null ) ? Class.forName(name) : loader.loadClass(name); + } - return c; + /* ------------------------------------------------------------ */ + /** Load a class. + * Load a class from the same classloader as the passed loadClass, or if none + * then use {@link #loadClass(String)} + * + * @return Class + * @throws ClassNotFoundException if not able to find the class + */ + @SuppressWarnings("rawtypes") + public static Class loadClass(Class loaderClass, String name) + throws ClassNotFoundException + { + if (loaderClass!=null && loaderClass.getClassLoader()!=null) + return loaderClass.getClassLoader().loadClass(name); + return loadClass(name); } - /* ------------------------------------------------------------ */ - public static ResourceBundle getResourceBundle(Class loadClass,String name,boolean checkParents, Locale locale) + public static ResourceBundle getResourceBundle(String name,boolean checkParents,Locale locale) throws MissingResourceException { - MissingResourceException ex=null; - ResourceBundle bundle =null; ClassLoader loader=Thread.currentThread().getContextClassLoader(); - while (bundle==null && loader!=null ) - { - try { bundle=ResourceBundle.getBundle(name, locale, loader); } - catch (MissingResourceException e) {if(ex==null)ex=e;} - loader=(bundle==null&&checkParents)?loader.getParent():null; - } - - loader=loadClass==null?null:loadClass.getClassLoader(); - while (bundle==null && loader!=null ) - { - try { bundle=ResourceBundle.getBundle(name, locale, loader); } - catch (MissingResourceException e) {if(ex==null)ex=e;} - loader=(bundle==null&&checkParents)?loader.getParent():null; - } - - if (bundle==null) - { - try { bundle=ResourceBundle.getBundle(name, locale); } - catch (MissingResourceException e) {if(ex==null)ex=e;} - } - - if (bundle!=null) - return bundle; - throw ex; + return loader==null ? ResourceBundle.getBundle(name, locale) : ResourceBundle.getBundle(name, locale, loader); } - /* ------------------------------------------------------------ */ /** * Generate the classpath (as a string) of all classloaders diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/JavaUtilLog.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/JavaUtilLog.java index 57178cd48afa..66b8fad26eb4 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/JavaUtilLog.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/JavaUtilLog.java @@ -95,7 +95,7 @@ public Object run() { try { - URL props = Loader.getResource(JavaUtilLog.class,properties); + URL props = Loader.getResource(properties); if (props != null) LogManager.getLogManager().readConfiguration(props.openStream()); } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java index 396b95b268c7..602d124791b3 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java @@ -132,7 +132,7 @@ public Object run() static void loadProperties(String resourceName, Properties props) { - URL testProps = Loader.getResource(Log.class,resourceName); + URL testProps = Loader.getResource(resourceName); if (testProps != null) { try (InputStream in = testProps.openStream()) @@ -169,7 +169,7 @@ public static void initialized() try { - Class log_class = __logClass==null?null:Loader.loadClass(Log.class, __logClass); + Class log_class = __logClass==null?null:Loader.loadClass(__logClass); if (LOG == null || (log_class!=null && !LOG.getClass().equals(log_class))) { LOG = (Logger)log_class.newInstance(); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index 35e0cf5eda7a..153f08ca9e41 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -269,7 +269,7 @@ public static Resource newClassPathResource(String resource) /* ------------------------------------------------------------ */ /** Find a classpath resource. * The {@link java.lang.Class#getResource(String)} method is used to lookup the resource. If it is not - * found, then the {@link Loader#getResource(Class, String)} method is used. + * found, then the {@link Loader#getResource(String)} method is used. * If it is still not found, then {@link ClassLoader#getSystemResource(String)} is used. * Unlike {@link ClassLoader#getSystemResource(String)} this method does not check for normal resources. * @param name The relative name of the resource @@ -283,7 +283,7 @@ public static Resource newClassPathResource(String name,boolean useCaches,boolea URL url=Resource.class.getResource(name); if (url==null) - url=Loader.getResource(Resource.class,name); + url=Loader.getResource(name); if (url==null) return null; return newResource(url,useCaches); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutionStrategy.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutionStrategy.java index b57697273618..676263fe4622 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutionStrategy.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/ExecutionStrategy.java @@ -83,7 +83,7 @@ public static ExecutionStrategy instanceFor(Producer producer, Executor executor { try { - Class c = Loader.loadClass(producer.getClass(),strategy); + Class c = Loader.loadClass(strategy); Constructor m = c.getConstructor(Producer.class,Executor.class); LOG.info("Use {} for {}",c.getSimpleName(),producer.getClass().getName()); return m.newInstance(producer,executor); diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/DiscoveredAnnotation.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/DiscoveredAnnotation.java index 193eedc890a7..4d8fe91c7cba 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/DiscoveredAnnotation.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/DiscoveredAnnotation.java @@ -79,7 +79,7 @@ private void loadClass () try { - _clazz = Loader.loadClass(null, _className); + _clazz = Loader.loadClass(_className); } catch (Exception e) { diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java index c6f5ce831d30..01cba016e7f4 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/JettyWebXmlConfiguration.java @@ -90,7 +90,7 @@ public void configure (WebAppContext context) throws Exception if (jetty_config==null) { - jetty_config=new XmlConfiguration(jetty.getURL()); + jetty_config=new XmlConfiguration(jetty.getURI().toURL()); } else { @@ -99,7 +99,8 @@ public void configure (WebAppContext context) throws Exception setupXmlConfiguration(jetty_config, web_inf); try { - jetty_config.configure(context); + XmlConfiguration config=jetty_config; + WebAppClassLoader.runWithServerClassAccess(()->{config.configure(context);return null;}); } catch (ClassNotFoundException e) { @@ -125,6 +126,6 @@ private void setupXmlConfiguration(XmlConfiguration jetty_config, Resource web_i { Map props = jetty_config.getProperties(); // TODO - should this be an id rather than a property? - props.put(PROPERTY_THIS_WEB_INF_URL, String.valueOf(web_inf.getURL())); + props.put(PROPERTY_THIS_WEB_INF_URL, String.valueOf(web_inf.getURI())); } } diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java index b2dc458675c2..0aae0c01abf1 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/StandardDescriptorProcessor.java @@ -273,7 +273,7 @@ public void visitServlet(WebAppContext context, Descriptor descriptor, XmlParser { try { - Loader.loadClass(this.getClass(), servlet_class); + Loader.loadClass(servlet_class); } catch (ClassNotFoundException e) { diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java index b4c684a912cd..67241f3ff091 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppClassLoader.java @@ -27,6 +27,7 @@ import java.net.URLClassLoader; import java.security.CodeSource; import java.security.PermissionCollection; +import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; @@ -35,6 +36,7 @@ import java.util.Locale; import java.util.Set; import java.util.StringTokenizer; +import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; import org.eclipse.jetty.util.IO; @@ -71,13 +73,15 @@ public class WebAppClassLoader extends URLClassLoader } private static final Logger LOG = Log.getLogger(WebAppClassLoader.class); - + private static final ThreadLocal __loadServerClasses = new ThreadLocal<>(); + private final Context _context; private final ClassLoader _parent; private final Set _extensions=new HashSet(); private String _name=String.valueOf(hashCode()); private final List _transformers = new CopyOnWriteArrayList<>(); + /* ------------------------------------------------------------ */ /** The Context in which the classloader operates. */ @@ -133,6 +137,31 @@ public interface Context String getExtraClasspath(); } + + /* ------------------------------------------------------------ */ + /** Run an action with access to ServerClasses + *

Run the passed {@link PrivilegedExceptionAction} with the classloader + * configured so as to allow server classes to be visible

+ * @param action The action to run + * @return The return from the action + * @throws Exception + */ + public static T runWithServerClassAccess(PrivilegedExceptionAction action) throws Exception + { + Boolean lsc=__loadServerClasses.get(); + try + { + __loadServerClasses.set(true); + return action.run(); + } + finally + { + if (lsc==null) + __loadServerClasses.remove(); + else + __loadServerClasses.set(lsc); + } + } /* ------------------------------------------------------------ */ /** @@ -333,7 +362,7 @@ public PermissionCollection getPermissions(CodeSource cs) public Enumeration getResources(String name) throws IOException { boolean system_class=_context.isSystemClass(name); - boolean server_class=_context.isServerClass(name); + boolean server_class=_context.isServerClass(name) && !Boolean.TRUE.equals(__loadServerClasses.get()); List from_parent = toList(server_class?null:_parent.getResources(name)); List from_webapp = toList((system_class&&!from_parent.isEmpty())?null:this.findResources(name)); @@ -376,7 +405,7 @@ public URL getResource(String name) tmp = tmp.substring(0, tmp.length()-6); boolean system_class=_context.isSystemClass(tmp); - boolean server_class=_context.isServerClass(tmp); + boolean server_class=_context.isServerClass(tmp) && !Boolean.TRUE.equals(__loadServerClasses.get()); if (LOG.isDebugEnabled()) LOG.debug("getResource({}) system={} server={} cl={}",name,system_class,server_class,this); @@ -439,7 +468,7 @@ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundE boolean tried_parent= false; boolean system_class=_context.isSystemClass(name); - boolean server_class=_context.isServerClass(name); + boolean server_class=_context.isServerClass(name) && !Boolean.TRUE.equals(__loadServerClasses.get()); if (LOG.isDebugEnabled()) LOG.debug("loadClass({}) system={} server={} cl={}",name,system_class,server_class,this); diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java index 534d1076a1de..7ca31abe8676 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java @@ -144,6 +144,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL "-org.eclipse.jetty.jaas.", // don't hide jaas classes "-org.eclipse.jetty.servlets.", // don't hide jetty servlets "-org.eclipse.jetty.servlet.DefaultServlet", // don't hide default servlet + "-org.eclipse.jetty.servlet.NoJspServlet", // don't hide noJspServlet servlet "-org.eclipse.jetty.jsp.", //don't hide jsp servlet "-org.eclipse.jetty.servlet.listener.", // don't hide useful listeners "-org.eclipse.jetty.websocket.", // don't hide websocket classes from webapps (allow webapp to use ones from system classloader) @@ -924,7 +925,7 @@ protected void loadConfigurations() if (_configurationClasses.size()==0) _configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer())); for (String configClass : _configurationClasses) - _configurations.add((Configuration)Loader.loadClass(this.getClass(), configClass).newInstance()); + _configurations.add((Configuration)Loader.loadClass(configClass).newInstance()); } /* ------------------------------------------------------------ */ diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java index 1a439d95b49b..d6e6120c4727 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebDescriptor.java @@ -23,8 +23,6 @@ import java.util.Iterator; import java.util.List; -import javax.servlet.Servlet; - import org.eclipse.jetty.util.Loader; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -89,31 +87,31 @@ protected InputSource resolveEntity(String pid, String sid) void mapResources() { //set up cache of DTDs and schemas locally - URL dtd22=Loader.getResource(Servlet.class,"javax/servlet/resources/web-app_2_2.dtd"); - URL dtd23=Loader.getResource(Servlet.class,"javax/servlet/resources/web-app_2_3.dtd"); - URL j2ee14xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/j2ee_1_4.xsd"); - URL javaee5=Loader.getResource(Servlet.class,"javax/servlet/resources/javaee_5.xsd"); - URL javaee6=Loader.getResource(Servlet.class,"javax/servlet/resources/javaee_6.xsd"); - URL javaee7=Loader.getResource(Servlet.class,"javax/servlet/resources/javaee_7.xsd"); - - URL webapp24xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-app_2_4.xsd"); - URL webapp25xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-app_2_5.xsd"); - URL webapp30xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-app_3_0.xsd"); - URL webapp31xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-app_3_1.xsd"); + URL dtd22=Loader.getResource("javax/servlet/resources/web-app_2_2.dtd"); + URL dtd23=Loader.getResource("javax/servlet/resources/web-app_2_3.dtd"); + URL j2ee14xsd=Loader.getResource("javax/servlet/resources/j2ee_1_4.xsd"); + URL javaee5=Loader.getResource("javax/servlet/resources/javaee_5.xsd"); + URL javaee6=Loader.getResource("javax/servlet/resources/javaee_6.xsd"); + URL javaee7=Loader.getResource("javax/servlet/resources/javaee_7.xsd"); + + URL webapp24xsd=Loader.getResource("javax/servlet/resources/web-app_2_4.xsd"); + URL webapp25xsd=Loader.getResource("javax/servlet/resources/web-app_2_5.xsd"); + URL webapp30xsd=Loader.getResource("javax/servlet/resources/web-app_3_0.xsd"); + URL webapp31xsd=Loader.getResource("javax/servlet/resources/web-app_3_1.xsd"); - URL webcommon30xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-common_3_0.xsd"); - URL webcommon31xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-common_3_1.xsd"); + URL webcommon30xsd=Loader.getResource("javax/servlet/resources/web-common_3_0.xsd"); + URL webcommon31xsd=Loader.getResource("javax/servlet/resources/web-common_3_1.xsd"); - URL webfragment30xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-fragment_3_0.xsd"); - URL webfragment31xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/web-fragment_3_1.xsd"); + URL webfragment30xsd=Loader.getResource("javax/servlet/resources/web-fragment_3_0.xsd"); + URL webfragment31xsd=Loader.getResource("javax/servlet/resources/web-fragment_3_1.xsd"); - URL schemadtd=Loader.getResource(Servlet.class,"javax/servlet/resources/XMLSchema.dtd"); - URL xmlxsd=Loader.getResource(Servlet.class,"javax/servlet/resources/xml.xsd"); - URL webservice11xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/j2ee_web_services_client_1_1.xsd"); - URL webservice12xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/javaee_web_services_client_1_2.xsd"); - URL webservice13xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/javaee_web_services_client_1_3.xsd"); - URL webservice14xsd=Loader.getResource(Servlet.class,"javax/servlet/resources/javaee_web_services_client_1_4.xsd"); - URL datatypesdtd=Loader.getResource(Servlet.class,"javax/servlet/resources/datatypes.dtd"); + URL schemadtd=Loader.getResource("javax/servlet/resources/XMLSchema.dtd"); + URL xmlxsd=Loader.getResource("javax/servlet/resources/xml.xsd"); + URL webservice11xsd=Loader.getResource("javax/servlet/resources/j2ee_web_services_client_1_1.xsd"); + URL webservice12xsd=Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_2.xsd"); + URL webservice13xsd=Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_3.xsd"); + URL webservice14xsd=Loader.getResource("javax/servlet/resources/javaee_web_services_client_1_4.xsd"); + URL datatypesdtd=Loader.getResource("javax/servlet/resources/datatypes.dtd"); URL jsp20xsd = null; URL jsp21xsd = null; @@ -123,10 +121,10 @@ void mapResources() try { //try both javax/servlet/resources and javax/servlet/jsp/resources to load - jsp20xsd = Loader.getResource(Servlet.class, "javax/servlet/resources/jsp_2_0.xsd"); - jsp21xsd = Loader.getResource(Servlet.class, "javax/servlet/resources/jsp_2_1.xsd"); - jsp22xsd = Loader.getResource(Servlet.class, "javax/servlet/resources/jsp_2_2.xsd"); - jsp23xsd = Loader.getResource(Servlet.class, "javax/servlet/resources/jsp_2_3.xsd"); + jsp20xsd = Loader.getResource("javax/servlet/resources/jsp_2_0.xsd"); + jsp21xsd = Loader.getResource("javax/servlet/resources/jsp_2_1.xsd"); + jsp22xsd = Loader.getResource("javax/servlet/resources/jsp_2_2.xsd"); + jsp23xsd = Loader.getResource("javax/servlet/resources/jsp_2_3.xsd"); } catch (Exception e) { @@ -134,10 +132,10 @@ void mapResources() } finally { - if (jsp20xsd == null) jsp20xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_0.xsd"); - if (jsp21xsd == null) jsp21xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_1.xsd"); - if (jsp22xsd == null) jsp22xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_2.xsd"); - if (jsp23xsd == null) jsp23xsd = Loader.getResource(Servlet.class, "javax/servlet/jsp/resources/jsp_2_3.xsd"); + if (jsp20xsd == null) jsp20xsd = Loader.getResource("javax/servlet/jsp/resources/jsp_2_0.xsd"); + if (jsp21xsd == null) jsp21xsd = Loader.getResource("javax/servlet/jsp/resources/jsp_2_1.xsd"); + if (jsp22xsd == null) jsp22xsd = Loader.getResource("javax/servlet/jsp/resources/jsp_2_2.xsd"); + if (jsp23xsd == null) jsp23xsd = Loader.getResource("javax/servlet/jsp/resources/jsp_2_3.xsd"); } redirectEntity("web-app_2_2.dtd",dtd22); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java index 5810768f974e..e6f280db2892 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserSocket.java @@ -136,7 +136,7 @@ public void onTextMessage(String message) if (message.charAt(0) == '@') { String name = message.substring(1); - URL url = Loader.getResource(BrowserSocket.class,name); + URL url = Loader.getResource(name); if (url == null) { writeMessage("Unable to find resource: " + name); diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index fb396ac742df..3e0d65a44964 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -90,10 +90,10 @@ public class XmlConfiguration private static XmlParser initParser() { XmlParser parser = new XmlParser(); - URL config60 = Loader.getResource(XmlConfiguration.class, "org/eclipse/jetty/xml/configure_6_0.dtd"); - URL config76 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_7_6.dtd"); - URL config90 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_9_0.dtd"); - URL config93 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_9_3.dtd"); + URL config60 = Loader.getResource("org/eclipse/jetty/xml/configure_6_0.dtd"); + URL config76 = Loader.getResource("org/eclipse/jetty/xml/configure_7_6.dtd"); + URL config90 = Loader.getResource("org/eclipse/jetty/xml/configure_9_0.dtd"); + URL config93 = Loader.getResource("org/eclipse/jetty/xml/configure_9_3.dtd"); parser.redirectEntity("configure.dtd",config90); parser.redirectEntity("configure_1_0.dtd",config60); parser.redirectEntity("configure_1_1.dtd",config60); @@ -365,7 +365,7 @@ private static Class nodeClass(XmlParser.Node node) throws ClassNotFoundExcep if (className == null) return null; - return Loader.loadClass(XmlConfiguration.class,className); + return Loader.loadClass(className); } /** @@ -708,7 +708,7 @@ private Object call(Object obj, XmlParser.Node node) throws Exception if (clazz!=null) { // static call - oClass=Loader.loadClass(XmlConfiguration.class,clazz); + oClass=Loader.loadClass(clazz); obj=null; } else if (obj!=null) @@ -755,7 +755,7 @@ private Object newObj(Object obj, XmlParser.Node node) throws Exception if (LOG.isDebugEnabled()) LOG.debug("XML new " + clazz); - Class oClass = Loader.loadClass(XmlConfiguration.class,clazz); + Class oClass = Loader.loadClass(clazz); // Find the elements Map namedArgMap = new HashMap<>(); @@ -846,7 +846,7 @@ private Object newArray(Object obj, XmlParser.Node node) throws Exception aClass = InetAddress.class; break; default: - aClass = Loader.loadClass(XmlConfiguration.class, type); + aClass = Loader.loadClass(type); break; } } diff --git a/tests/test-loginservice/src/test/java/org/eclipse/jetty/DataSourceLoginServiceTest.java b/tests/test-loginservice/src/test/java/org/eclipse/jetty/DataSourceLoginServiceTest.java index b8311a59efa7..51c04c509f59 100644 --- a/tests/test-loginservice/src/test/java/org/eclipse/jetty/DataSourceLoginServiceTest.java +++ b/tests/test-loginservice/src/test/java/org/eclipse/jetty/DataSourceLoginServiceTest.java @@ -172,7 +172,7 @@ public void testGetAndPasswordUpdate() throws Exception protected void changePassword (String user, String newpwd) throws Exception { - Loader.loadClass(this.getClass(), "org.apache.derby.jdbc.EmbeddedDriver").newInstance(); + Loader.loadClass("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); try (Connection connection = DriverManager.getConnection(DatabaseLoginServiceTestServer.__dbURL, "", ""); Statement stmt = connection.createStatement()) { diff --git a/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java b/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java index 92378036dd87..b0de37b9b85d 100644 --- a/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java +++ b/tests/test-loginservice/src/test/java/org/eclipse/jetty/DatabaseLoginServiceTestServer.java @@ -92,7 +92,7 @@ public static int runscript (File scriptFile) throws Exception //System.err.println("Running script:"+scriptFile.getAbsolutePath()); try (FileInputStream fileStream = new FileInputStream(scriptFile)) { - Loader.loadClass(fileStream.getClass(), "org.apache.derby.jdbc.EmbeddedDriver").newInstance(); + Loader.loadClass("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); Connection connection = DriverManager.getConnection(__dbURL, "", ""); ByteArrayOutputStream out = new ByteArrayOutputStream(); return ij.runScript(connection, fileStream, "UTF-8", out, "UTF-8"); diff --git a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java index 15e5f1d7e720..6ef67d65a74c 100644 --- a/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java +++ b/tests/test-sessions/test-sessions-common/src/main/java/org/eclipse/jetty/server/session/AbstractSessionRenewTest.java @@ -52,6 +52,7 @@ public void testSessionRenewal() throws Exception int scavengePeriod = 3; AbstractTestServer server = createServer(0, 1, scavengePeriod); WebAppContext context = server.addWebAppContext(".", contextPath); + context.setParentLoaderPriority(true); context.addServlet(TestServlet.class, servletMapping); TestHttpSessionIdListener testListener = new TestHttpSessionIdListener(); context.addEventListener(testListener);