{"record":{"id":"b099cd3439eaffa2","repo":"quarkusio/quarkus","slug":"the-clazz-getsimplename-class-instanceclass","errorCode":null,"errorMessage":"The <clazz.getSimpleName()> class [<instanceClass>] could not be instantiated!","messagePattern":"The <clazz\\.getSimpleName\\(\\)> class \\[<instanceClass>\\] could not be instantiated!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java","lineNumber":705,"sourceCode":"\n                instanceClass = classLoaderService.classForName(settingStringValue);\n            } else {\n                try {\n                    instanceClass = (Class<? extends T>) Class.forName(settingStringValue);\n                } catch (ClassNotFoundException e) {\n                    throw new IllegalArgumentException(\"Can't load class: \" + settingStringValue, e);\n                }\n            }\n        } else {\n            throw new IllegalArgumentException(\n                    \"The provided \" + settingName + \" setting value [\" + settingValue + \"] is not supported!\");\n        }\n\n        if (instanceClass != null) {\n            try {\n                instance = instanceClass.getConstructor().newInstance();\n            } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {\n                throw new IllegalArgumentException(\n                        \"The \" + clazz.getSimpleName() + \" class [\" + instanceClass + \"] could not be instantiated!\",\n                        e);\n            }\n        }\n\n        return instance;\n    }\n\n}\n","sourceCodeStart":687,"sourceCodeEnd":715,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java#L687-L715","documentation":"After resolving the configured setting value to a Class, loadSettingInstance instantiates it via its no-arg constructor. If the class is abstract/an interface, lacks a public no-arg constructor, its constructor throws, or instantiation is otherwise illegal, the builder wraps the reflective exception in this IllegalArgumentException.","triggerScenarios":"Configuring a contributor/naming-strategy class that is abstract, an interface, has only constructor arguments, or whose no-arg constructor throws at static-init time — reached through settings like metadata_builder_contributor or naming strategy settings.","commonSituations":"Pointing a strategy setting at an interface; contributor requiring DI; constructor failing because Quarkus beans/CDI aren't initialized during static init; shading/obfuscation removing default constructors.","solutions":["Make the class concrete with a public no-argument constructor.","Read the nested 'Caused by' (InstantiationException, NoSuchMethodException, InvocationTargetException) for the root cause.","Move logic depending on CDI/services out of the constructor into integrate()/contribute() callbacks.","Verify the class implements the expected interface (e.g. MetadataBuilderContributor)."],"exampleFix":"// before\npublic abstract class MyContributor implements MetadataBuilderContributor { ... }\n// after\npublic class MyContributor implements MetadataBuilderContributor {\n    public MyContributor() { }\n    @Override public void contribute(MetadataBuilder mb) { ... }\n}","handlingStrategy":"validation","validationCode":"// Pre-instantiate to catch problems before boot\nObject c = Class.forName(\"com.example.MyContributor\").getConstructor().newInstance();\nif (!(c instanceof MetadataBuilderContributor)) throw new IllegalStateException(\"Wrong interface\");","typeGuard":null,"tryCatchPattern":"try {\n    bootPersistenceUnit();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"could not be instantiated\")) {\n        log.error(\"Contributor must be concrete with a public no-arg constructor\", e.getCause());\n    }\n}","preventionTips":["Make configured classes concrete, public, with public no-arg constructors","Never do CDI/service lookups in constructors used at static-init","Unit-test reflective instantiation of configured classes","Confirm the class implements the expected interface"],"tags":["hibernate-orm","reflection","instantiation","configuration"],"backgroundTag":"reflective-instantiation-failed","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"}