{
  "id": "ros2/component-container-mismatch",
  "signature": "[component_container_isolated]: Failed to load component: Failed to find class with name 'my_pkg::MyComponent': No matching class found in library",
  "signature_zh": "[component_container_isolated]：加载组件失败：找不到名为'my_pkg::MyComponent'的类：库中无匹配类",
  "regex": "Failed to find class with name '.*?': No matching class found in library",
  "domain": "ros2",
  "category": "module_error",
  "subcategory": null,
  "root_cause": "The component class is either not registered with the RCLCPP_COMPONENTS_REGISTER_NODE macro, or the library was not built/linked correctly, so the container cannot instantiate it at runtime.",
  "root_cause_type": "generic",
  "root_cause_zh": "组件类未使用RCLCPP_COMPONENTS_REGISTER_NODE宏注册，或者库未正确构建/链接，导致容器在运行时无法实例化它。",
  "versions": [
    {
      "version": "ROS2 Humble",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Iron",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Jazzy",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding the component source file to a different package's CMakeLists.txt without proper registration",
      "why_fails": "The class must be registered in the same library where it is built, using the correct macro. Moving files without registration does not help.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Manually loading the library with 'dlopen' in the container to verify it exists",
      "why_fails": "The library may exist but the class registration may still be missing. This does not fix the registration issue.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the component source file includes the registration macro: 'RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent)' and that the CMakeLists.txt uses 'add_library' with 'ament_target_dependencies' and 'pluginlib_export_plugin_description_file' if needed.",
      "success_rate": 0.95,
      "how": "Ensure the component source file includes the registration macro: 'RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent)' and that the CMakeLists.txt uses 'add_library' with 'ament_target_dependencies' and 'pluginlib_export_plugin_description_file' if needed.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check the library exports: 'nm -C libmy_component.so | grep MyComponent' to see if the symbol is present. If not, rebuild with 'colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug' and check for missing dependencies.",
      "success_rate": 0.85,
      "how": "Check the library exports: 'nm -C libmy_component.so | grep MyComponent' to see if the symbol is present. If not, rebuild with 'colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug' and check for missing dependencies.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Verify the component's plugin description XML file (e.g., 'my_component_plugins.xml') is correctly formatted and referenced in 'package.xml' under <export>.",
      "success_rate": 0.9,
      "how": "Verify the component's plugin description XML file (e.g., 'my_component_plugins.xml') is correctly formatted and referenced in 'package.xml' under <export>.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保组件源文件包含注册宏：'RCLCPP_COMPONENTS_REGISTER_NODE(my_pkg::MyComponent)'，并且CMakeLists.txt使用'add_library'，必要时包含'ament_target_dependencies'和'pluginlib_export_plugin_description_file'。",
    "检查库导出：'nm -C libmy_component.so | grep MyComponent'以查看符号是否存在。如果不存在，使用'colcon build --cmake-args -DCMAKE_BUILD_TYPE=Debug'重新构建并检查缺失的依赖。",
    "验证组件的插件描述XML文件（如'my_component_plugins.xml'）格式正确，并在'package.xml'的<export>部分中引用。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Composition.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-06-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}