Commit 5d317f2d authored by Dave Syer's avatar Dave Syer

Reflection hack for Tomcat 8 API change

Fixes gh-1148
parent fda24b84
......@@ -16,9 +16,12 @@
package org.springframework.boot.context.embedded.tomcat;
import java.lang.reflect.Method;
import org.apache.catalina.Container;
import org.apache.catalina.core.StandardContext;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
* Tomcat {@link StandardContext} used by {@link TomcatEmbeddedServletContainer} to
......@@ -45,7 +48,12 @@ class TomcatEmbeddedContext extends StandardContext {
if (classLoader != null) {
existingLoader = ClassUtils.overrideThreadContextClassLoader(classLoader);
}
super.loadOnStartup(findChildren());
if (ClassUtils.isPresent("org.apache.catalina.deploy.ErrorPage", null)) {
super.loadOnStartup(findChildren());
}
else {
callSuper(this, "loadOnStartup", findChildren(), Container[].class);
}
if (existingLoader != null) {
ClassUtils.overrideThreadContextClassLoader(existingLoader);
}
......@@ -59,4 +67,10 @@ class TomcatEmbeddedContext extends StandardContext {
return this.starter;
}
private void callSuper(Object target, String name, Object value, Class<?> type) {
Method method = ReflectionUtils.findMethod(target.getClass().getSuperclass(),
name, type);
ReflectionUtils.invokeMethod(method, target, value);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment