{"record":{"id":"67ffe166ff9498d7","repo":"quarkusio/quarkus","slug":"runtimeexception-e-67ffe1","errorCode":null,"errorMessage":"RuntimeException(e)","messagePattern":"RuntimeException\\(e\\)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/google-cloud-functions/runtime/src/main/java/io/quarkus/gcp/functions/QuarkusBackgroundFunction.java","lineNumber":74,"sourceCode":"\n    static void setDelegates(String selectedDelegate, String selectedRawDelegate) {\n        delegateClassLoader = Thread.currentThread().getContextClassLoader();\n        if (selectedDelegate != null) {\n            try {\n                Class<?> clazz = Class.forName(selectedDelegate, false, delegateClassLoader);\n                for (Method method : clazz.getDeclaredMethods()) {\n                    if (method.getName().equals(\"accept\")) {\n                        // the first parameter of the accept method is the event, we need to register it's type to\n                        // be able to deserialize to it to mimic what a BackgroundFunction does\n                        Class<?>[] parameterTypes = method.getParameterTypes();\n                        if (parameterTypes[0] != Object.class) {// FIXME we have two accept methods !!!\n                            parameterType = parameterTypes[0];\n                        }\n                    }\n                }\n                delegate = (BackgroundFunction) Arc.container().instance(clazz).get();\n            } catch (ClassNotFoundException e) {\n                throw new RuntimeException(e);\n            }\n        }\n\n        if (selectedRawDelegate != null) {\n            try {\n                Class<?> clazz = Class.forName(selectedRawDelegate, false, delegateClassLoader);\n                rawDelegate = (RawBackgroundFunction) Arc.container().instance(clazz).get();\n            } catch (ClassNotFoundException e) {\n                throw new RuntimeException(e);\n            }\n        }\n    }\n\n    public static void clearState() {\n        delegate = null;\n        parameterType = null;\n        rawDelegate = null;\n        delegateClassLoader = null;","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/google-cloud-functions/runtime/src/main/java/io/quarkus/gcp/functions/QuarkusBackgroundFunction.java#L56-L92","documentation":"QuarkusBackgroundFunction.setDelegates loads the configured BackgroundFunction delegate class by name and obtains it from CDI (Arc). If Class.forName fails to find the configured class, the ClassNotFoundException is wrapped in a RuntimeException. It means the configured delegate class is not on the runtime classpath.","triggerScenarios":"The class name configured (via quarkus.google-cloud-functions.function / generated delegate selection) for the BackgroundFunction does not exist in delegateClassLoader at runtime.","commonSituations":"Renamed or deleted function class after build; wrong quarkus.google-cloud-functions.function value; class in a module not visible to the delegate classloader (classloading mismatch).","solutions":["Check the wrapped ClassNotFoundException cause for the missing class name.","Ensure the class name in quarkus.google-cloud-functions.function matches an existing function class (fully qualified name).","Rebuild the application after adding/renaming function classes.","Verify the function class is in the application archive, not an unindexed dependency."],"exampleFix":"// before (application.properties)\nquarkus.google-cloud-functions.function=com.example.OldFunction\n// after\nquarkus.google-cloud-functions.function=com.example.MyFunction","handlingStrategy":"try-catch","validationCode":"try { Class.forName(\"com.example.MyFunction\"); } catch (ClassNotFoundException e) {\n  throw new IllegalStateException(\"Configured GCF function class missing: com.example.MyFunction\");\n}","typeGuard":null,"tryCatchPattern":"try { startFunction(); }\ncatch (RuntimeException e) {\n  if (e.getCause() instanceof ClassNotFoundException cnfe) {\n    log.error(\"Function class not found: \" + cnfe.getMessage());\n  }\n}","preventionTips":["Use fully qualified class names in quarkus.google-cloud-functions.function","Rebuild after renaming function classes","Keep function classes in the application archive, not optional deps","Add a startup test that triggers delegate loading"],"tags":["google-cloud-functions","classpath","reflection"],"backgroundTag":"classnotfound-runtime","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}