I use tomcat as web server,I want to deploy many same war file in tomcat server with different config. How to do this in the best way possible manner?
So I want to run tomcat server per each war application, my means is tomcat1 handle the .war1 in webapp and ... or handle all war files with one tomcat?which one is better?
Change the names of your war files and deploy
Use the same tomcat server, but copy and rename your web application to something different. For eg, the original application name app, copy and rename as following.
webapp -> app1
app2
app3
Running a different tomcat server for each war application might not be necessary.
Related
I am new to the world of J2ee using Tomcat, so pardon me for my noobness.
At Tomcat start-up, all the war files deployed gets enabled. What do I need to do if I want some of them to be enabled at start up and start the rest of the wars later as per my convenience? There should be something which tells tomcat to enable the wars right[modifying which I might set the start-up settings of an application manual/automatic like that we do for windows services in services.msc]?
What I'm looking for is, if there are 3 different apps deployed in tomcat, I should be able to instruct tomcat that at Tomcat start-up, only app1 should start. I will manually turn up app2 and app3 as and when I need it. Like configuring the start up of apps with options like "manual"/"automatic"
Thanks in advance.
I just packaged my maven web application into a war file, upload it to remote server which has installed the tomcat environment. After I unpacked my war file and put all files in the /webapps/ROOT directory, I run bin/startup.sh to fire up the tomcat.
This just works fine, but when I intend to change my web application and redeploy it on the server, I don't know how to do that seamlessly, that is to say, not letting the users who is using my website lose any request.
Could anyone give me some idea? Thanks a lot!
You can always use manager app coming with tomcat to deploy a war without bringing the website down, even from a remote machine using browser.
http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely
You may use reverse proxy as door of you site. After deploying your "second" war into Tomcat, you can change the configuration of reverse proxy and reload it. The reloading of reverse proxy is very speedy, so that it likes "seamless" re-deployment of Java web application. After the reloading of reverse proxy, you could un-deploy "first" war of application safely.
This way to re-deploy is especially useful if the application needs time for initialization(for example: including ORM, Spring Framework...).
There are few concerns about using multiple-war-at-the-same-time:
1) There will be two applications(although, temporary) running on your Tomcat concurrently, make sure there is nothing hazard about concurrent executing. For example: scheduled jobs
2) You need to confirm that there is enough memory on Tomcat to live with two web applications, or Tomcat may hang.
3) Be meticulous about Java.lang.OutOfMemory: PermGen Space problem
I have two war files WARA and WARB deployed in a tomcat, both use same log4j properties file. How to reset the log4j configurations in both war files through another stand alone application deployed in same tomcat without disturbing WARA and WARB? Is it possible to do?
If polling is an option you can use PropertyConfigurator.configureAndWatch().
More here.
If you need to do it manually the process is bit longer. On a high level its as follows.
Configure JMX for your application server / servlet container.
Write an MBean to trigger full reconfiguration.
Register the MBean in WARA and WARB.
Connect to the MBean server from the other webapp.
Invoke the MBean in WARA and WARB.
If you can provide more details on what software stack your are using I may be able to provide specific details on how to do the above.
not the best way , but make a jar file that contains properties file ,and place it tomcat lib folder ,all applications use same propertyfiles.
My system is divided to 2 or 3 servers architecture, and only one server has a webApp
Since we use javaMelody to monitor the webApp server, is there a way to use on a regular, no-
webApp JVM, and if so, how can we access the data
I would say include your application into a webapp (a war file for example) then deploy it in a server like Tomcat or Jetty. By the way, Tomcat or Jetty can be embedded.
Otherwise, there is currently no way to do this.
I know that when a war file is created of my web application, i have to deploy it, that is if i am using JBoss i have to copy it to deploy folder and if using WAS i have to install it.
But i want to know, When i start the server from where the server starts deploying my application. that is which is the entry point to start loading my classes, properties ,DB connections etc..
Thanks.
It's the web.xml file, which is known as the deployment descriptor. This is where you configure your servlets and filters. In particular, you map urls to servlets, and this is the entry point into your application. The classes are loaded on startup, before any requests are handled.
Here is a link to more information about deployment descriptors.