I am working on a project and the project is in running state. As there is some issue in a java file and I have resolved that issue. But I don't have an idea how to update that particular java file in war file which is deployed on the company server.Please help me out.
Tomcat doesn't support hot deployment. SO you have to restart Tomcat anyhow.
And if you are going to restart it, either replace the .class file(the one which u have changed) or generate new war and then retart Tomcat. Your changes will be reflected.
Update : for hot deployment http://www.mulesoft.com/tomcat-deploy-procedures
You can replace your new java .class file into your extracted project folder under tomcat
http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Reload_An_Existing_Application
This will cause a service interruption anyway, but probably still shorter than restarting the whole server.
Note that this will only works when the web application is deployed from an unpacked directory, otherwise you will have to undeploy and deploy again the web app.
(http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html#Undeploy_an_Existing_Application)
Related
I have an application running in a tomcat container in Windows environment.
When I have to update the application, the tomcat windows service is stopped, new ROOT.war file is copied in the webapps folder and tomcat service is restarted.
Sometimes it happens that the ROOT.war extraction fails and the extracted ROOT folder has only few subfolder and few files. Obviously the following application startup fails.
To solve this problem I have to stop tomcat, delete ROOT folder and run in again to let tomcat re-extract the ROOT.war again from the beginning.
I cannot understand why sometimes it happens and sometimes no. However, it makes impossibile to me to create an automatic update. It is too risky.
Do you have any idea why it can happen?
Resources are not released. So, when you try to update the existing war file, tomcat is not able to delete the older files before deployment/redeployment.
To resolve this issue, ensure that:
The application is not open/running on web browser.
You're not stuck in debug mode when you click on update.
All processes/requests are completed before redeployment.
All files/streams are closed within the code.
When all else fails, you may want to stop the application. Then update. There are ways to stop applications on tomcat using command line, batch files, etc. You can then automate the process.
If you want a more reliable way to do this, you may use jrebel or a free version of the same. There are other ways to update code. Basically, standalone tomcat is not worth anything more than a development server.
Remark: if you are updating the application while Tomcat is running you need to either:
use Tomcat Manager to deploy it,
call tryAddServiced (before Tomcat 9.0 addServiced/isServiced) before any modification to the webapps directory and removeServiced afterwards. This can be done through JMX on the bean Catalina:type=Deployer,host=<your_host_name>,
replace the WAR file (almost) atomically: e.g. deleting the old one and moving (renaming) the new one from another location on the same filesystem should work.
which prevents Tomcat from immediately deploying the application until the copy operation is finished.
To prevent the OS from locking the files in the webapps/ROOT folder you have two options:
Use antiResourceLocking="true" as already suggested by Svetlin, which basically forces Tomcat to copy webapps/ROOT to a uniquely named temporary directory before deployment (the copy will be locked, webapps/ROOT will not),
Use parallel deployment by naming your WAR files: ROOT##001.war, ROOT##002.war, etc. This is basically an explicit version of the antiResourceLocking feature with the additional advantage of letting clients transition fluently between the old and new app version.
My team and I originally had a server running through Eclipse (Java EE), but wanted to switch it to running on the Tomcat 7.0 service found in Windows 2008 R2. We are completely clueless on what files to put where in the Tomcat folders found in program files. The entire server has gone down and we can't go back to the original setup. Any help is appreciated. All we're asking is where do we put our JSP/ROOT ect folders in the Tomcat program files.
Copying JSP files are not good idea rather you can package your jsp file into an archive file called WAR file. You can export your project from Eclipse IDE as a WAR file.
After creating the WAR file (.war), you need to find out tomcat installation directory and its called tomcat HOME. Now you just need to copy the WAR file into the following folder:
{TOMCAT HOME}/webapps/<project>.war
I'll add to the answer.
If you have folders of running applications from before you can put 'em under
{TOMCAT HOME}/webapps/
war file will un-zip after you start the service.
once the war is un-zipped, you can delete it, but only after you stop the service for the first time after war deployment.
I use IntelliJ IDEA 13.1 and have configured a Java web application to deploy to a Tomcat server. After starting the server, if I go to my tomcat webapps folder, I couldn't see the exploded version of my web app there.
So, do IntelliJ keep the deployed files somewhere else other than the tomcat webapps folder?
Btw, I did check the answer for this question: Where is my app placed when deploying to Tomcat?. But I couldn't find my deployed files in the ${dir.to.idea.project}\YourWebApp\out\artifacts folder either.
Any help?
Typically the exploded war is built in your web-module's target directory (called either target or out by default depending on whether you use maven or not), with a .war extension on the folder. Tomcat (and most other application servers) are pointed at this directory.
However, you shouldn't, in most cases, need to know this. When you make a change to your code, IntelliJ will update the contents of the exploded war for you. You shouldn't really change it yourself, otherwise the code will get out of sync with the deployed app.
I'm using gradle and the deployed wars are in project_root/.build/package/modules/.
If this doesn't help,here is how I found out.
While the project is running I run the gradle clean task, then tomcat kindly complained
java.io.FileNotFoundException: /project_root/.build/package/modules/exploded/my.war/WEB-INF/lib/xxx.jar (No such file or directory)` How sweet of it.
I hope this helps!
I have got a war file generated using Maven and it works perfectly fine when i manually deploy it on the tomcat server.
However, the war file was generated using Maven on eclipse and when i try deploying this on the server using eclipse, it just doesn't act. The tomcat server starts perfectly fine. What I do is : Right click on the Tomcat Server 7.0, then Add/Remove Project and add it to the server.
The problem is when I deploy and publish it on the server and nothing happens after that.
On trying to access it, it says - The required resource is not found
Eclipse doesn't deploy the WAR. Instead, it knows how Tomcat works and deploys the exploded WAR.
The next step is to look into the webapps/ folder of Tomcat to make sure Eclipse really has deployed something.
If that looks ok, you need to look into the Tomcat log to see why it doesn't like the deployed web app.
Most of the time, there is old code which is somehow stuck in Tomcat, so Tomcat can't undeploy the old version. If that's the case, stop Tomcat, delete the app manually and try again.
There were certain jars required in specific versions for the application to work. I was usin the maven supported versions. I have got it to work adding them directly in Tomcat's lib folder for time being and the application now works. (Anyways i need to look to get them configured now on the maven)
Also, i guess installing the plugin for m2e - eclipse.org/m2e-wtp helped as well. Thanks #Aaron Digulla for the inputs.
The last Java project I was on used Tomcat as the server my new Java project is using JBOSS.
I am a front-end designer that needs to make frequent and rapid changes to JSP, HTML, CSS and JS files. Here is a rundown of what is happening...
In Tomcat, when an app is deployed into the webapps directory, it is automatically exploded. From there I can stop the server, create symbolic links pointing from the webapps/myapp directory to my GIT repository, ~/somedir/myapp and then restart tomcat. This way I am always working on my local repository and when I make a change in my IDE then go to the browser and refresh, the changes are there instantly.
In JBOSS, things are a bit different. When an app is deployed into the standalone/deployments directory, it remains compressed as a .war file.
I have tried expanding the .war file manually and renaming the folder to myapp.war and that seemed to work, however, JBOSS still re-deployed the app once it noticed there was a change to one of the files, which kinda defeats the purpose.
I have been searching for a couple of days now before asking this question as a last resort.
Does anyone happen to know of a way to accomplish in JBOSS what I was able to accomplish in Tomcat?
Thank you in advance!