开发者

War deployment on Tomcat takes ages

I have a Grails application, built to a war file (~30mb). When I attempt to deploy the war file on Tomcat 6 via the application manager, it takes upwa开发者_如何学JAVArds of 10 minutes to deploy, or hangs indefinitely. When it hangs I can restart Tomcat and the app is usually deployed, however sometimes I have to repeat the process. I've also noticed that during deployment, the Java process maxes out the CPU and the RAM is at ~10-15%.

I'm fairly new to Java, so I don't know if this is normal, but I can't imagine how it could be. Is there something I can do to make this run smoother/faster? Is there a better way to deploy than Tomcat's app manager?


I upload the WAR to my home directory, cd to /usr/local/tomcat, then run the following commands:

bin/shutdown.sh
rm webapps/ROOT.war
rm -rf webapps/ROOT
cp ~/ROOT.war webapps
bin/startup.sh


Definitely check the Tomcat logs for any errors/warnings.

You probably have some expensive/sensitive code logic in one of the ServletContextListeners. They are usually initialized during startup. If so, then I would debug/profile it for any performance matters/leaks.


As noted I would copy the war to the webapps folder and let tomcat do the deployment, its also quicker saving you time.

Both Tomcat and Jetty will support a hot deploy. They simply monitor the deploy directory for changes, so you can just copy the .war file into that directory, and the server will undeploy/redeploy.

If using a remote server check the lag is not the time take to upload the war to a remote server over the network.


Don't use application manager. My way is to upload it somewhere out of the webapps directory and then copy it to webapps directory. Takes a lot less of deplyoment time.


It's not always that you have sufficient access rights to manually put files in the webapps folder -- you are supposed to use the Tomcat Application Manager for .war file deployment, and need to make it work.

For me, it has been common that the process of uploading of a .war file to the server cannot complete; it gets stuck somewhere in the middle and the file is only partially uploaded to the server, no matter how many times I retry. In such situations, I have found it worthwhile to try another browser. For instance, I've found myself stuck using Google Chrome but once I switched to a freshly started Firefox browser, things worked out.


This may be relate to this BUG of JDK

I readed this article, Tomcat7 starts too late on Ubuntu 14.04 x64 and resolved my problem.

Try to resolve it by replacing

securerandom.source=file:/dev/urandom  

with

securerandom.source=file:/dev/./urandom 

in $JAVA_PATH/jre/lib/security/java.security

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜