perwendel/spark · error · ServletException

There are no Spark applications configured in the filter.

Error message

There are no Spark applications configured in the filter.

What it means

SparkFilter.init resolves the Spark application(s) to run from filter init parameters (application class names implementing SparkApplication). If no applications are configured, getApplications throws ServletException because the filter has nothing to dispatch to and cannot start.

Solutions

  1. Add a filter init parameter naming your SparkApplication implementation class in web.xml (or via the programmatic registration API).
  2. Implement spark.servlet.SparkApplication in your project and reference its fully qualified name.
  3. Verify the WAR actually contains the configured web.xml with the init-param (check for whitespace-only values too).

Example fix

<!-- before: no init-param -->
<filter>
  <filter-name>SparkFilter</filter-name>
  <filter-class>spark.servlet.SparkFilter</filter-class>
</filter>

<!-- after -->
<filter>
  <filter-name>SparkFilter</filter-name>
  <filter-class>spark.servlet.SparkFilter</filter-class>
  <init-param>
    <param-name>applicationClass</param-name>
    <param-value>com.example.MyApp</param-value>
  </init-param>
</filter>
Defensive patterns

Strategy: validation

Validate before calling

String appClass = filterConfig.getInitParameter("applicationClass");
if (appClass == null || appClass.trim().isEmpty()) {
    throw new IllegalStateException("SparkFilter requires an applicationClass init-param");
}

Try / catch

try {
    filterChain.doFilter(request, response);
} catch (ServletException e) {
    if (e.getMessage().contains("no Spark applications configured")) {
        log.error("Add the applicationClass init-param to the SparkFilter declaration");
    }
}

Prevention

When it happens

Trigger: Deploying SparkFilter in a servlet container without setting the filter init parameter that names the SparkApplication class(es) (e.g. an empty or missing 'applicationClass' init-param in web.xml).

Common situations: Forgetting the init-param when migrating from embedded Spark to WAR deployment; deploying a WAR where the web.xml was not packaged; a whitespace-only init-param value; renaming the application class without updating web.xml.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of perwendel/spark@1973e402f5 (2026-09-10). Data as JSON: /api/errors/25078000ef62302a. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/spark/servlet/SparkFilter.java:135

     * @return the spark applications containing the configuration.
     * @throws ServletException if anything went wrong.
     */
    protected SparkApplication[] getApplications(final FilterConfig filterConfig) throws ServletException {

        String applications = filterConfig.getInitParameter(APPLICATION_CLASS_PARAM);
        SparkApplication[] solvedApplications = null;

        if (StringUtils.isNotBlank(applications)) {
            final String[] sparkApplications = applications.split(",");

            if (sparkApplications != null && sparkApplications.length > 0) {
                solvedApplications = new SparkApplication[sparkApplications.length];

                for (int index = 0; index < sparkApplications.length; index++) {
                    solvedApplications[index] = getApplication(sparkApplications[index].trim());
                }
            } else {
                throw new ServletException("There are no Spark applications configured in the filter.");
            }
        }

        return solvedApplications;
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws
                                                                                              IOException,
                                                                                              ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request; // NOSONAR
        HttpServletResponse httpResponse = (HttpServletResponse) response; // NOSONAR

        final String relativePath = FilterTools.getRelativePath(httpRequest, filterPath);

        if (LOG.isDebugEnabled()) {
            LOG.debug(relativePath);
        }

View on GitHub (pinned to 1973e402f5)