简体   繁体   English

如何防止Tomcat6在WEB-INF / lib中预加载JDBC驱动程序?

[英]How can I prevent Tomcat6 from pre-loading JDBC Drivers in WEB-INF/lib?

I have a number of JDBC Driver jar files in my webapp's WEB-INF/lib - eg oracle and SQL-Server. 我的Web应用程序的WEB-INF / lib中有许多JDBC Driver jar文件-例如oracle和SQL-Server。 In Tomcat7, if the webapp only uses oracle, the SQL-Server driver doesn't get registered, but in Tomcat6 it does (I can see this from my contextDestroyed() in a ServletContextListener, which de-registers Drivers loaded by this classloader). 在Tomcat7中,如果Web应用程序仅使用oracle,则不会注册SQL-Server驱动程序,但是在Tomcat6中,它会注册(我可以从ServletContextListener中的contextDestroyed()中看到此信息,该注册器会注销由该类加载器加载的驱动程序) 。

Is Tomcat6 somehow pre-loading classes from jars in WEB-INF/lib? Tomcat6是否以某种方式从WEB-INF / lib中的jars预加载了类? If so, can this be disabled? 如果是这样,可以禁用此功能吗?

(I know these jars would be better in the shared lib, but this is another issue...) (我知道这些jar在共享库中会更好,但这是另一个问题...)

Never ever put drivers in the webapp class path. 永远不要将驱动程序放在webapp类路径中。 Put it always into the server's classpath. 始终将其放入服务器的类路径中。

Declare a DataSource then in your context.xml and then free the resources with this . 然后在您的context.xml声明一个DataSource ,然后使用this释放资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM