{"record":{"id":"df540446254c94a7","repo":"openjdk/jdk","slug":"couldn-t-find-x-input-context-n","errorCode":null,"errorMessage":"Couldn't find X Input Context\\n","messagePattern":"Couldn't find X Input Context\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c","lineNumber":409,"sourceCode":"        removeX11InputMethodGRefFromList(pX11IMData->x11inputmethod);\n        (*env)->DeleteGlobalRef(env, pX11IMData->x11inputmethod);\n    }\n\n    if (pX11IMData->lookup_buf) {\n        free((void *)pX11IMData->lookup_buf);\n    }\n\n    free((void *)pX11IMData);\n}\n\n/*\n * Sets or unsets the focus to the given XIC.\n */\nstatic void\nsetXICFocus(XIC ic, unsigned short req)\n{\n    if (ic == NULL) {\n        (void)fprintf(stderr, \"Couldn't find X Input Context\\n\");\n        return;\n    }\n    if (req == 1)\n        XSetICFocus(ic);\n    else\n        XUnsetICFocus(ic);\n}\n\n/*\n * Sets the focus window to the given XIC.\n */\nstatic void\nsetXICWindowFocus(XIC ic, Window w)\n{\n    if (ic == NULL) {\n        (void)fprintf(stderr, \"Couldn't find X Input Context\\n\");\n        return;\n    }","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c#L391-L427","documentation":"Printed by setXICFocus() in the XAWT input-method code when Java asks to set or unset X Input Method focus on an XIC that is NULL — i.e. the input context for the focused component could not be found or was already destroyed. The call is then skipped, so XIM focus tracking silently diverges from AWT focus; text composition (preedit/commit) may stop working for that component.","triggerScenarios":"XSetICFocus/XUnsetICFocus requests arriving after XDestroyIC ran for a window's context, or when XCreateIC failed earlier (missing XMODIFIERS, dead input-method server) leaving currentXIC == NULL. Typical during rapid window close/reopen, focus changes while an IME restarts, or opening/closing composition-enabled components.","commonSituations":"Running under X11 with XMODIFIERS pointing at a crashed/hung IM server (ibus/fcitx restarted under the app); usinginput-method frameworks with dialogs that gain focus during disposal; remote X sessions where the IM server connection drops. Mostly harmless noise but signals IME may be dead for that window.","solutions":["Verify the input method server is alive: restart ibus/fcitx and check XMODIFIERS (@im=ibus/@im=fcitx) matches the running server","Re-launch the application after the IM server is back; stale XICs from before the restart cannot recover","Avoid closing windows while composition is active — commit or cancel composition before dispose","On Wayland, run the app in a proper XWayland session with the same IM environment set"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// before launching a GUI app that needs IME, sanity-check the IM environment\nString xm = System.getenv(\"XMODIFIERS\");\nif (System.getenv(\"XDG_SESSION_TYPE\").equals(\"x11\") && (xm == null || xm.isEmpty())) {\n    System.err.println(\"XMODIFIERS unset — IME focus (XIC) may be unavailable\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Launch the app with the IM server already running and XMODIFIERS set","Don't close windows while composition (preedit) is active","Restart the app after any ibus/fcitx crash — stale XICs cannot be fixed in-process"],"tags":["x11","input-method","ime","awt","linux","native"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}