通过tomcat的server.xml设置来部署webapp,即在Host下增加Context节点,会引起webapp应用的META-INF/context.xml文件无效,如果context配置了数据源则可能会出现如下错误:
[org.hibernate.util.JDBCExceptionReporter]-[ERROR] - Cannot create JDBC driver of class '' for connect URL 'null'
所以如果是通过server.xml设置来部署webapp的,应当把context.xml配置也转移到server.xml中,这样就可以避免此类问题。
另外Context节点的属性 antiResourceLocking="true" antiJARLocking="true" 要慎用,如果配置上,部署的项目会copy一份到tomcat/temp目录下,如果上传的附件是保存在webapp目录下tomcat重启后附件就会丢失。
Context配置参考:
[org.hibernate.util.JDBCExceptionReporter]-[ERROR] - Cannot create JDBC driver of class '' for connect URL 'null'
所以如果是通过server.xml设置来部署webapp的,应当把context.xml配置也转移到server.xml中,这样就可以避免此类问题。
另外Context节点的属性 antiResourceLocking="true" antiJARLocking="true" 要慎用,如果配置上,部署的项目会copy一份到tomcat/temp目录下,如果上传的附件是保存在webapp目录下tomcat重启后附件就会丢失。
Context配置参考:
<Context reloadable="false" docBase="/usr/wwwroot/app1" path="">
<Resource name="jdbc/lxcy" auth="Container"
type="javax.sql.DataSource" maxActive="40" maxIdle="20"
maxWait="10000" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/lxcy?characterEncoding=utf8"
username="lxcy"
password="123456"
testOnBorrow="true" testWhileIdle="true"
validationQuery="select now()" />
</Context>