I am using Tomcat 7.0.50 server.
How can I delete the tomcat cache memory without restarting the server?
You can find how to delete Tomcat Cache here
You can delete the "work" folder under Tomcat Home. Even if it does allow you to delete the folder while tomcat is running, I would guess it will cause troubles to your running site.
If your Tomcat installation is configured to have a ROOT directory for your webapp, you will have to find a path like
/tomcat/base-myapplication/webapps/ROOT/
which contains your deployed webapp.
Just delete everything inside, including sub directories META-INF, WEB-INF, VAADIN etc., and then re-deploy your webapp. This worked for me even with tomcat running, but it doesn't hurt to restart tomcat after deployment.
Related
I have done a maven project in my eclipse and was generated a war file in my system.I want to run that war file in another system without using eclipse.Is it possible to run without downloading JDK and eclipse..
You can refer the following link to run WAR with tomcat -
Deploy war in Tomcat
or a video - Deploy the war in Tomcat Video
Well, if this suffice your requirement, it is good else please mention the specific issue, if there is that you are facing.
The .war file stands for 'Web Archive'. This is a packaged web application, which can be run by an Application server (Examples: Glassfish / Tomcat / Weblogic, Wildfly)
The process of making an application server run the .war file is called Deployment.
For example, a .war file can be deployed to Tomcat application server (I.E., made to run by tomcat) by simply copying the .war file to the /webapps folder of Tomcat.
Here are the steps to deploy .war file on Tomcat:
Step 1: Build the .war file for the web application.
Suppose that the .war file is "my-app.war".
Verify that the my-app.war file contains the following:
/WEB-INF/ folder and
/WEB-INF/web.xml file
Step 2: Verify the following settings in Tomcat config.
(This step can be skipped if Tomcat was installed with default settings)
autoDeploy : true
unpackWARs : true
(Note: These are default values. These will be set to true if Tomcat is installed with default settings.)
Step 3: Remove any conflicting entries or stale entries from Tomcat config.
For example, if the new app to be deployed is 'my-app', then make sure that the existing config of Tomcat does not have 'my-app' already registered for another application.
This can be checked by trying to browse http://localhost:8080/my-app.
If this link works, then it means that the name 'my-app' was already taken.
Another way to find if the name already exists:
If Tomcat is installed in "C:\Tomcat8",
then the registration for 'my-app' can be found at
C:\Tomcat8\conf\Catalina\localhost\my-app.xml
Step 4: If steps 1, 2, 3 are cleared, then copy the my-app.war file to 'webapps' folder of Tomcat.
If Tomcat is installed in "C:\Tomcat8",
then the my-app.war file can be copied to
C:\Tomcat8\webapps\my-app.war
Step 5: Wait for Tomcat to automatically detect my-app.war file inside webapps and extract it to webapps/my-app folder.
Tomcat usually does this automatically. However, this process may sometimes not work either due to file permissions (Example: User does not have write permissions on webapps folder, or Tomcat is installed to C:\program files, which has read-only permissions) or due to folder being locked.
Try restarting the Tomcat service to fix the issue.
If restarting Tomcat does not fix the issue, then verify permissions of Tomcat service and re-install / execute Tomcat with the necessary permissions.
More information:
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Top-5-ways-to-deploy-a-WAR-file-to-Tomcat
https://tomcat.apache.org/tomcat-8.0-doc/deployer-howto.html
https://dzone.com/articles/how-deploy-war-file-using
https://developer.jboss.org/thread/268260
In my Eclipse I have created a Dynamic Web Project, which runs on a Tomcat7. If I modify and save any file in the project, eclipse automatically republishes the project on the Tomcat (copies files in a temporary Tomcat directory) and restarts the Tomcat. This means I loose all sessions.
Is there a way to tell eclipse to automatically copy modified files in the Tomcat directory but only restart the Tomcat when manually restarting Tomcat?
Even better would be: Copy any modified files in Tomcat directoy but restart Tomcat only when I modified a file with extention *.java
Thanks for your help!
You should start Tomcat in hot deploy mode (supported only in debug mode). There is a good guide for this here.
It is possible to deploy web applications to a running Tomcat server.
If the Host autoDeploy attribute is "true", the Host will attempt to deploy and update web applications dynamically, as needed, for example if a new .WAR is dropped into the appBase. For this to work, the Host needs to have background processing enabled which is the default configuration.
autoDeploy set to "true" and a running Tomcat allows for:
Deployment of .WAR files copied into the Host appBase.
Deployment of exploded web applications which are copied into the Host appBase.
Re-deployment of a web application which has already been deployed from a .WAR when the new .WAR is provided. In this case the exploded web application is removed, and the .WAR is expanded again. Note that the explosion will not occur if the Host is configured so that .WARs are not exploded with a unpackWARs attribute set to "false", in which case the web application will be simply redeployed as a compressed archive.
Re-deployment of a web application if the /WEB-INF/web.xml file (or any other resource defined as a WatchedResource) is updated.
Re-deployment of a web application if the Context Descriptor file from which the web application has been deployed is updated.
Re-deployment of a web application if a Context Descriptor file (with a filename corresponding to the Context path of the previously deployed web application) is added to the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory.
Undeployment of a web application if its document base (docBase) is deleted. Note that on Windows, this assumes that anti-locking features (see Context configuration) are enabled, otherwise it is not possible to delete the resources of a running web application.
Note that web application reloading can also be configured in the
loader, in which case loaded classes will be tracked for changes.
For more details, you can follow this tutorial
Related Link:
Tomcat Deploy Procedures
Hot Deployment
How to configure hot deploy in Eclipse?
I use tomcat 7 via Intellij IDEA 13. Tomcat home is /usr/share/tomcat7, tomcat base is /var/lib/tomcat7. /var/lib/tomcat7/webapps contains single folder ROOT where I can find initial tomcat webapp with different instructions.
So where can I find my local deployed webapp? or where is the server root folder?
/var/lib/tomcat7/webapps is the place where you should find your local deployed app, right next to the ROOT folder you see.
If it is not there, then there might be some problem in your deployment.
Are you sure you have deployed it correctly?
I have a Java Web project (Struts + Spring) working perfectly in my localhost. I have to deploy it on my website, but the Tomcat Manager interface given by the webhost says it cannot upload a WAR file due to safety reasons. When contacting the tech support I was told it is not possible to upload a WAR and that I should try deploying my project by uploading the files directly (I have FTP access).
My problem is that no one at the tech support gave specific instructions on where I should put my project files (I don't know if it should be on de same folder the WAR would be sent to) neither how to start/stop it (Will the Tomcat Manager recognize it once I upload the files?).
You can always try to upload a war file to webapps folder of tomcat.
if tomcat is running with autoDeploy set to true it will auto deploy your application.
i think that the same will happen if you upload the exploded war to the webapps, the context will be the name of the directory you put your files in.
Just place your apllication's root folder to the Tomcat's directory webapps and configure tomcat to auto deploy. Restart the server and your application will be deployed.
You transfer the files to the same place as the war file would go - but just as an expanded war.
Whether or not tomcat will recognise that the files have changed depends on the configuration of the tomcat server. I'd just give it a go - transfer the files and see what happens. If it doesn't pick up the changes then you'll need to find out from tech support how to restart tomcat.
I need your help. I am facing unusual problem dealing with Tomcat classloader. I have a WAR and inside the WAR there's a third-party JAR that has native methods. The WAR successfully deployed in a development server for the first time and had been running for about 3 months.
Last week, I did some code refactoring and wanted to deploy the updated WAR, so I delete the old instance and deployed WAR. But now after the redeployment, I always face NoClassDefFoundError. I redeploy the WAR for several times, and the result is same, NoClassDefFoundError.
Oddly, when I deployed the updated WAR in my laptop also use Tomcat, it works fine. My co-worker also tried to deployed in his laptop using Tomcat, it works fine.
I had deleted files inside work directory, but still NoClassDefFoundError appeared. I had turn off the Tomcat, delete the instance on webapp folder, copy the updated WAR again in webapp folder, turn on Tomcat again, but still the error shows up.
What's wrong with the Tomcat in the development server?
You can only register a native library once in the lifetime of a JVM. I suspect that when you updated the WAR, it tried to register the native library again, that failed and that in turn lead to the NoClassDefFoundError. That a restart of the Tomcat server fixed it is consistent with this theory.
If you ship a WAR that contains a native library then the safest course is to restart Tomcat everytime you need to update the app.