{"record":{"id":"a14ba63159ffdd73","repo":"apache/hadoop","slug":"socket-factory-class-not-found-cnfe","errorCode":null,"errorMessage":"Socket Factory class not found: ${cnfe}","messagePattern":"Socket Factory class not found: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java","lineNumber":149,"sourceCode":"  /**\n   * Get the socket factory corresponding to the given proxy URI. If the\n   * given proxy URI corresponds to an absence of configuration parameter,\n   * returns null. If the URI is malformed raises an exception.\n   *\n   * @param conf configuration.\n   * @param propValue the property which is the class name of the\n   *        SocketFactory to instantiate; assumed non null and non empty.\n   * @return a socket factory as defined in the property value.\n   */\n  public static SocketFactory getSocketFactoryFromProperty(\n      Configuration conf, String propValue) {\n\n    try {\n      Class<?> theClass = conf.getClassByName(propValue);\n      return (SocketFactory) ReflectionUtils.newInstance(theClass, conf);\n\n    } catch (ClassNotFoundException cnfe) {\n      throw new RuntimeException(\"Socket Factory class not found: \" + cnfe);\n    }\n  }\n\n  /**\n   * Util method to build socket addr from either.\n   *   {@literal <host>:<port>}\n   *   {@literal <fs>://<host>:<port>/<path>}\n   *\n   * @param target target.\n   * @return socket addr.\n   */\n  public static InetSocketAddress createSocketAddr(String target) {\n    return createSocketAddr(target, -1);\n  }\n\n  public static InetSocketAddress createSocketAddrUnresolved(String target) {\n    return createSocketAddr(target, -1, null, false, false);\n  }","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java#L131-L167","documentation":"RuntimeException('Socket Factory class not found: <cnfe>') from NetUtils.getSocketFactoryFromProperty when conf.getClassByName(propValue) raises ClassNotFoundException — the socket-factory class named by a configuration property is not loadable. It wraps the original ClassNotFoundException (whose message is embedded), so the details of the missing class survive. This runs on the RPC/client path, so a bad value typically fails at first connection setup.","triggerScenarios":"Setting 'hadoop.rpc.socket.factory.class.default' (or a per-protocol override like 'hadoop.rpc.socket.factory.class.ClientProtocol', or fs-level 'fs.<scheme>.socket.factory') to a class name that is misspelled, not on the classpath, or whose jar is missing on the client node.","commonSituations":"Custom SocketFactory implementations referenced in core-site.xml but not bundled into the client/fat jar; version upgrades that moved or renamed the factory class; leftover experimental config pointing at a class removed from the build.","solutions":["Check the exact class name in the property for typos (fully qualified name required)","Verify the class is on the classpath of every node/client: 'hadoop classpath' plus 'java -cp ... <FQCN>' probe or Class.forName check","Ship the jar containing the factory (e.g., add to HADOOP_CLASSPATH or lib/ directory of the service)","If the custom factory is no longer needed, remove the property so the default StandardSocketFactory is used"],"exampleFix":"<!-- before -->\n<property><name>hadoop.rpc.socket.factory.class.default</name>\n  <value>com.myco.HdfsSocketFactory</value></property> <!-- jar missing -> RuntimeException at first connect -->\n\n<!-- after -->\n<property><name>hadoop.rpc.socket.factory.class.default</name>\n  <value>org.apache.hadoop.net.StandardSocketFactory</value></property>\n<!-- or ship com.myco.HdfsSocketFactory's jar to all nodes -->","handlingStrategy":"validation","validationCode":"String factoryClass = conf.get(\"hadoop.rpc.socket.factory.class.default\");\nif (factoryClass != null) {\n  Class.forName(factoryClass); // throws ClassNotFoundException early with a clear context\n}","typeGuard":null,"tryCatchPattern":"catch (RuntimeException e) { /* 'Socket Factory class not found: ...' */ report the missing FQCN and the property name; ship the jar or revert the property to StandardSocketFactory; }","preventionTips":["Config-lint every *-site.xml for class-valued properties with Class.forName at deploy time","Ship custom SocketFactory jars to every node's lib/ directory, not just the client","After upgrades, grep configs for FQCNs of removed/moved classes"],"tags":["rpc","socket-factory","classpath","configuration","hadoop-common"],"backgroundTag":"class-not-found-in-configuration","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}