{"record":{"id":"ba255032a3a5c753","repo":"quarkusio/quarkus","slug":"lock-binding-not-found-on-business-method-metho","errorCode":null,"errorMessage":"@Lock binding not found on business method ${method}","messagePattern":"@Lock binding not found on business method (.+?)","errorType":"exception","errorClass":"jakarta.enterprise.context.control.LockException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LockInterceptor.java","lineNumber":111,"sourceCode":"                    throw new LockException(\"Read lock not acquired in \" + lock.unit().toMillis(time) + \" ms\");\n                }\n            } else {\n                rwl.readLock().lock();\n                locked = true;\n            }\n            return ctx.proceed();\n        } finally {\n            if (locked) {\n                rwl.readLock().unlock();\n            }\n        }\n    }\n\n    Lock getLock(ArcInvocationContext ctx) {\n        Lock lock = ctx.findIterceptorBinding(Lock.class);\n        if (lock == null) {\n            // This should never happen\n            throw new LockException(\"@Lock binding not found on business method \" + ctx.getMethod());\n        }\n        return lock;\n    }\n\n}\n","sourceCodeStart":93,"sourceCodeEnd":117,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/LockInterceptor.java#L93-L117","documentation":"LockInterceptor.getLock() expects the InvocationContext to carry a @Lock interceptor binding; if absent it throws LockException. The code comment notes this should never happen because the interceptor is only activated by that binding — hitting it means the interceptor was invoked with the wrong binding set (container bug, wrong interceptor wiring, or a reflection-built context in tests).","triggerScenarios":"Invoking an intercepted method through a manually constructed InvocationContext (e.g. custom AOP or test harness) that activates LockInterceptor without adding the Lock binding; container misconfiguration where interceptor bindings were lost.","commonSituations":"Unit tests invoking methods on raw (unproxied) or hand-wired interception contexts; upgrading Quarkus where binding propagation changed; registering LockInterceptor manually without its binding.","solutions":["Call the method through the CDI-managed bean (inject it) so ArC builds the correct intercepted context.","If building contexts manually, add the Lock interceptor binding via ctx.getInterceptorBindings-style API before proceeding.","Rebuild the app to regenerate interceptor chains (clean install) after a Quarkus upgrade.","Remove manual registration of LockInterceptor; rely on the container's automatic binding discovery."],"exampleFix":"// before\nnew MyBean().read(); // raw instance, wrong context\n// after\n@Inject MyBean bean;\nbean.read(); // container-managed, binding present","handlingStrategy":"type-guard","validationCode":"if (bean instanceof Intercepted == false /* or use CDI.current().select */) {\n    throw new IllegalStateException(\"Invoke via CDI-managed bean so @Lock binding is present\");\n}","typeGuard":"<T> T requireManaged(Instance<T> instance, Class<T> type) {\n    T bean = instance.get();\n    if (bean == null) throw new IllegalStateException(\"No managed bean for \" + type);\n    return bean;\n}","tryCatchPattern":"try {\n    return method.invoke(managedBean, args);\n} catch (InvocationTargetException e) {\n    if (e.getCause() instanceof LockException) {\n        throw new IllegalStateException(\"@Lock binding missing — use the container-managed proxy\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Always call @Lock-annotated methods on injected CDI beans, never on new instances","Don't manually register or drive LockInterceptor in tests","Rebuild after Quarkus upgrades so interceptor chains are regenerated"],"tags":["cdi","interceptor","arc","locking"],"backgroundTag":"missing-interceptor-binding","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"}