{"record":{"id":"016870ddbe929632","repo":"apache/hadoop","slug":"webapps-not-found-in-classpath","errorCode":null,"errorMessage":"webapps/{} not found in CLASSPATH","messagePattern":"webapps/(.+?) not found in CLASSPATH","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java","lineNumber":1361,"sourceCode":"   */\n  protected String getWebAppsPath(String appName) throws FileNotFoundException {\n    URL resourceUrl = null;\n    File webResourceDevLocation = new File(\"src/main/webapps\", appName);\n    if (webResourceDevLocation.exists()) {\n      LOG.info(\"Web server is in development mode. Resources \"\n          + \"will be read from the source tree.\");\n      try {\n        resourceUrl = webResourceDevLocation.getParentFile().toURI().toURL();\n      } catch (MalformedURLException e) {\n        throw new FileNotFoundException(\"Mailformed URL while finding the \"\n            + \"web resource dir:\" + e.getMessage());\n      }\n    } else {\n      resourceUrl =\n          getClass().getClassLoader().getResource(\"webapps/\" + appName);\n\n      if (resourceUrl == null) {\n        throw new FileNotFoundException(\"webapps/\" + appName +\n            \" not found in CLASSPATH\");\n      }\n    }\n    String urlString = resourceUrl.toString();\n    return urlString.substring(0, urlString.lastIndexOf('/'));\n  }\n\n  /**\n   * Get the port that the server is on\n   * @return the port\n   */\n  @Deprecated\n  public int getPort() {\n    return ((ServerConnector)webServer.getConnectors()[0]).getLocalPort();\n  }\n\n  /**\n   * Get the address that corresponds to a particular connector.","sourceCodeStart":1343,"sourceCodeEnd":1379,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java#L1343-L1379","documentation":"getWebAppsPath() falls back to ClassLoader.getResource(\"webapps/\" + appName) when the dev-mode directory is absent; a null result throws FileNotFoundException '<resource> not found in CLASSPATH'. It means no webapps/<appName> entry (directory or jar resource) is reachable from the classloader that loaded HttpServer2.","triggerScenarios":"Starting HttpServer2 with an appName whose webapps resources are not packaged (custom embedding with a made-up name); uber/shaded jars where the shade plugin dropped the webapps resource directory; a corrupted or trimmed hadoop-common jar in an unpacked distribution.","commonSituations":"Building fat jars for Hadoop-based services without resource inclusion; unit tests that construct HttpServer2 outside a full distribution; installing clusters with partially copied lib directories.","solutions":["Ensure webapps/<appName> exists as a classpath resource: ship it inside your jar or as a directory next to hadoop-common's webapps","Fix the appName passed to the builder (it must match the resource directory name)","For shade assemblies, configure resource inclusion so 'webapps/**' is kept"],"exampleFix":"<!-- maven-shade-plugin: before, webapps resources dropped -->\n<!-- after -->\n<plugin>\n  <groupId>org.apache.maven.plugins</groupId>\n  <artifactId>maven-shade-plugin</artifactId>\n  <configuration>\n    <filters>\n      <filter>\n        <artifact>*:*</artifact>\n        <excludes><exclude>META-INF/*.SF</exclude></excludes>\n      </filter>\n    </filters>\n  </configuration>\n</plugin>\n<!-- plus ensure hadoop-common jar (containing webapps/) stays on the classpath unshaded -->","handlingStrategy":"validation","validationCode":"if (Thread.currentThread().getContextClassLoader().getResource(\"webapps/\" + appName) == null\n    && !new File(\"src/main/webapps\", appName).exists()) {\n  throw new IllegalStateException(\"webapps/\" + appName + \" not on classpath; package it into the jar\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  server.start();\n} catch (FileNotFoundException e) {\n  // message names the missing resource: verify packaging/classpath for that app\n}","preventionTips":["Include webapps/** as resources in your build and verify the jar contents before shipping","In shade plugin config, keep hadoop-common's webapps resources or ship them alongside","Smoke-test HttpServer2 startup in CI with the exact packaged classpath"],"tags":["hadoop","http-server","classpath","packaging","resources"],"backgroundTag":"classpath-resource-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}