diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java index 3fd7b5f928..9234b36403 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java @@ -117,7 +117,8 @@ class ConfigurationClassEnhancer { */ private Class createClass(Enhancer enhancer) { Class subclass = enhancer.createClass(); - Enhancer.registerCallbacks(subclass, this.callbackInstances.toArray(new Callback[this.callbackInstances.size()])); + // registering callbacks statically (as opposed to threadlocal) is critical for usage in an OSGi env (SPR-5932) + Enhancer.registerStaticCallbacks(subclass, this.callbackInstances.toArray(new Callback[this.callbackInstances.size()])); return subclass; }