Jetty web application support for Jakarta EE 10 with full servlet specification compliance
npx @tessl/cli install tessl/maven-org-eclipse-jetty-ee10--jetty-ee10-webapp@12.0.0Jetty EE10 WebApp provides comprehensive web application support for Jakarta EE 10 within the Eclipse Jetty web server framework. It enables deployment, configuration, and management of Java web applications with full Jakarta EE 10 compliance, offering features like web.xml parsing, annotation scanning, fragment processing, security configuration, JNDI integration, and class loading isolation.
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<version>12.0.21</version>
</dependency>import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.ee10.webapp.WebAppClassLoader;
import org.eclipse.jetty.ee10.webapp.Configuration;
import org.eclipse.jetty.ee10.webapp.Configurations;import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.server.Server;
// Create a basic web application context
WebAppContext webapp = new WebAppContext();
webapp.setWar("/path/to/webapp.war");
webapp.setContextPath("/myapp");
// Add to server
Server server = new Server(8080);
server.setHandler(webapp);
server.start();The Jetty EE10 WebApp module is built around several key architectural components:
Core functionality for creating, configuring, and managing web application contexts.
public class WebAppContext extends ServletContextHandler
implements WebAppClassLoader.Context, Deployable {
public WebAppContext();
public WebAppContext(String webApp, String contextPath);
public WebAppContext(Resource webApp, String contextPath);
public WebAppContext(SessionHandler sessionHandler,
SecurityHandler securityHandler, ServletHandler servletHandler,
ErrorHandler errorHandler);
public WebAppContext(String contextPath, SessionHandler sessionHandler,
SecurityHandler securityHandler, ServletHandler servletHandler,
ErrorHandler errorHandler, int options);
public static WebAppContext getCurrentWebAppContext();
public void setWar(String war);
public boolean configure() throws Exception;
public void preConfigure() throws Exception;
public void postConfigure() throws Exception;
}Specialized classloading with visibility controls and performance optimizations.
public class WebAppClassLoader extends URLClassLoader
implements ClassVisibilityChecker {
public WebAppClassLoader(Context context);
public WebAppClassLoader(ClassLoader parent, Context context);
public void addClassPath(Resource resource);
public void addClassPath(String classPathList) throws IOException;
public void addJars(Resource libs);
public boolean isProtectedClass(Class<?> clazz);
public boolean isHiddenClass(Class<?> clazz);
public static <T> T runWithServerClassAccess(
PrivilegedExceptionAction<T> action) throws Exception;
}
public class CachingWebAppClassLoader extends WebAppClassLoader {
public CachingWebAppClassLoader(Context context) throws IOException;
public CachingWebAppClassLoader(ClassLoader parent, Context context)
throws IOException;
public void clearCache();
}Pluggable configuration system for handling different aspects of web application setup.
public interface Configuration {
void preConfigure(WebAppContext context) throws Exception;
void configure(WebAppContext context) throws Exception;
void postConfigure(WebAppContext context) throws Exception;
boolean isEnabledByDefault();
}
public class Configurations extends AbstractList<Configuration> {
public Configurations();
public static List<Configuration> getKnown();
public void sort();
public boolean configure(WebAppContext webapp) throws Exception;
}Comprehensive metadata handling for web.xml, fragments, and annotations.
public class MetaData {
public void setWebDescriptor(WebDescriptor descriptor) throws Exception;
public void addFragmentDescriptor(Resource jarResource,
FragmentDescriptor descriptor) throws Exception;
public void resolve(WebAppContext context) throws Exception;
public boolean isMetaDataComplete();
}
public abstract class Descriptor {
public Descriptor(Resource resource);
public void parse(XmlParser parser) throws Exception;
public Resource getResource();
}// Context interface for classloader operations
public interface WebAppClassLoader.Context {
Resource newResource(String urlOrPath) throws IOException;
PermissionCollection getPermissions();
boolean isParentLoaderPriority();
List<Resource> getExtraClasspath();
}
// Metadata origin tracking
public enum Origin {
NotSet, WebXml, WebDefaults, WebOverride,
WebFragment, Annotation, API
}
// Fragment ordering interface
public interface Ordering {
List<Resource> order(List<Resource> fragments);
}public static final String WEB_DEFAULTS_XML =
"org/eclipse/jetty/ee10/webapp/webdefault-ee10.xml";
// MetaInfConfiguration constants
public static final String USE_CONTAINER_METAINF_CACHE =
"org.eclipse.jetty.metainf.useCache";
public static final String CONTAINER_JAR_PATTERN =
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern";
public static final String WEBINF_JAR_PATTERN =
"org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern";The module uses Java's ServiceLoader mechanism for configuration discovery:
// Automatic discovery of Configuration implementations
ServiceLoader<Configuration> loader = ServiceLoader.load(Configuration.class);
for (Configuration config : loader) {
// Use discovered configurations
}Built-in configuration providers include: