{"record":{"id":"391d1862004c91a4","repo":"quarkusio/quarkus","slug":"unable-to-obtain-a-message-bundle-for-interface","errorCode":null,"errorMessage":"Unable to obtain a message bundle for interface [{ifacename}]{#if loc} and locale [{loc.value}]{/if}","messagePattern":"Unable to obtain a message bundle for interface \\[(.+?)\\](.+?) and locale \\[(.+?)\\](.+?)","errorType":"exception","errorClass":"java.lang.IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/qute/runtime/src/main/java/io/quarkus/qute/i18n/MessageBundles.java","lineNumber":55,"sourceCode":"    }\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());\n    }\n\n    /**\n     * Obtains a message bundle for the specified interface and the current locale.\n     * <p>\n     * The current locale is obtained from a {@link CurrentLocaleProvider} bean. The appropriate localized variant is\n     * selected by an exact language tag match first, then by a language-only match. If no provider is available, or the\n     * current locale cannot be determined, or no matching localized variant exists, then the bundle for the default\n     * locale is returned.\n     * <p>\n     * This method backs the beans injected with the {@link LocaleAware} qualifier.\n     *\n     * @param <T>\n     * @param bundleInterface","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/qute/runtime/src/main/java/io/quarkus/qute/i18n/MessageBundles.java#L37-L73","documentation":"MessageBundles.get() obtains the bundle implementation from the CDI container (optionally qualified with @Localized). If no bean is available for the interface (and locale, when a @Localized qualifier is given), it throws IllegalStateException with a Qute-rendered message naming the interface and locale.","triggerScenarios":"Calling MessageBundles.get(AppMessages.class) (or with a Localized instance) at runtime when the message bundle bean was never registered — e.g. the interface isn't a bean (no @MessageBundle in an unprocessed module), the localized variant for that locale was never defined, or ArC container isn't started.","commonSituations":"Requesting a locale variant (@Localized('de')) that was never authored; using MessageBundles.get in a non-CDI context/unit test without the Quarkus container; bundle interface living in a library not processed by the Qute extension.","solutions":["Define a @Localized bean for the requested locale, or request the default bundle without the localized qualifier","Ensure the interface is annotated with @MessageBundle and part of the Quarkus application build","Run inside the Quarkus runtime (ArC container started), not a plain JUnit test without @QuarkusTest","Check quarkus.default-locale / quarkus.locales config to confirm the locale is supported"],"exampleFix":"// before\nAppMessages m = MessageBundles.get(AppMessages, new Localized.Literal(Locale.FRENCH)); // no fr bundle\n// after\n@Localized(\"fr\") AppMessagesFr fr; // define/add the fr variant, or use the default bundle\nAppMessages m = MessageBundles.get(AppMessages);","handlingStrategy":"try-catch","validationCode":"// Before calling get(), ensure the app is running under Quarkus and the locale variant exists\nboolean defaultOnly = MessageBundles.getHandle == null; // or check Arc.container() != null\nSet<String> availableLocales = Set.of(\"en\", \"de\"); // mirror your @Localized values\nif (!availableLocales.contains(requestedLocale)) { /* fall back to default bundle */ }","typeGuard":null,"tryCatchPattern":"try {\n    return MessageBundles.get(AppMessages.class, new Localized.Literal(locale));\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Unable to obtain a message bundle\")) {\n        return MessageBundles.get(AppMessages.class); // fall back to default\n    }\n    throw e;\n}","preventionTips":["Author @Localized variants for every locale you advertise in quarkus.locales","Only call MessageBundles.get from within the running Quarkus container (@QuarkusTest or runtime beans)","Keep a default (unqualified) bundle so lookups without a locale always succeed"],"tags":["qute","i18n","cdi","locale"],"backgroundTag":"bean-not-available","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"}