From 6b1dfec9716397e1c5983f6c940c4621a7d4cceb Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 15 Jun 2022 10:05:56 +1000 Subject: [PATCH] reenabled more ee9 modules --- .../org/eclipse/jetty/io/QuietException.java | 11 +++ .../ee10/servlet/ServletRequestState.java | 2 +- jetty-ee9/jetty-ee9-apache-jsp/pom.xml | 2 +- .../apache/jsp/JettyJasperInitializer.java | 2 +- jetty-ee9/jetty-ee9-bom/pom.xml | 70 +++++++++---------- .../main/resources/demo/webdefault-ee9.xml | 2 +- .../security/jaspi/JaspiAuthenticator.java | 5 +- .../BasicAuthenticationAuthModule.java | 2 +- .../jaspi/DefaultAuthConfigFactoryTest.java | 8 +-- .../jetty/ee9/security/jaspi/JaspiTest.java | 16 ++--- .../jetty/ee9/jspc/plugin/JspcMojo.java | 2 +- .../jetty/ee9/nested/ContextHandler.java | 16 +++-- .../jetty/ee9/nested/HttpChannelState.java | 5 +- .../src/main/java/module-info.java | 3 +- .../jetty-ee9-osgi-boot-jsp/pom.xml | 4 +- .../src/test/config/etc/webdefault-ee9.xml | 2 +- .../src/test/resources/webdefault-ee9.xml | 2 +- .../src/main/config/etc/webdefault-ee9.xml | 2 +- .../jetty/ee9/webapp/JaasConfiguration.java | 4 +- .../jetty/ee9/webapp/JaspiConfiguration.java | 2 +- .../jetty/ee9/webapp/JspConfiguration.java | 8 +-- .../jetty/ee9/webapp/WebAppContext.java | 10 ++- .../jetty/ee9/webapp/ClassMatcherTest.java | 7 +- .../StandardDescriptorProcessorTest.java | 22 +++++- .../jetty/ee9/webapp/WebAppContextTest.java | 2 +- jetty-ee9/pom.xml | 11 ++- 26 files changed, 133 insertions(+), 89 deletions(-) diff --git a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/QuietException.java b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/QuietException.java index 9e496c5c607..0c644b27ed8 100644 --- a/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/QuietException.java +++ b/jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/QuietException.java @@ -20,6 +20,17 @@ package org.eclipse.jetty.io; */ public interface QuietException { + static boolean isQuiet(Throwable throwable) + { + while (throwable != null) + { + if (throwable instanceof QuietException) + return true; + throwable = throwable.getCause(); + } + return false; + } + class Exception extends java.lang.Exception implements QuietException { public Exception() diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletRequestState.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletRequestState.java index 260ad027fb8..9d97a9b3881 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletRequestState.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletRequestState.java @@ -757,7 +757,7 @@ public class ServletRequestState } else { - if (!(failure instanceof QuietException)) + if (!QuietException.isQuiet(failure)) LOG.warn(failure.toString()); if (LOG.isDebugEnabled()) LOG.debug("Async error", failure); diff --git a/jetty-ee9/jetty-ee9-apache-jsp/pom.xml b/jetty-ee9/jetty-ee9-apache-jsp/pom.xml index 681cb087829..c25b4fbc1bb 100644 --- a/jetty-ee9/jetty-ee9-apache-jsp/pom.xml +++ b/jetty-ee9/jetty-ee9-apache-jsp/pom.xml @@ -23,7 +23,7 @@ Jetty-specific ServletContainerInitializer for Jasper - org.eclipse.jetty.ee9.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", org.eclipse.jetty.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" + org.eclipse.jetty.ee9.apache.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", org.eclipse.jetty.ee9.jsp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional diff --git a/jetty-ee9/jetty-ee9-apache-jsp/src/main/java/org/eclipse/jetty/ee9/apache/jsp/JettyJasperInitializer.java b/jetty-ee9/jetty-ee9-apache-jsp/src/main/java/org/eclipse/jetty/ee9/apache/jsp/JettyJasperInitializer.java index 4512130a8e6..414d7e377bc 100644 --- a/jetty-ee9/jetty-ee9-apache-jsp/src/main/java/org/eclipse/jetty/ee9/apache/jsp/JettyJasperInitializer.java +++ b/jetty-ee9/jetty-ee9-apache-jsp/src/main/java/org/eclipse/jetty/ee9/apache/jsp/JettyJasperInitializer.java @@ -75,7 +75,7 @@ public class JettyJasperInitializer extends JasperInitializer @Override public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal) { - String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled"); + String tmp = context.getInitParameter("org.eclipse.jetty.ee9.jsp.precompiled"); if (tmp != null && !tmp.equals("") && Boolean.valueOf(tmp)) { if (LOG.isDebugEnabled()) diff --git a/jetty-ee9/jetty-ee9-bom/pom.xml b/jetty-ee9/jetty-ee9-bom/pom.xml index 562598d3403..1d931186ab1 100644 --- a/jetty-ee9/jetty-ee9-bom/pom.xml +++ b/jetty-ee9/jetty-ee9-bom/pom.xml @@ -58,36 +58,36 @@ import - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + org.eclipse.jetty.ee9 + jetty-ee9-annotations + ${project.version} + + + org.eclipse.jetty.ee9 + jetty-ee9-apache-jsp + ${project.version} + + + org.eclipse.jetty.ee9 + jetty-ee9-cdi + ${project.version} + + + org.eclipse.jetty.ee9 + jetty-ee9-glassfish-jstl + ${project.version} + + + org.eclipse.jetty.ee9 + jetty-ee9-jaas + ${project.version} + + + org.eclipse.jetty.ee9 + jetty-ee9-jaspi + ${project.version} + @@ -103,11 +103,11 @@ - - - - - + + org.eclipse.jetty.ee9 + jetty-ee9-plus + ${project.version} + diff --git a/jetty-ee9/jetty-ee9-demos/ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-demos/ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml index bf92279e6eb..303478184d7 100644 --- a/jetty-ee9/jetty-ee9-demos/ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-demos/ee9-demo-embedded/src/main/resources/demo/webdefault-ee9.xml @@ -200,7 +200,7 @@ jsp - org.eclipse.jetty.jsp.JettyJspServlet + org.eclipse.jetty.ee9.jsp.JettyJspServlet xpoweredBy false diff --git a/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/JaspiAuthenticator.java b/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/JaspiAuthenticator.java index a2f929da162..389787e372f 100644 --- a/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/JaspiAuthenticator.java +++ b/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/JaspiAuthenticator.java @@ -34,6 +34,7 @@ import jakarta.servlet.ServletResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.ee9.nested.Authentication; import org.eclipse.jetty.ee9.nested.UserIdentity; import org.eclipse.jetty.ee9.security.EmptyLoginService; import org.eclipse.jetty.ee9.security.IdentityService; @@ -44,8 +45,6 @@ import org.eclipse.jetty.ee9.security.WrappedAuthConfiguration; import org.eclipse.jetty.ee9.security.authentication.DeferredAuthentication; import org.eclipse.jetty.ee9.security.authentication.LoginAuthenticator; import org.eclipse.jetty.ee9.security.authentication.SessionAuthentication; -import org.eclipse.jetty.server.Authentication; -import org.eclipse.jetty.server.Authentication.User; import static org.eclipse.jetty.ee9.security.jaspi.JaspiAuthenticatorFactory.MESSAGE_LAYER; @@ -255,7 +254,7 @@ public class JaspiAuthenticator extends LoginAuthenticator // most likely validatedUser is not needed here. @Override - public boolean secureResponse(ServletRequest req, ServletResponse res, boolean mandatory, User validatedUser) throws ServerAuthException + public boolean secureResponse(ServletRequest req, ServletResponse res, boolean mandatory, Authentication.User validatedUser) throws ServerAuthException { JaspiMessageInfo info = (JaspiMessageInfo)req.getAttribute("org.eclipse.jetty.security.jaspi.info"); if (info == null) diff --git a/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/modules/BasicAuthenticationAuthModule.java b/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/modules/BasicAuthenticationAuthModule.java index 6483ab5f316..cdbf5a9fcf4 100644 --- a/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/modules/BasicAuthenticationAuthModule.java +++ b/jetty-ee9/jetty-ee9-jaspi/src/main/java/org/eclipse/jetty/ee9/security/jaspi/modules/BasicAuthenticationAuthModule.java @@ -40,7 +40,7 @@ public class BasicAuthenticationAuthModule extends BaseAuthModule private String realmName; - private static final String REALM_KEY = "org.eclipse.jetty.security.jaspi.modules.RealmName"; + private static final String REALM_KEY = "org.eclipse.jetty.ee9.security.jaspi.modules.RealmName"; public BasicAuthenticationAuthModule() { diff --git a/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/DefaultAuthConfigFactoryTest.java b/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/DefaultAuthConfigFactoryTest.java index 61eaf38ccfe..c2f1ff4d639 100644 --- a/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/DefaultAuthConfigFactoryTest.java +++ b/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/DefaultAuthConfigFactoryTest.java @@ -33,14 +33,14 @@ public class DefaultAuthConfigFactoryTest private static final String MESSAGE_LAYER = "HttpServlet"; - private final String jettyAuthConfigProvider = "org.eclipse.jetty.security.jaspi.provider.JaspiAuthConfigProvider"; + private final String jettyAuthConfigProvider = "org.eclipse.jetty.ee9.security.jaspi.provider.JaspiAuthConfigProvider"; private final String appContext = "server /test"; private final Map serverAuthModuleProperties = Map.of("ServerAuthModule", - "org.eclipse.jetty.security.jaspi.modules.BasicAuthenticationAuthModule", "AppContextID", appContext, - "org.eclipse.jetty.security.jaspi.modules.RealmName", "TestRealm"); + "org.eclipse.jetty.ee9.security.jaspi.modules.BasicAuthenticationAuthModule", "AppContextID", appContext, + "org.eclipse.jetty.ee9.security.jaspi.modules.RealmName", "TestRealm"); - private final String serverAuthModuleClassName = "org.eclipse.jetty.security.jaspi.modules.BasicAuthenticationAuthModule"; + private final String serverAuthModuleClassName = "org.eclipse.jetty.ee9.security.jaspi.modules.BasicAuthenticationAuthModule"; @Test public void testRegisterConfigProviderByClassName() throws Exception diff --git a/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/JaspiTest.java b/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/JaspiTest.java index c7e8f96ce29..a4ff00cf04a 100644 --- a/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/JaspiTest.java +++ b/jetty-ee9/jetty-ee9-jaspi/src/test/java/org/eclipse/jetty/ee9/security/jaspi/JaspiTest.java @@ -25,16 +25,16 @@ import jakarta.security.auth.message.config.AuthConfigFactory; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.ee9.nested.AbstractHandler; +import org.eclipse.jetty.ee9.nested.ContextHandler; +import org.eclipse.jetty.ee9.nested.Request; import org.eclipse.jetty.ee9.security.AbstractLoginService; import org.eclipse.jetty.ee9.security.ConstraintMapping; import org.eclipse.jetty.ee9.security.ConstraintSecurityHandler; import org.eclipse.jetty.ee9.security.RolePrincipal; import org.eclipse.jetty.ee9.security.UserPrincipal; import org.eclipse.jetty.server.LocalConnector; -import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.util.security.Constraint; import org.eclipse.jetty.util.security.Credential; @@ -94,14 +94,14 @@ public class JaspiTest { AuthConfigFactory factory = new DefaultAuthConfigFactory(); - factory.registerConfigProvider("org.eclipse.jetty.security.jaspi.provider.JaspiAuthConfigProvider", - Map.of("ServerAuthModule", "org.eclipse.jetty.security.jaspi.modules.BasicAuthenticationAuthModule", + factory.registerConfigProvider("org.eclipse.jetty.ee9.security.jaspi.provider.JaspiAuthConfigProvider", + Map.of("ServerAuthModule", "org.eclipse.jetty.ee9.security.jaspi.modules.BasicAuthenticationAuthModule", "AppContextID", "server /ctx", - "org.eclipse.jetty.security.jaspi.modules.RealmName", "TestRealm"), + "org.eclipse.jetty.ee9.security.jaspi.modules.RealmName", "TestRealm"), "HttpServlet", "server /ctx", "a test provider"); - factory.registerConfigProvider("org.eclipse.jetty.security.jaspi.provider.JaspiAuthConfigProvider", - Map.of("ServerAuthModule", "org.eclipse.jetty.security.jaspi.HttpHeaderAuthModule", + factory.registerConfigProvider("org.eclipse.jetty.ee9.security.jaspi.provider.JaspiAuthConfigProvider", + Map.of("ServerAuthModule", "org.eclipse.jetty.ee9.security.jaspi.HttpHeaderAuthModule", "AppContextID", "server /other"), "HttpServlet", "server /other", "another test provider"); diff --git a/jetty-ee9/jetty-ee9-jspc-maven-plugin/src/main/java/org/eclipse/jetty/ee9/jspc/plugin/JspcMojo.java b/jetty-ee9/jetty-ee9-jspc-maven-plugin/src/main/java/org/eclipse/jetty/ee9/jspc/plugin/JspcMojo.java index 85080baf94c..60739c9948a 100644 --- a/jetty-ee9/jetty-ee9-jspc-maven-plugin/src/main/java/org/eclipse/jetty/ee9/jspc/plugin/JspcMojo.java +++ b/jetty-ee9/jetty-ee9-jspc-maven-plugin/src/main/java/org/eclipse/jetty/ee9/jspc/plugin/JspcMojo.java @@ -70,7 +70,7 @@ import org.eclipse.jetty.util.resource.Resource; public class JspcMojo extends AbstractMojo { public static final String END_OF_WEBAPP = ""; - public static final String PRECOMPILED_FLAG = "org.eclipse.jetty.jsp.precompiled"; + public static final String PRECOMPILED_FLAG = "org.eclipse.jetty.ee9.jsp.precompiled"; /** * JettyJspC diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java index db21907ddff..91c081022c9 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/ContextHandler.java @@ -117,7 +117,7 @@ import org.slf4j.LoggerFactory; @ManagedObject("EE9 Context") public class ContextHandler extends ScopedHandler implements Attributes, Graceful, Supplier { - protected static final Environment __environment = Environment.ensure("ee9"); + public static final Environment ENVIRONMENT = Environment.ensure("ee9"); public static final int SERVLET_MAJOR_VERSION = 5; public static final int SERVLET_MINOR_VERSION = 0; public static final Class[] SERVLET_LISTENER_TYPES = @@ -226,7 +226,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu public ContextHandler() { this(null, null, null); - Objects.requireNonNull(__environment); + Objects.requireNonNull(ENVIRONMENT); } public ContextHandler(String contextPath) @@ -607,6 +607,14 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu @Override protected void doStart() throws Exception { + // If we are being started directly (rather than via a start of the CoreContextHandler), then + // we need to run ourselves in the core context + if (org.eclipse.jetty.server.handler.ContextHandler.getCurrentContext() != _coreContextHandler.getContext()) + { + _coreContextHandler.getContext().call(this::doStart, null); + return; + } + if (_logger == null) _logger = LoggerFactory.getLogger(ContextHandler.class.getName() + getLogNameSuffix()); @@ -2481,7 +2489,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu protected void doStart() throws Exception { ClassLoader old = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(__environment.getClassLoader()); + Thread.currentThread().setContextClassLoader(ENVIRONMENT.getClassLoader()); try { super.doStart(); @@ -2496,7 +2504,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu protected void doStop() throws Exception { ClassLoader old = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(__environment.getClassLoader()); + Thread.currentThread().setContextClassLoader(ENVIRONMENT.getClassLoader()); try { super.doStop(); diff --git a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannelState.java b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannelState.java index a12fb6effcd..9f3ba155cd1 100644 --- a/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannelState.java +++ b/jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpChannelState.java @@ -837,7 +837,10 @@ public class HttpChannelState } else if (_requestState != RequestState.COMPLETE) { - LOG.warn("unhandled in state {}", _requestState, new IllegalStateException(th)); + if (QuietException.isQuiet(th)) + LOG.debug("unhandled in state {}", _requestState, th); + else + LOG.warn("unhandled in state {}", _requestState, th); } } } diff --git a/jetty-ee9/jetty-ee9-openid/src/main/java/module-info.java b/jetty-ee9/jetty-ee9-openid/src/main/java/module-info.java index bcc3985c47d..0d008ccede8 100644 --- a/jetty-ee9/jetty-ee9-openid/src/main/java/module-info.java +++ b/jetty-ee9/jetty-ee9-openid/src/main/java/module-info.java @@ -18,7 +18,8 @@ module org.eclipse.jetty.security.openid requires org.eclipse.jetty.util.ajax; requires transitive org.eclipse.jetty.client; - requires transitive org.eclipse.jetty.security; + requires transitive org.eclipse.jetty.ee9.nested; + requires transitive org.eclipse.jetty.ee9.security; exports org.eclipse.jetty.ee9.security.openid; diff --git a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml index d24663c3fdc..0d3002642d9 100644 --- a/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml +++ b/jetty-ee9/jetty-ee9-osgi/jetty-ee9-osgi-boot-jsp/pom.xml @@ -131,7 +131,7 @@ org.apache.taglibs.standard.tei;version="2.0";resolution:=optional, org.apache.taglibs.standard.tlv;version="2.0";resolution:=optional, org.apache.tomcat;version="[10,11)";resolution:=optional, - org.eclipse.jetty.jsp;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))";resolution:=optional, + org.eclipse.jetty.ee9.jsp;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))";resolution:=optional, org.osgi.*, org.xml.*;resolution:=optional, org.xml.sax.*;resolution:=optional, @@ -140,7 +140,7 @@ org.w3c.dom.ls;resolution:=optional, javax.xml.parser;resolution:=optional - org.eclipse.jetty.jsp.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))", + org.eclipse.jetty.ee9.jsp.*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))", org.apache.jasper.*;version="[$(version;===;${jspImpl.osgiVersion}),$(version;+;${jspImpl.osgiVersion}))", org.apache.el.*;version="[$(version;===;${jspImpl.osgiVersion}),$(version;+;${jspImpl.osgiVersion}))" diff --git a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml index b7620718ed0..dd0520f1934 100644 --- a/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-osgi/test-jetty-ee9-osgi/src/test/config/etc/webdefault-ee9.xml @@ -277,7 +277,7 @@ jsp - org.eclipse.jetty.jsp.JettyJspServlet + org.eclipse.jetty.ee9.jsp.JettyJspServlet logVerbosityLevel DEBUG diff --git a/jetty-ee9/jetty-ee9-tests/test-integration/src/test/resources/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-tests/test-integration/src/test/resources/webdefault-ee9.xml index b7620718ed0..dd0520f1934 100644 --- a/jetty-ee9/jetty-ee9-tests/test-integration/src/test/resources/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-tests/test-integration/src/test/resources/webdefault-ee9.xml @@ -277,7 +277,7 @@ jsp - org.eclipse.jetty.jsp.JettyJspServlet + org.eclipse.jetty.ee9.jsp.JettyJspServlet logVerbosityLevel DEBUG diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml b/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml index fdb7c701fc0..0fc14a43085 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml +++ b/jetty-ee9/jetty-ee9-webapp/src/main/config/etc/webdefault-ee9.xml @@ -200,7 +200,7 @@ jsp - org.eclipse.jetty.jsp.JettyJspServlet + org.eclipse.jetty.ee9.jsp.JettyJspServlet xpoweredBy false diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaasConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaasConfiguration.java index 3fa2d7dd210..853ceb9a9b0 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaasConfiguration.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaasConfiguration.java @@ -33,7 +33,7 @@ public class JaasConfiguration extends AbstractConfiguration { addDependencies(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class, FragmentConfiguration.class); addDependents(WebAppConfiguration.class); - protectAndExpose("org.eclipse.jetty.jaas."); + protectAndExpose("org.eclipse.jetty.ee9.jaas."); } @Override @@ -41,7 +41,7 @@ public class JaasConfiguration extends AbstractConfiguration { try { - return Loader.loadClass("org.eclipse.jetty.jaas.JAASLoginService") != null; + return Loader.loadClass("org.eclipse.jetty.ee9.jaas.JAASLoginService") != null; } catch (Throwable e) { diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaspiConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaspiConfiguration.java index bb395c37dc2..c308909197a 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaspiConfiguration.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JaspiConfiguration.java @@ -39,7 +39,7 @@ public class JaspiConfiguration extends AbstractConfiguration { try { - return Loader.loadClass("org.eclipse.jetty.security.jaspi.JaspiAuthenticator") != null; + return Loader.loadClass("org.eclipse.jetty.ee9.security.jaspi.JaspiAuthenticator") != null; } catch (Throwable e) { diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JspConfiguration.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JspConfiguration.java index a9878888a96..029c95d83f5 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JspConfiguration.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/JspConfiguration.java @@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory; /** *

JSP Configuration

*

This configuration configures the WebAppContext server/system classes to - * be able to see the org.eclipse.jetty.jsp and org.eclipse.jetty.apache packages. + * be able to see the org.eclipse.jetty.ee9.jsp and org.eclipse.jetty.apache packages. * This class is defined in the webapp package, as it implements the {@link Configuration} interface, * which is unknown to the jsp package. *

@@ -33,8 +33,8 @@ public class JspConfiguration extends AbstractConfiguration { addDependencies(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class, FragmentConfiguration.class); addDependents(WebAppConfiguration.class); - protectAndExpose("org.eclipse.jetty.jsp."); - expose("org.eclipse.jetty.apache."); + protectAndExpose("org.eclipse.jetty.ee9.jsp."); + expose("org.eclipse.jetty.ee9.apache."); hide("org.eclipse.jdt."); } @@ -43,7 +43,7 @@ public class JspConfiguration extends AbstractConfiguration { try { - return Loader.loadClass("org.eclipse.jetty.jsp.JettyJspServlet") != null; + return Loader.loadClass("org.eclipse.jetty.ee9.jsp.JettyJspServlet") != null; } catch (Throwable e) { diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java index 455c99b5871..15ef2771d53 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/WebAppContext.java @@ -524,6 +524,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL @Override protected void doStart() throws Exception { + ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); try { _metadata.setAllowDuplicateFragmentNames(isAllowDuplicateFragmentNames()); @@ -531,6 +532,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL _metadata.setValidateXml((validate != null && validate)); wrapConfigurations(); preConfigure(); + Thread.currentThread().setContextClassLoader(getClassLoader()); super.doStart(); postConfigure(); @@ -546,6 +548,10 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL if (isThrowUnavailableOnStartupException()) throw t; } + finally + { + Thread.currentThread().setContextClassLoader(oldLoader); + } } private void wrapConfigurations() @@ -944,14 +950,14 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL name = String.format("%s@%x", name, hashCode()); dumpObjects(out, indent, - Dumpable.named("environment", __environment.getName()), + Dumpable.named("environment", ENVIRONMENT.getName()), new ClassLoaderDump(getClassLoader()), new DumpableCollection("Systemclasses " + name, systemClasses), new DumpableCollection("Serverclasses " + name, serverClasses), new DumpableCollection("Configurations " + name, _configurations), new DumpableCollection("Handler attributes " + name, getAttributes().asAttributeMap().entrySet()), new DumpableCollection("Context attributes " + name, getServletContext().getContextHandler().asAttributeMap().entrySet()), - new DumpableCollection("Environment attributes " + name, __environment.asAttributeMap().entrySet()), + new DumpableCollection("Environment attributes " + name, ENVIRONMENT.asAttributeMap().entrySet()), new DumpableCollection("EventListeners " + this, getEventListeners()), new DumpableCollection("Initparams " + name, getInitParams().entrySet()) ); diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/ClassMatcherTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/ClassMatcherTest.java index 5c5aa532d57..7a2af34c4a5 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/ClassMatcherTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/ClassMatcherTest.java @@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -298,8 +299,8 @@ public class ClassMatcherTest public void testJvmModule() { URI uri = TypeUtil.getLocationOfClass(String.class); - System.err.println(uri); - System.err.println(uri.toString().split("/")[0]); - System.err.println(uri.toString().split("/")[1]); + assertThat(uri, notNullValue()); + assertThat(uri.getScheme(), is("jrt")); + assertThat(uri.getPath(), is("/java.base")); } } diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/StandardDescriptorProcessorTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/StandardDescriptorProcessorTest.java index 892d0703a9a..1252b41f036 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/StandardDescriptorProcessorTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/StandardDescriptorProcessorTest.java @@ -18,6 +18,8 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -25,14 +27,28 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class StandardDescriptorProcessorTest { //TODO add tests for other methods - + Server _server; + + @BeforeEach + public void beforeEach() throws Exception + { + _server = new Server(); + _server.start(); + } + + @AfterEach + public void afterEach() throws Exception + { + _server.stop(); + Configurations.getKnown().forEach(System.err::println); + } + @Test public void testVisitSessionConfig() throws Exception { File webXml = MavenTestingUtils.getTargetFile("test-classes/web-session-config.xml"); - Server server = new Server(); WebAppContext wac = new WebAppContext(); - wac.setServer(server); + wac.setServer(_server); wac.setResourceBase(MavenTestingUtils.getTargetTestingDir("testSessionConfig").getAbsolutePath()); wac.setDescriptor(webXml.toURI().toURL().toString()); wac.start(); diff --git a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java index 18071ff3f53..928018cbb7a 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java +++ b/jetty-ee9/jetty-ee9-webapp/src/test/java/org/eclipse/jetty/ee9/webapp/WebAppContextTest.java @@ -204,7 +204,7 @@ public class WebAppContextTest //test that explicit config instances override any from server String[] classNames = {"x.y.z"}; Server server = newServer(); - server.setAttribute(Configuration.ATTR, classNames); + server.setAttribute(Configurations.class.getName(), classNames); wac.setServer(server); assertThat(wac.getConfigurations(), Matchers.contains(configs)); } diff --git a/jetty-ee9/pom.xml b/jetty-ee9/pom.xml index 7aedbc79e1c..8a7ffe180f8 100644 --- a/jetty-ee9/pom.xml +++ b/jetty-ee9/pom.xml @@ -51,16 +51,15 @@ jetty-ee9-webapp jetty-ee9-servlets jetty-ee9-demos - - + jetty-ee9-apache-jsp + jetty-ee9-glassfish-jstl jetty-ee9-annotations - + jetty-ee9-cdi - jetty-ee9-jaas - - + jetty-ee9-jaspi + jetty-ee9-jspc-maven-plugin