Add Tld scanning exceptions to Tomcat startup

Addresses gh-263 to some extent.
pull/276/head
Dave Syer 11 years ago
parent 91998d5942
commit 1f1820b161

@ -90,12 +90,8 @@
</activation> </activation>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>jetty-webapp</artifactId> <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</profile> </profile>

@ -37,6 +37,7 @@ import org.apache.catalina.Valve;
import org.apache.catalina.Wrapper; import org.apache.catalina.Wrapper;
import org.apache.catalina.connector.Connector; import org.apache.catalina.connector.Connector;
import org.apache.catalina.loader.WebappLoader; import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.TldConfig;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.Tomcat.FixContextListener; import org.apache.catalina.startup.Tomcat.FixContextListener;
import org.apache.coyote.AbstractProtocol; import org.apache.coyote.AbstractProtocol;
@ -89,6 +90,14 @@ public class TomcatEmbeddedServletContainerFactory extends
private String protocol = DEFAULT_PROTOCOL; 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. * Create a new {@link TomcatEmbeddedServletContainerFactory} instance.
*/ */
@ -137,6 +146,7 @@ public class TomcatEmbeddedServletContainerFactory extends
protected void prepareContext(Host host, ServletContextInitializer[] initializers) { protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
File docBase = getValidDocumentRoot(); File docBase = getValidDocumentRoot();
docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase")); docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase"));
TldConfig.setNoTldJars(this.noTldJars);
TomcatEmbeddedContext context = new TomcatEmbeddedContext(); TomcatEmbeddedContext context = new TomcatEmbeddedContext();
context.setName(getContextPath()); context.setName(getContextPath());
context.setPath(getContextPath()); context.setPath(getContextPath());
@ -281,6 +291,16 @@ public class TomcatEmbeddedServletContainerFactory extends
this.baseDirectory = baseDirectory; 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}. * The Tomcat protocol to use when create the {@link Connector}.
* @see Connector#Connector(String) * @see Connector#Connector(String)

Loading…
Cancel
Save