{"record":{"id":"14535973f0f616f5","repo":"quarkusio/quarkus","slug":"not-a-message-bundle-interface","errorCode":null,"errorMessage":"Not a message bundle interface: ","messagePattern":"Not a message bundle interface: ","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/qute/runtime/src/main/java/io/quarkus/qute/i18n/MessageBundles.java","lineNumber":41,"sourceCode":"import io.quarkus.qute.TemplateInstance;\nimport io.quarkus.qute.Variant;\nimport io.quarkus.qute.runtime.MessageBundleRecorder.BundleContext;\n\npublic final class MessageBundles {\n\n    public static final String ATTRIBUTE_LOCALE = TemplateInstance.LOCALE;\n    public static final String DEFAULT_LOCALE = \"<<default>>\";\n\n    private MessageBundles() {\n    }\n\n    public static <T> T get(Class<T> bundleInterface) {\n        return get(bundleInterface, null);\n    }\n\n    public static <T> T get(Class<T> bundleInterface, Localized localized) {\n        if (!bundleInterface.isInterface()) {\n            throw new IllegalArgumentException(\"Not a message bundle interface: \" + bundleInterface.getName());\n        }\n        if (!bundleInterface.isAnnotationPresent(MessageBundle.class)\n                && !bundleInterface.isAnnotationPresent(Localized.class)) {\n            throw new IllegalArgumentException(\n                    \"Message bundle interface must be annotated either with @MessageBundle or with @Localized: \"\n                            + bundleInterface.getName());\n        }\n        ArcContainer container = Arc.requireContainer();\n        InstanceHandle<T> handle = localized != null ? container.instance(bundleInterface, localized)\n                : container.instance(bundleInterface);\n        if (handle.isAvailable()) {\n            return handle.get();\n        }\n        throw new IllegalStateException(Qute.fmt(\n                \"Unable to obtain a message bundle for interface [{ifacename}]{#if loc} and locale [{loc.value}]{/if}\")\n                .data(\"ifacename\", bundleInterface.getName())\n                .data(\"loc\", localized)\n                .render());","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/runtime/src/main/java/io/quarkus/qute/i18n/MessageBundles.java#L23-L59","documentation":"MessageBundles.get() resolves a CDI bean implementing the given message bundle interface at runtime. Before lookup it validates the argument is an interface; passing a class throws IllegalArgumentException('Not a message bundle interface: ...').","triggerScenarios":"Calling MessageBundles.get(SomeClass.class) or MessageBundles.get(iface, locale) where the Class argument is a concrete class, enum, or record rather than an interface.","commonSituations":"Autocompleting to a wrong class type; confusing MessageBundles.get with a generic service locator API; refactoring an interface into an abstract class while call sites remain.","solutions":["Pass only the message bundle interface (annotated with @MessageBundle or @Localized)","If the type became a class, restore it as an interface to keep bundle support","Check imports — make sure you reference the interface, not a similarly named impl class"],"exampleFix":"// before\nMyMessages m = MessageBundles.get(MyMessagesImpl.class);\n// after\nMyMessages m = MessageBundles.get(MyMessages.class);","handlingStrategy":"type-guard","validationCode":"if (!bundleInterface.isInterface()) {\n    throw new IllegalArgumentException(bundleInterface + \" is not an interface\");\n}","typeGuard":"static <T> boolean isBundleCandidate(Class<T> c) {\n    return c.isInterface() && (c.isAnnotationPresent(MessageBundle.class) || c.isAnnotationPresent(Localized.class));\n}","tryCatchPattern":"try {\n    MyMessages m = MessageBundles.get(MyMessages.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Not a message bundle interface\")) {\n        throw new IllegalStateException(\"Pass the bundle interface, not a class\", e);\n    }\n    throw e;\n}","preventionTips":["Keep bundle types as interfaces, never refactor them to abstract classes","Type the MessageBundles.get call against the annotated interface","Rely on IDE generics: get() will not accept non-interface types without warnings if generics are used correctly"],"tags":["qute","i18n","messages","cdi"],"backgroundTag":"invalid-argument-value","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"}