`
lym6520
  • 浏览: 695505 次
  • 性别: Icon_minigender_1
  • 来自: 福建
社区版块
存档分类
最新评论

tomcat server.xml设置Context指定webapp访问路径引起的context.xml无效

阅读更多
        通过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配置参考:
<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>
0
0
分享到:
评论
1 楼 lym6520 2014-02-12  
antiJARLocking

If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false.

antiJARLocking is a subset of antiResourceLocking and therefore, to prevent duplicate work and possible issues, only one of these attributes should be set to true at any one time.


antiResourceLocking
If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false.

antiJARLocking is a subset of antiResourceLocking and therefore, to prevent duplicate work and possible issues, only one of these attributes should be set to true at any one time.

Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668.

Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host.

相关推荐

    修改Tomcat默认访问根目录的方法

    在Tomcat默认安装后,tomcat的主目录是webapps/root目录。 在conf文件夹下面找到server.xml 打开 在&lt;hosts&gt; ……中间添加一行 代码如下:&lt;Context path=”” docBase=”/usr...Context docBase=”D:/Tomcat 8.0/webapp

    tomcat权威指南第二版.pdf

    context.xml 335 8. Debugging and Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336 Reading Logfiles 336 Hunting for Errors 337 URLs and the ...

    Red5 0.9与现有tomcat项目整合

    &lt;bean id="myApp.context" class="org.red5.server.Context"&gt; &lt;property name="scopeResolver" ref="red5.scopeResolver" /&gt; &lt;property name="clientRegistry" ref="global.clientRegistry" /&gt; ...

    tomcat7使用redis管理session需要的jar包

    2、修改tomcat/conf下的context.xml文件,示例如下: &lt;!-- Default set of monitored resources --&gt; &lt;WatchedResource&gt;WEB-INF/web.xml &lt;!-- Uncomment this to disable session persistence across Tomcat ...

    Tomcat监控工具Probe,支持tomcat6-7-8-9.zip

    3.将下载好的war包,或者zip文件,放在tomcat的webapp目录下 4.配置tomcat-users.xml文件 &lt;tomcat-users&gt;&lt;/tomcat-users&gt;标签内添加,具体的权限配置,查看下面表格 &lt;role rolename="tomcat"/&gt; ...

    Struts2+Spring3+MyBatis3完整实例

    网上的东西好大多都不能直接用,自己结合网上资料做了一个Struts2+Spring3+MyBatis3的测试工程,JUnit测试用例和WEB服务。...- Find registry server-registry.xml at classpath resource - Server startup in 5329 ms

    tomcat 采用msm连接memcached缓存session所需要的所有jar包下载

    1,在tomcat中找到文件apache-tomcat-6.0.37\conf\context.xml 加入内部 &lt;Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n1:192.168.1.65:11211" ...

    开心超级签名系统源码下载 Java超级签名系统企业签名超级签名 apk分发系统源码.zip

    把webapp下的war解压,修改里面的servlet-context.xml和applicationContext-dao.xml里面对 classpath:spring/kxapp.properties改成file:spring/kxapp.properties, 这样运行版本的服务器 配置文件就放到了tomcat/bin...

    Tomcat下发布JSP程序的N种方法

    JSP网站的发布最灵活的一种方式我们可以在Tomcat的conf目录下的的Servlet.xml文件中进行配置 在其Host标签内新建一个Context标签来部置一个JSP应用程序,如果在这里部置后,那我们就不需要再把 你的作品拿到...

    Jetty中文手册

    如何设置上下文(Context Path) 如何知道使用了那些jar包 如何配置SSL 如何使用非root用户监听80端口 如何配置连接器(Connectors) 如何配置虚拟主机(Virtual Hosts) 如何配置会话ID(Session IDs) 如何序列化...

    Apache2.2整合Tomcat6所用软件包

    &lt;Context path="/uambank" reloadable="false" docBase="D:\\jdk\\workspace\\uambank\\uambank\\deploy\\target\\uambank-webapp" workDir="D:/jdk/workspace/work" /&gt; tomcat_bbs的设定 Shutdown 端口 ...

    spring-cxf:Apache CXF 在 Spring Boot 中运行,具有零 XML 配置

    或者,可以通过放入容器(例如 Jetty 或 Tomcat 的 /webapp 目录)来运行。 服务端点 服务端点是&lt;context&gt;/api/hello 。 WSDL/服务的完整路径是: http://localhost:8080/ws-server-1.0/api/hello?wsdl 运行客户

    solr-5.2.1.part1.rar 编译第1部分,共2部分

    创建JNDI让程序找到solr/home(当然你也可以用System Properties方式), 在WebRoot/META-INF目下创建context.xml 文件,并写入以下字符 &lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;Context&gt; ...

    solr-5.2.1.part2.rar 编译 第2部分,共2部分

    创建JNDI让程序找到solr/home(当然你也可以用System Properties方式), 在WebRoot/META-INF目下创建context.xml 文件,并写入以下字符 &lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;Context&gt; ...

    solr-5.2.1-src.tgz源码

    创建JNDI让程序找到solr/home(当然你也可以用System Properties方式), 在WebRoot/META-INF目下创建context.xml 文件,并写入以下字符 &lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;Context&gt; ...

    apache-solr-ref-guide-5.2.1用户手册与搭建指南.rar

    创建JNDI让程序找到solr/home(当然你也可以用System Properties方式), 在WebRoot/META-INF目下创建context.xml 文件,并写入以下字符 &lt;?xml version='1.0' encoding='utf-8'?&gt; &lt;Context&gt; ...

    wechat-spring-mvc

    配置MySQL连接:根据需要更改src / main / webapp / WEB-INF / spring / appServlet / servlet-context.xml中的dataSource bean定义。 名称价值网址jdbc:mysql:// localhost:3306 / TestDB 用户名根密码MVC 成分...

Global site tag (gtag.js) - Google Analytics