{"record":{"id":"1ba33008c22093cb","repo":"quarkusio/quarkus","slug":"unable-to-load-context-type-typeparam","errorCode":null,"errorMessage":"Unable to load context type: ${typeParam}","messagePattern":"Unable to load context type: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ResteasyReactiveContextResolverScanner.java","lineNumber":65,"sourceCode":"        Collection<ClassInfo> resolvers = index\n                .getAllKnownImplementors(ResteasyReactiveDotNames.CONTEXT_RESOLVER);\n        for (ClassInfo resolverClass : resolvers) {\n            ApplicationScanningResult.KeepProviderResult keepProviderResult = result\n                    .keepProvider(resolverClass);\n            if (keepProviderResult != ApplicationScanningResult.KeepProviderResult.DISCARD) {\n                List<Type> typeParameters = JandexUtil.resolveTypeParameters(resolverClass.name(),\n                        ResteasyReactiveDotNames.CONTEXT_RESOLVER,\n                        index);\n                DotName typeParam = typeParameters.get(0).name();\n                ResourceContextResolver mapper = new ResourceContextResolver();\n                mapper.setClassName(resolverClass.name().toString());\n                mapper.setMediaTypeStrings(getProducesMediaTypes(resolverClass));\n                try {\n                    Class contextType = Class.forName(typeParam.toString(), false,\n                            Thread.currentThread().getContextClassLoader());\n                    contextResolvers.addContextResolver(contextType, mapper);\n                } catch (ClassNotFoundException e) {\n                    throw new RuntimeException(\"Unable to load context type: \" + typeParam);\n                }\n            }\n        }\n        return contextResolvers;\n    }\n\n    private static List<String> getProducesMediaTypes(ClassInfo classInfo) {\n        AnnotationInstance produces = classInfo.declaredAnnotation(ResteasyReactiveDotNames.PRODUCES);\n        if (produces == null) {\n            return Collections.emptyList();\n        }\n        return Arrays.asList(produces.value().asStringArray());\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":80,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/scanning/ResteasyReactiveContextResolverScanner.java#L47-L80","documentation":"When scanning @ContextResolver classes, RESTEasy Reactive reads the ContextResolver's type parameter and attempts to load that context class with Class.forName at build time. If the class cannot be loaded from the thread context classloader, the scan fails with this RuntimeException.","triggerScenarios":"Implementing ContextResolver<T> where T resolves to a type that is not on the application classpath, or a raw/unresolvable parameterized type, so Class.forName(typeParam.toString()) throws ClassNotFoundException during scanning.","commonSituations":"A ContextResolver declared for a class from a dependency marked provided/optional and not packaged; typos in the generic type; use of a raw ContextResolver without a concrete type parameter; classloader differences in dev/test vs production.","solutions":["Add the missing context type's artifact to the application's dependencies so the class is loadable.","Make sure the resolver declares a concrete ContextResolver<MyContext> type parameter, not a raw type.","Check for typos in the generic type name and that the class is in the same module/deployment as the resolver.","Verify no packaging exclusions (e.g. Maven exclusions or native-mode removal) drop the class."],"exampleFix":"// before\npublic class MyResolver implements ContextResolver { ... } // raw type\n// after\npublic class MyResolver implements ContextResolver<MyContextClass> {\n    public MyContextClass getContext(Class<?> type) { ... }\n}","handlingStrategy":"validation","validationCode":"Class<?> ctxType;\ntry {\n    ctxType = Class.forName(typeParam.toString(), false,\n        Thread.currentThread().getContextClassLoader());\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"ContextResolver type \" + typeParam + \" not on classpath\", e);\n}","typeGuard":"boolean isResolvable(String className, ClassLoader cl) {\n    try { cl.loadClass(className); return true; } catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n    scanner.scanForContextResolvers(...);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Unable to load context type\")) {\n        log.error(\"Add the dependency containing the context type: \" + e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Always declare a concrete generic parameter on ContextResolver implementations.","Keep the context type's artifact in the same module or a compile/runtime-scope dependency.","Avoid optional/provided scope for classes referenced by resolvers.","Re-check resolver generics after dependency upgrades."],"tags":["quarkus","resteasy-reactive","jax-rs","classpath","contextresolver"],"backgroundTag":"classnotfound","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}