Jersey core server implementation for building RESTful Web Services with JAX-RS.
—
Server configuration constants for customizing Jersey server behavior including provider scanning, feature control, validation settings, performance tuning options, and advanced server configurations.
Central repository of all Jersey server configuration property constants providing comprehensive control over server behavior.
/**
* Server configuration property constants for customizing Jersey server behavior.
* Contains 41 public static final String constants for various configuration options.
*/
public final class ServerProperties {
// Private constructor - utility class
private ServerProperties();
}Properties for controlling provider scanning, registration, and discovery mechanisms.
/**
* Package names for automatic provider and resource scanning.
* Value type: String (semicolon-separated package names)
* Default: null (no automatic scanning)
*/
public static final String PROVIDER_PACKAGES = "jersey.config.server.provider.packages";
/**
* Enable recursive scanning of provider packages.
* Value type: Boolean
* Default: true
*/
public static final String PROVIDER_SCANNING_RECURSIVE = "jersey.config.server.provider.scanning.recursive";
/**
* Provider classpath scanning configuration.
* Value type: String (classpath locations)
* Default: null
*/
public static final String PROVIDER_CLASSPATH = "jersey.config.server.provider.classpath";
/**
* Explicit provider class names for registration.
* Value type: String (semicolon-separated class names)
* Default: null
*/
public static final String PROVIDER_CLASSNAMES = "jersey.config.server.provider.classnames";
/**
* Disable META-INF/services lookup for provider discovery.
* Value type: Boolean
* Default: false
*/
public static final String METAINF_SERVICES_LOOKUP_DISABLE = "jersey.config.server.provider.scanning.metainf.disable";Usage Examples:
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
ResourceConfig config = new ResourceConfig();
// Configure package scanning
config.property(ServerProperties.PROVIDER_PACKAGES, "com.example.providers;com.example.resources")
.property(ServerProperties.PROVIDER_SCANNING_RECURSIVE, true);
// Explicit provider registration
config.property(ServerProperties.PROVIDER_CLASSNAMES,
"com.example.CustomProvider;com.example.AnotherProvider");
// Disable META-INF services lookup
config.property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
// Alternative: Use packages() method (recommended)
config.packages("com.example.providers", "com.example.resources");Properties for enabling or disabling specific Jersey features and functionalities.
/**
* Disable automatic feature discovery.
* Value type: Boolean
* Default: false
*/
public static final String FEATURE_AUTO_DISCOVERY_DISABLE = "jersey.config.server.disableAutoDiscovery";
/**
* Disable WADL feature completely.
* Value type: Boolean
* Default: false
*/
public static final String WADL_FEATURE_DISABLE = "jersey.config.server.wadl.disableWadl";
/**
* Disable JSON-B (JSON Binding) feature.
* Value type: Boolean
* Default: false
*/
public static final String JSON_BINDING_FEATURE_DISABLE = "jersey.config.server.jsonBinding.disable";
/**
* Disable JSON-P (JSON Processing) feature.
* Value type: Boolean
* Default: false
*/
public static final String JSON_PROCESSING_FEATURE_DISABLE = "jersey.config.server.jsonProcessing.disable";
/**
* Disable MOXy JSON feature.
* Value type: Boolean
* Default: false
*/
public static final String MOXY_JSON_FEATURE_DISABLE = "jersey.config.server.moxy.json.disable";
/**
* Disable Bean Validation feature.
* Value type: Boolean
* Default: false
*/
public static final String BV_FEATURE_DISABLE = "jersey.config.beanValidation.disable.server";Usage Examples:
import org.glassfish.jersey.server.ServerProperties;
// Disable automatic feature discovery for better control
config.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
// Disable WADL generation for production
config.property(ServerProperties.WADL_FEATURE_DISABLE, true);
// Disable JSON features if not needed
config.property(ServerProperties.JSON_BINDING_FEATURE_DISABLE, true)
.property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, true)
.property(ServerProperties.MOXY_JSON_FEATURE_DISABLE, true);
// Enable Bean Validation (default is enabled)
config.property(ServerProperties.BV_FEATURE_DISABLE, false);
// Typical production configuration
ResourceConfig productionConfig = new ResourceConfig()
.packages("com.example.api")
.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
.property(ServerProperties.WADL_FEATURE_DISABLE, true)
.property(ServerProperties.BV_FEATURE_DISABLE, false);Properties for controlling Bean Validation (JSR-303/JSR-380) behavior and error handling.
/**
* Disable validation on executable override check.
* Value type: Boolean
* Default: false
*/
public static final String BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK =
"jersey.config.beanValidation.disable.validateOnExecutableCheck.override";
/**
* Send validation errors in HTTP response instead of throwing exceptions.
* Value type: Boolean
* Default: true
*/
public static final String BV_SEND_ERROR_IN_RESPONSE = "jersey.config.beanValidation.enableOutputValidationErrorEntity";
/**
* WADL generator configuration for Bean Validation integration.
* Value type: String (generator class name)
* Default: null
*/
public static final String WADL_GENERATOR_CONFIG = "jersey.config.server.wadl.generatorConfig";Usage Examples:
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Min;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
@Path("/validated")
public class ValidatedResource {
@GET
public String getValidatedData(@QueryParam("count") @Min(1) int count,
@QueryParam("name") @NotNull String name) {
return "Count: " + count + ", Name: " + name;
}
}
// Configure validation behavior
ResourceConfig config = new ResourceConfig()
.register(ValidatedResource.class)
.property(ServerProperties.BV_FEATURE_DISABLE, false)
.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true)
.property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, false);
// Validation errors will be returned as HTTP 400 with details
// GET /validated?count=0&name= will return validation error responseProperties for controlling media type mappings and content negotiation behavior.
/**
* Media type mappings for file extensions.
* Value type: Map<String, MediaType> or String (comma-separated mappings)
* Default: null
* Format: "html:text/html,xml:application/xml,json:application/json"
*/
public static final String MEDIA_TYPE_MAPPINGS = "jersey.config.server.mediaTypeMappings";
/**
* Language mappings for content negotiation.
* Value type: Map<String, String> or String (comma-separated mappings)
* Default: null
* Format: "en:en-US,fr:fr-FR,de:de-DE"
*/
public static final String LANGUAGE_MAPPINGS = "jersey.config.server.languageMappings";
/**
* HTTP method override support (via header or query parameter).
* Value type: String (header names or query parameter names)
* Default: null
*/
public static final String HTTP_METHOD_OVERRIDE = "jersey.config.server.httpMethodOverride";Usage Examples:
import jakarta.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
// Configure media type mappings
Map<String, MediaType> mediaTypeMappings = new HashMap<>();
mediaTypeMappings.put("json", MediaType.APPLICATION_JSON_TYPE);
mediaTypeMappings.put("xml", MediaType.APPLICATION_XML_TYPE);
mediaTypeMappings.put("html", MediaType.TEXT_HTML_TYPE);
config.property(ServerProperties.MEDIA_TYPE_MAPPINGS, mediaTypeMappings);
// Or using string format
config.property(ServerProperties.MEDIA_TYPE_MAPPINGS,
"json:application/json,xml:application/xml,html:text/html");
// Configure language mappings
config.property(ServerProperties.LANGUAGE_MAPPINGS, "en:en-US,fr:fr-FR,es:es-ES");
// Enable HTTP method override via header
config.property(ServerProperties.HTTP_METHOD_OVERRIDE, "X-HTTP-Method-Override");
// Now requests can use:
// GET /api/users.json -> Accept: application/json
// GET /api/users.xml -> Accept: application/xml
// POST with X-HTTP-Method-Override: PUT -> treated as PUT requestProperties for performance tuning, buffering, and advanced server behavior configuration.
/**
* Outbound content length buffer size.
* Value type: Integer (buffer size in bytes)
* Default: 8192
*/
public static final String OUTBOUND_CONTENT_LENGTH_BUFFER = "jersey.config.server.contentLength.buffer";
/**
* Enable reduction of consecutive slashes in context path.
* Value type: Boolean
* Default: false
*/
public static final String REDUCE_CONTEXT_PATH_SLASHES_ENABLED = "jersey.config.server.reduceContextPathSlashesEnabled";
/**
* Disable resource validation during application initialization.
* Value type: Boolean
* Default: false
*/
public static final String RESOURCE_VALIDATION_DISABLE = "jersey.config.server.resource.validation.disable";
/**
* Ignore resource validation issues during initialization.
* Value type: Boolean
* Default: false
*/
public static final String RESOURCE_VALIDATION_IGNORE_ERRORS = "jersey.config.server.resource.validation.ignoreErrors";
/**
* Disable automatic response buffering.
* Value type: Boolean
* Default: false
*/
public static final String RESPONSE_BUFFERING_AUTO = "jersey.config.server.response.buffering.auto";
/**
* Monitor application statistics and events.
* Value type: Boolean
* Default: false
*/
public static final String MONITORING_STATISTICS_ENABLED = "jersey.config.server.monitoring.statistics.enabled";
/**
* Monitor application MBeans via JMX.
* Value type: Boolean
* Default: false
*/
public static final String MONITORING_STATISTICS_MBEANS_ENABLED = "jersey.config.server.monitoring.statistics.mbeans.enabled";
/**
* Request tracing configuration.
* Value type: String ("OFF", "ON_DEMAND", "ALL")
* Default: "OFF"
*/
public static final String TRACING = "jersey.config.server.tracing";
/**
* Request tracing logger name.
* Value type: String
* Default: "org.glassfish.jersey.tracing"
*/
public static final String TRACING_LOGGER = "jersey.config.server.tracing.logger";
/**
* Tracing response headers threshold.
* Value type: Integer
* Default: Integer.MAX_VALUE
*/
public static final String TRACING_THRESHOLD = "jersey.config.server.tracing.threshold";Usage Examples:
// Performance tuning configuration
ResourceConfig performanceConfig = new ResourceConfig()
.packages("com.example.api")
// Increase content length buffer for large responses
.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 16384)
// Enable context path slash normalization
.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true)
// Enable automatic response buffering
.property(ServerProperties.RESPONSE_BUFFERING_AUTO, true);
// Monitoring configuration
ResourceConfig monitoringConfig = new ResourceConfig()
.packages("com.example.api")
// Enable statistics collection
.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true)
// Enable JMX MBeans
.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true)
// Enable request tracing for debugging
.property(ServerProperties.TRACING, "ON_DEMAND")
.property(ServerProperties.TRACING_THRESHOLD, 100);
// Development configuration with validation disabled for faster startup
ResourceConfig devConfig = new ResourceConfig()
.packages("com.example.api")
.property(ServerProperties.RESOURCE_VALIDATION_DISABLE, true)
.property(ServerProperties.RESOURCE_VALIDATION_IGNORE_ERRORS, true)
.property(ServerProperties.TRACING, "ALL");
// Production configuration optimized for performance
ResourceConfig prodConfig = new ResourceConfig()
.packages("com.example.api")
.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
.property(ServerProperties.WADL_FEATURE_DISABLE, true)
.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 32768)
.property(ServerProperties.RESPONSE_BUFFERING_AUTO, true)
.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true)
.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true)
.property(ServerProperties.TRACING, "OFF");Properties for application-level settings and behavior control.
/**
* Application name for identification and monitoring.
* Value type: String
* Default: null (derived from Application class)
*/
public static final String APPLICATION_NAME = "jersey.config.server.application.name";
/**
* Disable automatic application class loading.
* Value type: Boolean
* Default: false
*/
public static final String APPLICATION_AUTO_DISCOVERY_DISABLE = "jersey.config.server.application.disableAutoDiscovery";
/**
* Sub-resource locator cache size.
* Value type: Integer
* Default: 64
*/
public static final String SUBRESOURCE_LOCATOR_DEFAULT_CACHE_SIZE = "jersey.config.server.subresource.cache.size";
/**
* Sub-resource locator cache age limit.
* Value type: Long (milliseconds)
* Default: Long.MAX_VALUE (no expiration)
*/
public static final String SUBRESOURCE_LOCATOR_CACHE_JERSEY_RESOURCE_ENABLED = "jersey.config.server.subresource.cache.jersey.resource.enabled";Usage Examples:
// Application identification and caching configuration
ResourceConfig appConfig = new ResourceConfig()
.packages("com.example.api")
// Set application name for monitoring
.property(ServerProperties.APPLICATION_NAME, "My REST API v1.0")
// Optimize sub-resource locator caching
.property(ServerProperties.SUBRESOURCE_LOCATOR_DEFAULT_CACHE_SIZE, 128)
.property(ServerProperties.SUBRESOURCE_LOCATOR_CACHE_JERSEY_RESOURCE_ENABLED, true);
// Complete production-ready configuration example
ResourceConfig completeConfig = new ResourceConfig()
// Resource and provider packages
.packages("com.example.api.resources", "com.example.api.providers")
// Application settings
.property(ServerProperties.APPLICATION_NAME, "Production API v2.1")
// Feature control
.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
.property(ServerProperties.WADL_FEATURE_DISABLE, true)
.property(ServerProperties.BV_FEATURE_DISABLE, false)
// Performance settings
.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 16384)
.property(ServerProperties.RESPONSE_BUFFERING_AUTO, true)
.property(ServerProperties.REDUCE_CONTEXT_PATH_SLASHES_ENABLED, true)
// Monitoring
.property(ServerProperties.MONITORING_STATISTICS_ENABLED, true)
.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true)
// Bean Validation
.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true)
// Tracing (disabled for production)
.property(ServerProperties.TRACING, "OFF")
// Caching
.property(ServerProperties.SUBRESOURCE_LOCATOR_DEFAULT_CACHE_SIZE, 256);Install with Tessl CLI
npx tessl i tessl/maven-org-glassfish-jersey-core--jersey-server