From 1f1820b16182b4b7c644d2667908de65f56c3690 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 27 Jan 2014 13:21:29 +0000 Subject: [PATCH] Add Tld scanning exceptions to Tomcat startup Addresses gh-263 to some extent. --- .../spring-boot-sample-actuator/pom.xml | 8 ++------ ...TomcatEmbeddedServletContainerFactory.java | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/spring-boot-samples/spring-boot-sample-actuator/pom.xml b/spring-boot-samples/spring-boot-sample-actuator/pom.xml index df7914a465..447d252de7 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/pom.xml +++ b/spring-boot-samples/spring-boot-sample-actuator/pom.xml @@ -90,12 +90,8 @@ - org.eclipse.jetty - jetty-webapp - - - javax.servlet - javax.servlet-api + org.springframework.boot + spring-boot-starter-jetty diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java index 34552999b2..a8f59104b9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java @@ -37,6 +37,7 @@ import org.apache.catalina.Valve; import org.apache.catalina.Wrapper; import org.apache.catalina.connector.Connector; import org.apache.catalina.loader.WebappLoader; +import org.apache.catalina.startup.TldConfig; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat.FixContextListener; import org.apache.coyote.AbstractProtocol; @@ -89,6 +90,14 @@ public class TomcatEmbeddedServletContainerFactory extends private String protocol = DEFAULT_PROTOCOL; + private static String DEFAULT_NO_TLD_JARS = "tomcat-*.jar,tools.jar,commons-beanutils*.jar,commons-codec*.jar,commons-collections*.jar," + + "commons-dbcp*.jar,commons-digester*.jar,commons-fileupload*.jar,commons-httpclient*.jar,commons-io*.jar,commons-lang*.jar," + + "commons-logging*.jar,commons-math*.jar,commons-pool*.jar,jstl-*.jar,geronimo-spec-jaxrpc*.jar,wsdl4j*.jar,ant-*.jar," + + "aspectj*.jar,jmx.jar,h2*.jar,hibernate*.jar,httpclient*.jar,jmx-tools-*.jar,jta*.jar,log4j-*.jar,mail*.jar,slf4j*.jar," + + "xercesImpl-*.jar,xmlParserAPIs-*.jar,xml-apis-*.jar,junit-*.jar,hamcrest*.jar,org.hamcrest*.jar"; + + private String noTldJars = DEFAULT_NO_TLD_JARS; + /** * Create a new {@link TomcatEmbeddedServletContainerFactory} instance. */ @@ -137,6 +146,7 @@ public class TomcatEmbeddedServletContainerFactory extends protected void prepareContext(Host host, ServletContextInitializer[] initializers) { File docBase = getValidDocumentRoot(); docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase")); + TldConfig.setNoTldJars(this.noTldJars); TomcatEmbeddedContext context = new TomcatEmbeddedContext(); context.setName(getContextPath()); context.setPath(getContextPath()); @@ -281,6 +291,16 @@ public class TomcatEmbeddedServletContainerFactory extends this.baseDirectory = baseDirectory; } + /** + * A comma-separated list of jars to ignore for TLD scanning. See Tomcat's + * catalina.properties for typical values. Defaults to a list drawn from that source. + * + * @param noTldJars the noTldJars to set + */ + public void setNoTldJars(String noTldJars) { + this.noTldJars = noTldJars; + } + /** * The Tomcat protocol to use when create the {@link Connector}. * @see Connector#Connector(String)