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.00
# Jetty EE10 WebApp
1
2
Jetty 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.
3
4
## Package Information
5
6
- **Package Name**: org.eclipse.jetty.ee10:jetty-ee10-webapp
7
- **Package Type**: Maven
8
- **Language**: Java
9
- **Version**: 12.0.21
10
- **License**: EPL-2.0 OR Apache-2.0
11
- **Installation**: Add Maven dependency:
12
13
```xml
14
<dependency>
15
<groupId>org.eclipse.jetty.ee10</groupId>
16
<artifactId>jetty-ee10-webapp</artifactId>
17
<version>12.0.21</version>
18
</dependency>
19
```
20
21
## Core Imports
22
23
```java
24
import org.eclipse.jetty.ee10.webapp.WebAppContext;
25
import org.eclipse.jetty.ee10.webapp.WebAppClassLoader;
26
import org.eclipse.jetty.ee10.webapp.Configuration;
27
import org.eclipse.jetty.ee10.webapp.Configurations;
28
```
29
30
## Basic Usage
31
32
```java
33
import org.eclipse.jetty.ee10.webapp.WebAppContext;
34
import org.eclipse.jetty.server.Server;
35
36
// Create a basic web application context
37
WebAppContext webapp = new WebAppContext();
38
webapp.setWar("/path/to/webapp.war");
39
webapp.setContextPath("/myapp");
40
41
// Add to server
42
Server server = new Server(8080);
43
server.setHandler(webapp);
44
server.start();
45
```
46
47
## Architecture
48
49
The Jetty EE10 WebApp module is built around several key architectural components:
50
51
- **WebAppContext**: Main entry point that orchestrates web application deployment
52
- **Configuration System**: Pluggable configurations handle specific aspects of the servlet specification
53
- **ClassLoader System**: Provides isolation and customizable class visibility
54
- **Metadata Processing**: Handles web.xml, annotations, and fragment processing
55
- **Service Provider Pattern**: Enables modular configuration discovery
56
57
## Capabilities
58
59
### Web Application Context Management
60
61
Core functionality for creating, configuring, and managing web application contexts.
62
63
```java { .api }
64
public class WebAppContext extends ServletContextHandler
65
implements WebAppClassLoader.Context, Deployable {
66
67
public WebAppContext();
68
public WebAppContext(String webApp, String contextPath);
69
public WebAppContext(Resource webApp, String contextPath);
70
public WebAppContext(SessionHandler sessionHandler,
71
SecurityHandler securityHandler, ServletHandler servletHandler,
72
ErrorHandler errorHandler);
73
public WebAppContext(String contextPath, SessionHandler sessionHandler,
74
SecurityHandler securityHandler, ServletHandler servletHandler,
75
ErrorHandler errorHandler, int options);
76
public static WebAppContext getCurrentWebAppContext();
77
public void setWar(String war);
78
public boolean configure() throws Exception;
79
public void preConfigure() throws Exception;
80
public void postConfigure() throws Exception;
81
}
82
```
83
84
[Web Application Context](./webapp-context.md)
85
86
### ClassLoader Management
87
88
Specialized classloading with visibility controls and performance optimizations.
89
90
```java { .api }
91
public class WebAppClassLoader extends URLClassLoader
92
implements ClassVisibilityChecker {
93
94
public WebAppClassLoader(Context context);
95
public WebAppClassLoader(ClassLoader parent, Context context);
96
public void addClassPath(Resource resource);
97
public void addClassPath(String classPathList) throws IOException;
98
public void addJars(Resource libs);
99
public boolean isProtectedClass(Class<?> clazz);
100
public boolean isHiddenClass(Class<?> clazz);
101
public static <T> T runWithServerClassAccess(
102
PrivilegedExceptionAction<T> action) throws Exception;
103
}
104
105
public class CachingWebAppClassLoader extends WebAppClassLoader {
106
public CachingWebAppClassLoader(Context context) throws IOException;
107
public CachingWebAppClassLoader(ClassLoader parent, Context context)
108
throws IOException;
109
public void clearCache();
110
}
111
```
112
113
[ClassLoader Management](./classloader.md)
114
115
### Configuration System
116
117
Pluggable configuration system for handling different aspects of web application setup.
118
119
```java { .api }
120
public interface Configuration {
121
void preConfigure(WebAppContext context) throws Exception;
122
void configure(WebAppContext context) throws Exception;
123
void postConfigure(WebAppContext context) throws Exception;
124
boolean isEnabledByDefault();
125
}
126
127
public class Configurations extends AbstractList<Configuration> {
128
public Configurations();
129
public static List<Configuration> getKnown();
130
public void sort();
131
public boolean configure(WebAppContext webapp) throws Exception;
132
}
133
```
134
135
[Configuration System](./configuration.md)
136
137
### Metadata and Descriptor Processing
138
139
Comprehensive metadata handling for web.xml, fragments, and annotations.
140
141
```java { .api }
142
public class MetaData {
143
public void setWebDescriptor(WebDescriptor descriptor) throws Exception;
144
public void addFragmentDescriptor(Resource jarResource,
145
FragmentDescriptor descriptor) throws Exception;
146
public void resolve(WebAppContext context) throws Exception;
147
public boolean isMetaDataComplete();
148
}
149
150
public abstract class Descriptor {
151
public Descriptor(Resource resource);
152
public void parse(XmlParser parser) throws Exception;
153
public Resource getResource();
154
}
155
```
156
157
[Metadata Processing](./metadata.md)
158
159
## Core Types
160
161
```java { .api }
162
// Context interface for classloader operations
163
public interface WebAppClassLoader.Context {
164
Resource newResource(String urlOrPath) throws IOException;
165
PermissionCollection getPermissions();
166
boolean isParentLoaderPriority();
167
List<Resource> getExtraClasspath();
168
}
169
170
// Metadata origin tracking
171
public enum Origin {
172
NotSet, WebXml, WebDefaults, WebOverride,
173
WebFragment, Annotation, API
174
}
175
176
// Fragment ordering interface
177
public interface Ordering {
178
List<Resource> order(List<Resource> fragments);
179
}
180
```
181
182
## Key Constants
183
184
```java { .api }
185
public static final String WEB_DEFAULTS_XML =
186
"org/eclipse/jetty/ee10/webapp/webdefault-ee10.xml";
187
188
// MetaInfConfiguration constants
189
public static final String USE_CONTAINER_METAINF_CACHE =
190
"org.eclipse.jetty.metainf.useCache";
191
public static final String CONTAINER_JAR_PATTERN =
192
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern";
193
public static final String WEBINF_JAR_PATTERN =
194
"org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern";
195
```
196
197
## Service Provider Integration
198
199
The module uses Java's ServiceLoader mechanism for configuration discovery:
200
201
```java
202
// Automatic discovery of Configuration implementations
203
ServiceLoader<Configuration> loader = ServiceLoader.load(Configuration.class);
204
for (Configuration config : loader) {
205
// Use discovered configurations
206
}
207
```
208
209
Built-in configuration providers include:
210
- WebXmlConfiguration - Web.xml processing
211
- MetaInfConfiguration - META-INF scanning
212
- FragmentConfiguration - Web fragment processing
213
- JettyWebXmlConfiguration - Jetty-specific configuration
214
- JndiConfiguration - JNDI support
215
- JaasConfiguration - JAAS authentication support
216
- JaspiConfiguration - Jakarta Authentication (JASPI) support
217
- JmxConfiguration - JMX management support
218
- JspConfiguration - JSP support
219
- ServletsConfiguration - Servlet annotation processing
220
- WebAppConfiguration - Base web application configuration
221
- WebInfConfiguration - WEB-INF directory processing