{"record":{"id":"25078000ef62302a","repo":"perwendel/spark","slug":"there-are-no-spark-applications-configured-in-the","errorCode":null,"errorMessage":"There are no Spark applications configured in the filter.","messagePattern":"There are no Spark applications configured in the filter\\.","errorType":"exception","errorClass":"ServletException","httpStatus":null,"severity":"error","filePath":"src/main/java/spark/servlet/SparkFilter.java","lineNumber":135,"sourceCode":"     * @return the spark applications containing the configuration.\n     * @throws ServletException if anything went wrong.\n     */\n    protected SparkApplication[] getApplications(final FilterConfig filterConfig) throws ServletException {\n\n        String applications = filterConfig.getInitParameter(APPLICATION_CLASS_PARAM);\n        SparkApplication[] solvedApplications = null;\n\n        if (StringUtils.isNotBlank(applications)) {\n            final String[] sparkApplications = applications.split(\",\");\n\n            if (sparkApplications != null && sparkApplications.length > 0) {\n                solvedApplications = new SparkApplication[sparkApplications.length];\n\n                for (int index = 0; index < sparkApplications.length; index++) {\n                    solvedApplications[index] = getApplication(sparkApplications[index].trim());\n                }\n            } else {\n                throw new ServletException(\"There are no Spark applications configured in the filter.\");\n            }\n        }\n\n        return solvedApplications;\n    }\n\n    @Override\n    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws\n                                                                                              IOException,\n                                                                                              ServletException {\n        HttpServletRequest httpRequest = (HttpServletRequest) request; // NOSONAR\n        HttpServletResponse httpResponse = (HttpServletResponse) response; // NOSONAR\n\n        final String relativePath = FilterTools.getRelativePath(httpRequest, filterPath);\n\n        if (LOG.isDebugEnabled()) {\n            LOG.debug(relativePath);\n        }","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/perwendel/spark/blob/1973e402f5d4c1442ad34a1d38ed0758079f7773/src/main/java/spark/servlet/SparkFilter.java#L117-L153","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Add a filter init parameter naming your SparkApplication implementation class in web.xml (or via the programmatic registration API).","Implement spark.servlet.SparkApplication in your project and reference its fully qualified name.","Verify the WAR actually contains the configured web.xml with the init-param (check for whitespace-only values too)."],"exampleFix":"<!-- before: no init-param -->\n<filter>\n  <filter-name>SparkFilter</filter-name>\n  <filter-class>spark.servlet.SparkFilter</filter-class>\n</filter>\n\n<!-- after -->\n<filter>\n  <filter-name>SparkFilter</filter-name>\n  <filter-class>spark.servlet.SparkFilter</filter-class>\n  <init-param>\n    <param-name>applicationClass</param-name>\n    <param-value>com.example.MyApp</param-value>\n  </init-param>\n</filter>","handlingStrategy":"validation","validationCode":"String appClass = filterConfig.getInitParameter(\"applicationClass\");\nif (appClass == null || appClass.trim().isEmpty()) {\n    throw new IllegalStateException(\"SparkFilter requires an applicationClass init-param\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    filterChain.doFilter(request, response);\n} catch (ServletException e) {\n    if (e.getMessage().contains(\"no Spark applications configured\")) {\n        log.error(\"Add the applicationClass init-param to the SparkFilter declaration\");\n    }\n}","preventionTips":["Always define the applicationClass init-param when declaring SparkFilter.","Verify the packaged WAR's web.xml in CI (unzip and inspect).","Trim the value — whitespace-only values count as unconfigured."],"tags":["servlet","configuration","web-xml","startup","spark"],"backgroundTag":"missing-required-config-field","analyzedSha":"1973e402f5d4c1442ad34a1d38ed0758079f7773","analyzedAt":"2026-09-10T14:38:22.866Z","contentChangedAt":"2026-09-10T14:38:22.866Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}