diff --git a/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java b/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java
index 217d5b984d..93158b4800 100644
--- a/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java
+++ b/config/src/main/java/org/springframework/security/config/method/GlobalMethodSecurityBeanDefinitionParser.java
@@ -452,6 +452,9 @@ public class GlobalMethodSecurityBeanDefinitionParser implements BeanDefinitionP
}
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
+ if(!registry.containsBeanDefinition(beanName)) {
+ return;
+ }
BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
beanDefinition.setLazyInit(true);
}
diff --git a/config/src/test/java/org/springframework/security/config/method/sec2499/Sec2499Tests.java b/config/src/test/java/org/springframework/security/config/method/sec2499/Sec2499Tests.java
new file mode 100644
index 0000000000..ae8a13905e
--- /dev/null
+++ b/config/src/test/java/org/springframework/security/config/method/sec2499/Sec2499Tests.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2002-2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.security.config.method.sec2499;
+
+import org.junit.After;
+import org.junit.Test;
+import org.springframework.context.support.GenericXmlApplicationContext;
+
+/**
+ *
+ * @author Rob Winch
+ *
+ */
+public class Sec2499Tests {
+ private GenericXmlApplicationContext parent;
+
+ private GenericXmlApplicationContext child;
+
+ @After
+ public void cleanup() {
+ if(parent != null) {
+ parent.close();
+ }
+ if(child != null) {
+ child.close();
+ }
+ }
+
+ @Test
+ public void methodExpressionHandlerInParentContextLoads() {
+ parent = new GenericXmlApplicationContext("org/springframework/security/config/method/sec2499/parent.xml");
+ child = new GenericXmlApplicationContext();
+ child.load("org/springframework/security/config/method/sec2499/child.xml");
+ child.setParent(parent);
+ child.refresh();
+ }
+}
\ No newline at end of file
diff --git a/config/src/test/resources/org/springframework/security/config/method/sec2499/child.xml b/config/src/test/resources/org/springframework/security/config/method/sec2499/child.xml
new file mode 100644
index 0000000000..b9bc511cdb
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/method/sec2499/child.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config/src/test/resources/org/springframework/security/config/method/sec2499/parent.xml b/config/src/test/resources/org/springframework/security/config/method/sec2499/parent.xml
new file mode 100644
index 0000000000..cf62a87ce0
--- /dev/null
+++ b/config/src/test/resources/org/springframework/security/config/method/sec2499/parent.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+