War deployment on Tomcat takes ages - java

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 upwards 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

Related

How do I delete a directory if a file has changed using Chef?

I want to create a Chef recipe for deploying a java application using tomcat. When I update the java application(.WAR file in my cookbook, upload and get a node to run the updated cookbook), I want Chef to stop tomcat, delete the contents of tomcat/webapps folder, copy the new war and then start tomcat again.
I've seen syntax for if File.exists, but have not seen anything for if . How can I do this?
I presume Chef has this functionality, since it updates files only if their checksum changes.
I'm missing some details, for example how do you put WAR file in proper location. So I'll assume you use cookbook_file resource.
cookbook_file "path/to/release.war" do
notifies :execute, "cleanup tomcat webapp directory", :before
notifies :start, "service[tomcat]"
end
execute "cleanup tomcat directory" do
notifies :stop, "service[tomcat]", :before
command "rm -r path/tomcat/webapps/*"
action :nothing
end
Service tomcat must be available in scope of resource where you'll be putting this code, before timer requires chef 12.7 afair.
However this solution may introduce downtime for time of running rm -r and requires full stop/start of tomcat. Wouldn't it be better to use hot deploy (on running server)?

War works fine on local standalone tomcat 7 (no eclipse), does not work when uploaded to ec2

I am able to get the spring blazeds examples and war (http://docs.spring.io/spring-flex/docs/1.5.2.RELEASE/reference/html/#pre-built-samples) working locally in tomcat 7 webapps directory (i initially had problems with this but now it works fine locally), however when I upload the same war file to amazon ec2, tomcats starts up fine and i can see the project's index page but none of the projects scripts are executing. According to the catalina.out log, the server started up successfully without any errors. Please help.
thanks,
tone
*Update
I am assuming that the problem resides in the blazeds portion of the project? Not sure if it is executing properly. i have enabled ports 8080 and 8400 in the security group.
Nevermind I found out the issue. i had to recompile the swf files that comes with the project to point to my ec2 instance url instead of localhost.

Problem deplopying war on jetty 6

Jetty cannot unzip my Wicket application war and extract to the temp directory. It is able to unzip the example wars without issue.
I have two identical installations on 64 bit linux (Centos) using Jetty 6.1.16 and 64 bit java 1.6. One works and one is unable to unjar/zip the war and deploy it. I compile using 1.5 compatibility. I use maven to generate the war file. If I deploy the .war I get a general error - cannot unzip. If I unwar the web app to a file system and deploy that to Jetty it works fine.
To make sure it isn't a permissions problem I ran it as root but saw no difference no difference.
I actually get NoClassDefFound errors when deplopying as war to be extracted.
I can ask Jetty not to extract the war, but when I do I get another error ...
org.apache.wicket.WicketRuntimeException: Unable to load initializers file
Caused by: java.util.zip.ZipException: error in opening zip file
The deployment directory is listed in the output, but when I look in it, it is empty. Odd thing is the example war that comes with Jetty extracts and runs just fine without error, so it seems to be something about the way the war file is being created on my end (war created using eclipse/maven on 32 bit Vista). But again, it works fine on another virtually identical server wich makes that unlikely.
Was hopeing someone had a ready answer before I tear it all down and reinstall everything :-).
Sounds like an issue with file system permissions. Did you make sure that the user under which you run Jetty has write permissions to the directory where the war is supposedly to be extracted to?
The algorithm by which Jetty determines where to unzip a web application can potentially choose a bunch of directories. You should probably also sanity-check the variables that play a role in this algorithm and make sure that the user running Jetty has sufficient read/write permissions on these directories.

Tomcat6 not deploying my webapp

I have access to a Tomcat server that is currently deploy two webapps. When I put my own webapp in the apache-tomcat-6.xxx/webapps directory, it doesn't deploy it. I tried downloading the Tomcat sample webapp, and deployed it in the webapps directory, and it still doesn't deploy.
Is there anything I have to do beyond putting the webapps in the apache*/webapps directory to get them to deploy? I have tried starting/restarting Tomcat ad nauseam.
Thanks,
ktm
When you say you put your own webapp, I assume you are putting your webapp.war file? Make sure you delete the existing webapp directory first before you place webapp.war. Tomcat will automatically inflate the war file to create that webapp directory.
Did you try stopping and starting tomcat?
Is your server getting started? And if yes than your project directory is created in webapps.
Also look for environment variable.
Check to see if the security manager is running. If it is you will need to edit the catalina.policy file to allow your web application to be deployed and accessed.
If you export your .war file from eclipse, make sure your project's dynamic web module facet version is not more than what your production server can handle. For example, version 3.0 works for Tomcat 7, but doesn't work on Tomcat 6, which needs it to be set as 2.5. To knock the project facet version down a notch, see this question.
Ensure that permissions on your war file belongs to the tomcat user and group. Make sure to remove the deployed directory first, and then restart the server.
$ sudo rm -fr /path/to/tomcat/webapps/<yourwebapp>
$ sudo chown tomcat:tomcat /path/to/tomcat/webapps/<yourwebapp.war>
Now restart the server
I had a problem with tomcat 6's deployment system. For some reason the file $CATALINA_HOME/conf/Catalina/localhost/MyAppName.xml was zero-length... I'm not sure about what caused it, but I deleted the zero-lenght XML, deleted the WAR and then I repeated the deployment process (copied the WAR to the webapps directory) and it deployed correctly. I found the failure message in a log file... now I know it for the next time, but I though it would be worth to share just in case...
Hope it helps...
i also meet the problem,i redownload tomcat and check service.xml carefully,finnally i find my WEB-INF/web.xml not exsit.
The problem that I faced was there were too many java processes that were running. Somehow it was not letting Tomcat start and did not throw any error.
For that I killed all the java processes and then restarted the Tomcat and it worked.
In Linux:
> ps -aux | grep java
> kill -9 [pid_from_last_command]

Tomcat needs to be restarted 2 times when uploading new war file

When I put a new war file in the webapps directory and restart tomcat, my war file is exploded but the servlets are not available and their respective log files are not created in the logs directory. When I bounce tomcat again, then the servlets are available and the log files are created. I'm assuming I have setting(s) not correct within tomcat, but I'm not sure where to start.
Does anyone know the cause of my current situation? Or even what parameters to review?
New Additional/Comments: Our setup allows us to have our app 'myApp' be the default application that is seen at root of our URL. On the first starting of tomcat, I can get to myApp by going to /myApp/index.html - whereas on the second start of tomcat I can then just goto and myApp/index.html is displayed.
My welcome file list is the 'myApp/index.html'
I had a similar problem with Tomcat 6.0.26. I worked around it by deleting the exploded webapps before copying the new war file to the webapps directory. Maybe a little kludgy, but it solved my problem.
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
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.
have you set unpackWars and autoDeploy params to true in your server.xml file?
Try to do unpackwars=false and always make sure tomat is not running when you do deployment try to avoid hot deployment...

Categories

Resources