简体   繁体   English

Tomcat 5.5:.jar 未发布 on.war 重建

[英]Tomcat 5.5: .jar not releasing on .war rebuild

Synopsis概要

I am attempting to export a WAR to my webapps folder but everytiime I update the war it deletes all of the content of the webapp minus /WEB-INF/lib/struts.jar我正在尝试将 WAR 导出到我的 webapps 文件夹,但每次我更新 war 它都会删除 webapp 减去 /WEB-INF/lib/struts.jar 的所有内容

System info系统信息

  • Windows 2K3 Windows 2K3
  • Tomcat 5.5 Tomcat 5.5
  • JRE 1.6.23 JRE 1.6.23

Ok here is what is happening:好的,这就是正在发生的事情:

  1. Export project as.WAR via Eclipse (Helios) to /webapps directory通过 Eclipse (Helios) 将项目导出为 .WAR 到 /webapps 目录
  2. Tomcat sees the change in the war and attempts to rebuild webapp Tomcat 看到战局变化,尝试重建webapp
  3. Tomcat deletes contents of webapp folder ( /webapps/public ) Tomcat 删除 webapp 文件夹 ( /webapps/public ) 的内容
  4. ( /webapps/public/WEB-INF/lib/struts.jar ) is locked preventing it from being deleted. ( /webapps/public/WEB-INF/lib/struts.jar ) 被锁定以防止被删除。
  5. Tomcat gives up rebuild leaving me with nothing in the folder besides the struts.jar causing the application to break. Tomcat 放弃重建,文件夹中除了 struts 之外什么都没有。jar 导致应用程序中断。

Question(s)问题)

  • Is there a way to keep the jar from being locked?有没有办法防止 jar 被锁定?
  • (OR) a better deployment process I should be using (and can pick up quickly)? (或者)我应该使用更好的部署流程(并且可以快速上手)?

Using antiResourceLocking="true" and antiJARLocking="true" on the <Context> element did not solve the problem.<Context>元素上使用antiResourceLocking="true"antiJARLocking="true"并没有解决问题。 Appreciate any help.感谢任何帮助。

Does adding unloadDelay to your Context help?unloadDelay添加到您的 Context 有帮助吗?

Which is the:哪一个是:

Amount of ms that the container will wait for servlets to unload.容器等待 servlets 卸载的毫秒数。 If not specified, the default value of the flag is 2000 ms.如果未指定,则标志的默认值为 2000 毫秒。

Source: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html来源: http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Apparently sometimes the web app is in the middle of a large GC / the ClassLoader hasn't been garbage collected and cannot release in time.显然有时 web 应用程序处于大型 GC 中间/ClassLoader 没有被垃圾收集并且无法及时释放。 Try experimenting with the timeout to see if that helps.尝试尝试超时,看看是否有帮助。

There is also some anecdotal evidence of strange file locking on Windows platforms.在 Windows 平台上还有一些奇怪的文件锁定的轶事证据。

Also, assuming you're referring to a development (not production) build environment, look at one of my questions, showing my approach to Tomcat / Eclipse hot deploy environments:此外,假设您指的是开发(而非生产)构建环境,请查看我的一个问题,展示我对 Tomcat / Eclipse 热部署环境的方法:

Tomcat and Eclipse Zero Turnaround Deployment Tomcat 和 Eclipse 零周转部署


Update更新

This helpful thread comes up on a Google search of the same issue and is referred to by a number of others:这个有用的线程出现在对同一问题的 Google 搜索中,并被许多其他人引用:

http://blog.exis.com/colin/?s=I+Put+A+Spell+On+You http://blog.exis.com/colin/?s=I+Put+A+Spell+On+You

I guess your requirement is to deploy and rebuild quickly given eclipse is ur IDE.我想您的要求是快速部署和重建,因为 eclipse 是您的 IDE。 As you have figured out exporting war file to webapps folder is not the best option.正如您已经发现将战争文件导出到 webapps 文件夹不是最好的选择。 Few other options are其他选项很少

a) Use sysdeo tomcat plugin -- sysdeo deploys the project folder a) 使用 sysdeo tomcat 插件 -- sysdeo 部署项目文件夹

b) Update build script to deploy in exploded format. b) 更新构建脚本以展开格式部署。 -- deploy the \build folder as exploded application -- 将 \build 文件夹部署为展开的应用程序

First option is easiest.第一个选项是最简单的。 Second option is cleaner.第二种选择更清洁。

[OFF TOPIC] consider switching to tomcat 7 [OFF TOPIC] 考虑切换到 tomcat 7

Could this thread be of relevance?这个线程可能是相关的吗? Cites the DTD in the tiles-config.xml causing issues.引用了 tiles-config.xml 中的 DTD 导致了问题。

This is probably not the optimal solution but I have had similar issues with Tomcat 6 before now.这可能不是最佳解决方案,但在此之前我遇到过与 Tomcat 6 类似的问题。 At the time I was using Ant, so I wrote an Ant script which would deploy to Tomcat locally and in the process it would stop / start Tomcat where necessary (Tomcat was deployed as a service so I could use NET STOP / NET START commands ). At the time I was using Ant, so I wrote an Ant script which would deploy to Tomcat locally and in the process it would stop / start Tomcat where necessary (Tomcat was deployed as a service so I could use NET STOP / NET START commands ) . This included deleting the old expanded WAR folder.这包括删除旧的扩展 WAR 文件夹。

I think there probably are better options, but this worked for me.我认为可能有更好的选择,但这对我有用。

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

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