|
25 | 25 | import javax.servlet.http.HttpServletRequest;
|
26 | 26 | import javax.servlet.http.HttpServletResponse;
|
27 | 27 |
|
| 28 | +import org.apache.commons.logging.Log; |
| 29 | +import org.apache.commons.logging.LogFactory; |
28 | 30 | import org.springframework.beans.BeansException;
|
29 | 31 | import org.springframework.beans.factory.BeanFactory;
|
30 | 32 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
50 | 52 | import org.springframework.boot.autoconfigure.web.ServerProperties;
|
51 | 53 | import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
|
52 | 54 | import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
|
| 55 | +import org.springframework.boot.context.embedded.EmbeddedServletContainerException; |
53 | 56 | import org.springframework.context.ApplicationContext;
|
54 | 57 | import org.springframework.context.ApplicationContextAware;
|
55 | 58 | import org.springframework.context.ApplicationListener;
|
|
81 | 84 | public class EndpointWebMvcAutoConfiguration implements ApplicationContextAware,
|
82 | 85 | ApplicationListener<ContextRefreshedEvent> {
|
83 | 86 |
|
| 87 | + private static Log logger = LogFactory.getLog(EndpointWebMvcAutoConfiguration.class); |
| 88 | + |
84 | 89 | private ApplicationContext applicationContext;
|
85 | 90 |
|
86 | 91 | @Autowired
|
@@ -184,7 +189,20 @@ public void onApplicationEvent(ContextClosedEvent event) {
|
184 | 189 | }
|
185 | 190 | });
|
186 | 191 | }
|
187 |
| - childContext.refresh(); |
| 192 | + try { |
| 193 | + childContext.refresh(); |
| 194 | + } |
| 195 | + catch (RuntimeException e) { |
| 196 | + // No support currently for deploying a war with management.port=<different>, |
| 197 | + // and this is the signature of that happening |
| 198 | + if (e instanceof EmbeddedServletContainerException |
| 199 | + || e.getCause() instanceof EmbeddedServletContainerException) { |
| 200 | + logger.warn("Could not start embedded container (management endpoints are still available through JMX)"); |
| 201 | + } |
| 202 | + else { |
| 203 | + throw e; |
| 204 | + } |
| 205 | + } |
188 | 206 | }
|
189 | 207 |
|
190 | 208 | protected static enum ManagementServerPort {
|
|
0 commit comments