I am trying to deploy a war file on tomcat . Each time I make a modification I generate a war and deploy it to tomcat (Using the tomcat manager) to check my changes . Suddenly each time I deploy a changed war , tomcat seems to be hosting an old version of the file ( Which I suspect is a cached copy) . I tried re-installing tomcat , restarting my computer etc . I also extracted the files from the war to check if the changes exist and they do . Any help on how I could debug or work on this problem will be greatly appreciated .
Did you try cleaning up the following folders / files:
$TOMCAT_HOME\webapps\yourapplication
$TOMCAT_HOME\webapps\yourapplication.war
$TOMCAT_HOME\work\Catalina\localhost\yourapplication
$TOMCAT_HOME\temp
By default, tomcat uses a subdirectory called work to hold a cached copy of the exploded war. If you are having issues with old files hanging around, that is probably where they are. You might also check your tomcat log file for messages that are generated when you deploy the new version of the war regarding files that could not be removed during the undeploy phase.
Related
I am a sydadmin and was evaluating Hysterix Turbine.
https://github.com/Netflix/Turbine/wiki/Getting-Started-(1.x)
It is available as a war/jar file.
Directory structure looks like this after downloading
$ ls turbine-4.0
conf lib LICENSE NOTICE README.txt site sql turbine-4.0.jar
How to get this installed . If I download tomcat and put the above contents in deploy directory , will it work .
I am new to JAVA and Tomcat. So any help to get this installed will be highly appreciated.
Simple Steps-
Download the war file from here. If you are an absolute newbie, go with version 0.5. The version 0.0.1 has weird behaviour where it gives IOException while running multiple application instances on the same machine.
You should then deploy the war file to your tomcat by just placing it in the webapps folder in tomcat and starting the server. If your war name is turbine.war, you should be able to view your aggregated logs at http://localhost:8080/turbine/turbine.stream?cluster={cluster-name}
Before deploying your turbine.war, make sure you configure the file path of archaius.properties in catalina.sh in bin folder in the tomcat. Something like-
CATALINA_OPTS="-Darchaius.configurationSource.additionalUrls=file:///home/mukulbansal/Downloads/oauth-stuff/turbine-archaius.properties"
The contents of turbine-archaius.properties can something be like-
turbine.aggregator.clusterConfig={cluster-name}
turbine.instanceUrlSuffix.user-write=/hystrix.stream
turbine.ConfigPropertyBasedDiscovery.{cluster-name}.instances={IP:port-of-application-producing-hystrix-event-stream}
turbine.InstanceMonitor.eventStream.skipLineLogic.enabled=false
More info can be found here.
I have a simple hello world java application I deployed, and in the new code I changed the output of the servlet to print some statements in a loop.
It works fine locally.
I uploaded the new .war file, stopped tomcat, deleted the old .war file in /webapps and the exploded folder.
Then I copied the new .war file, and then restarted tomcat.
It exploded the folder, but somehow the code is old.
Could it be caching the .war file somehow?
I did change server.xml and set autodeploy=false but not sure if that is relevant?
delete the work directory and restart tomcat.
Bit too terse sorry.
Tomcat will turn jsp into servlet source before compiling, some caching takes place in the work directory this may be what is causing it to happen.
It has been some time since I used Tomcat but I am fairly sure the structure was something like work/host/engine/context so you will probably find your stuff under work/localhost/Catalina/--web context--
I did change server.xml and set autodeploy=false but not sure if that
is relevant?
oO.
From the docs
This flag value indicates if new web applications, dropped in to the
appBase directory while Tomcat is running, should be automatically
deployed. The flag's value defaults to true. See Automatic Application
Deployment for more information.
I'd start there.
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]
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...
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