Tomcat 7 skip specific folder loading from webapps - deployment

I am having two .war files, say webapp-A.war and webapp-B.war of two different projects. When I start tomcat, it deploys these wars and two folders are created in webapps directory i.e. webapp-A and webapp-B.
When I start tomcat both these folders are scanned and loaded. This increases the startup time of tomcat and consumes more memory. I dont want to work on both at a time but I must be able to switch between any two.
So, is there any way to skip loading of webapp-B when I am working on webapp-A considering both being present in webapps directory?

When working with webapp-A, go to TOMCAT_HOME/conf/server.xml and update the host tag with attribute 'deployIgnore' as shown below
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true" deployIgnore="webapp-B">
....
</Host>
Start your tomcat server, webapp-B will not be deployed :)
This is my very first answer on stackoverflow btw, hope it helps, I signed up to help you.

Related

Eclipse tomcat doesn't deploy web applications automatically

Hello all: We have done all of the eclipse server configuration (adding tomcat-juli.jar by using eclipse server configuration ) . and we spent two days searching in the internet and testing different version of tomcat and different pc , after that we realized that eclipse can’t deploy web application to tomcat service automatically , finally one thread of stackoverflow suggest to build the war manually by right clicking on the project and choosing Export -> war file , as you know it is not the solution . I would much appreciate if you suggest any solution
My suggestion would be to install Tomcat separately and build your WAR file with an ANT script, which will automatically deploy your War file to $TOMCAT_HOME/webapps. In $TOMCAT_HOME/conf/server.xml, make sure you have unpackWARs and autoDeploy set to "true":
<Host name="localhost"
appBase="webapps"
unpackWARs="true"
autoDeploy="true">

Adding server-specific options to an Eclipse-managed Tomcat instance (in server.xml)

How can I make sure that the server.xml which Eclipse produces for every separate project that relies on Tomcat, will always contain a specific option, which I added manually?
I'd like to add a bunch of <Context> mappings to the server.xml file. I tried doing that in the server.xml in the main tomcat dir - didn't work.
Then I saw that Eclipse builds a temporary folder for every project that uses Tomcat. This folder also containes this server.xml file. I edited it, and voila, it worked. However, soon after that the same file got updated by Eclipse, with the original data that it contained.
It is not very efficient to manually copy and paste the code every time before I run/restart tomcat. I hope there is a more permanent way.
Let's assume you have configured tomcat 5.5
If you have configured your tomcat server in eclipse using all default options, you want to edit the server.xml located at WORKSPACE_LOC\Servers\Tomcat v5.5 Server at localhost-config\server.xml

JBoss 4.2.3 EAR and Apache 2.2 virtual hosts with jk_mod serving blank white page

I have an EAR file I am trying to deploy alongside various WAR deployments on JBoss 4.2.3
The individual standalone WAR deployments are all working fine and are just a copy of the same application that is contained inside the EAR but the EAR deployment and it's included WAR(s) does not work correctly.
I am receiving a blank white page in the browser when I visit the virtual host that the jboss-web.xml is configured to associate with this EAR. The other virtual hosts associated with the standalone WAR deployments all work fine and are configured the same way.
I get no errors on startup and JBoss reports that the site was started. I have a jboss-web.xml file in the WAR's WEB-INF that ties it into a definition from server.xml. This works on every other type of configuration except the EAR. I keep getting just a white page, as if JBoss can't connect the WAR in the EAR to the host or maybe the WAR isn't starting right or I have some config wrong here.
When I fire up JBoss it creates the flex and railo directories in webwar1.war/WEB-INF as well as a railo-server directory as railo.ear/lib/railo-server but still just serves me a blank white page.
Here is where I stand...
I have a set of shared Railo JAR files are located in /JBoss/server/default/deploy/jboss-web.deployer/railojars/lib (I have told jboss-service.xml to include this as a classpath)
My site1.WAR and site2.WAR files are in the deploy folder and each contain an index.cfm and a WEB-INF with web.xml and jboss-web.xml mapped to a virtual host. They each use this shared Railo JAR instance and run perfectly. The sites I've configured in server.xml with a docPath and appPath to an outside folder use this shared JAR installation and run perfectly. Everything is good with this.
If I place a railo1.war, railo2.war, etc in the /JBoss/server/default/deploy folder (the full WAR with Railo lib folder) those sites use the Railo instance contained within the WAR. This is also great.
So, my only problem left is this:
under /JBoss/server/default/deploy I have created railo.ear
Inside railo.ear is:
META-INF which contains application.xml with:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN" "http://java.sun.com/j2ee/dtds/application_1_2.dtd">
<application id="RailoInstance1">
<display-name>Railo3</display-name>
<description>Railo3</description>
<module id="Module1">
<web>
<web-uri>webwar1.war</web-uri>
<context-root>/webwar1</context-root>
</web>
</module>
</application>
It also contains webwar1.war which contains: index.cfm and WEB-INF
WEB-INF has has web.xml, lib and jboss-web.xml
jboss-web.xml looks like this:
<jboss-web>
<context-root>/</context-root>
<virtual-host>foo3.com</virtual-host>
</jboss-web>
From server.xml:
<Host name="foo3.com">
<Alias>www.foo3.com</Alias>
</Host>
foo3.com is using jk_mod to send to JBoss via a virtual host from Apache. The other two sites (foo1.com, foo2.com) which are mapped to WAR deployments are configured the exact same way and work fine.
The WEB-INF includes the lib folder so I would expect this webwar1.WAR instance to use the Railo JAR files contained in that lib folder. The problem is that when I start JBoss, all of my other sites configured their various ways work, but the site in webwar1.war is not coming up. I simply see a white page in the browser.
So, either the jboss-web.xml in WEB-INF in the webwar1.war file is not being connected to the defined in server.xml or something else is going wrong here. My other standalone WAR installations and the shared JARs sites all see their respective descriptors as marked in their jboss-web.xml and have the same content as this deployment.
So, I'm just trying to figure out what I need to do to get this last EAR configuration to work.
The way I am trying now seems like each WAR would try to use the JAR files it contains, but I want to have one set of shared JAR files for the whole EAR and then each WAR file in the ear use those JARS.
I want to be able to have webwar1.war, webwar2.war, etc under this one EAR configuration so I have moved the lib folder out of webwar1.war/WEB-INF/lib and into railo.ear/lib
I would love to set it up this way, but I can't even get one WAR with its own JAR files to load up right when inside the EAR. I have tried this new configuration and get the same blank white page in the browser.
Any ideas?
JBoss gives me no errors. Another odd thing is that I don't get an error from Apache like I do when I try to visit a site that is improperly configured and did not start up. And if I visit a site that is not set up as a host in JBoss and I am redirected via jk_mod to JBoss, I see the JBoss default page. I am not seeing this default page when I visit the virtual host associated with this webwar1.war in the railo.ear, so JBoss must know that it's supposed to do something with the domain / virtual host or else it would show me that default JBoss page. Instead I see a blank white one.
I should also mention that this works on JBoss 5.1. The railo.ear configured the exact same way latches onto the virtual host and works properly.
Help? Thanks!!!!
Sounds like a complicated job; the folks on the railo-users mailing list might be able to help : http://groups.google.com/group/railo
Railo also has a professional services team who are ace : http://www.getrailo.com/index.cfm/contact-us/

tomcat deletes exploded webapps

Each time I shut down Tomcat server, it deletes my exploded webapp. What do I have to do to stop that? It's really inconvenient constantly copying it again under the webapps dir.
This can happen with Tomcat 5 if you have a WAR under your webapps directory. Tomcat has 3 modes of deployment,
Context fragment. A XML file under conf/Catalina/[host]
WAR. A file ended with war in appBase (normally webapps)
Directory. A directory (normally exploded WAR) in appBase
Looks like you are mixing 2 & 3 and Tomcat is confused. If you put war under webapps, Tomcat will explode it automatically. If you want explode it yourself, don't put WAR under webapps and Tomcat should leave your directory alone.
You can also run WAR without exploding it by adding this to your Context,
unpackWAR="false"
I've never seen it do that.
One option would be to place the exploded webapp in a directory outside of the Tomcat install, then add a deployment descriptor referencing it in the conf/Catalina/localhost directory. I typically work that way, and Tomcat has never deleted any files on me!

Deployment of Web Application to a Running Tomcat

I would like to collect some best-practices on deployment of a web-application to a running Tomcat. Not long ago I had to describe the deployment process of our web-application and the process appeared rather confusing.
Say, we have an application in a WAR file (foo.war) correctly configured and not requiring additional configuration. In this case, the deployment process is rather easy:
Copy the foo.war file to the $CATALINA_HOME/webapps directory. If the application starts correctly, the application will automatically deploy to $CATALINA_HOME/webapps/foo directory.
To undeploy the application:
Remove the foo.war file from the $CATALINA_HOME/webapps. If the application unloads correctly, it will be unloaded and the $CATALINA_HOME/webapps/foo will be removed.
Now I want to override some context parameters in my running application. Having read the docs, all I need to do:
Create a context.xml file called foo.xml
Copy the file to the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory.
Unfortunately, that did not work: the application would not restart. Empirically, we found out that the only working solution is when the war file is deployed to a location outside the $CATALINA_HOME/webapps.
Besides, the default values of the configurable context parameters in the WAR file should be specified in the web.xml, since context.xml in the WAR file is not read when there is a context.xml outside.
Here is an easy example of the foo.xml:
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/path-to-deployment-directory/foo.war">
<Parameter name="myparam" value="newvalue" override="false"/>
</Context>
Be sure to specify override=false for the parameter if you want the 'newvalue' to override the value specified in the WAR's web.xml. This was not obvious for us.
Thus, to deploy an aplication to a running Tomcat:
Create a context.xml file called foo.xml
Copy the file to the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory.
Copy the foo.war to the location specified in the docBase of the foo.xml; the application will deploy automatically.
To apply new context parameters:
Add the parameter values to the foo.xml and save the file; the application will re-deploy automatically.
To undeploy the application:
Remove the foo.xml from the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory
Note that removing the foo.war will also work, but will remove the foo.xml as well.
By now, I have the following questions:
Is it a best-practice at all to deploy a web-application without stopping the tomcat? I heard an opinion that deployment to a running tomcat is never needed since people run each application in a separate tomcat.
Is it a good idea to copy WAR files to $CATALINA_HOME/webapps or they should better be kept in a separate location?
How can I configure an application deployed to $CATALINA_HOME/webapps
Why there is no INFO line in the catalina.out for deployment of an application and there is one for undeployment? Is it configurable?
On question (1), Tomcat works great for deploying servlets into a running server. There may be concerns w.r.t. security or possibly D.O.S. or provisioning reasons why you would have separate server instances.
You have the flexibility to do either way, but it is often more convenient to deploy to an already running server. This is a BUILT-IN feature in the servlet architecture. :)
For (2), again it is at your discretion where you you want to put WARs. It sounds like you already have it configured a non-standard (non-default I should say) way. Check your server.xml file for the settings in your server instance(s). Check for attributes like unpackWARs and autoDeploy.
For (3) and (4), plus your (1,2) questions, it might be a good idea to consult the Tomcat docs for your version of Tomcat on its deployment model. You should be able to use the same docs to figure out how your server has been configured.
See Tomcat Web Application Deployment in the Tomcat manual, adjusting for your version of Tomcat.
One solution would be to use the manager application. If you decide that is safe to use it, then you can easily deploy, start, stop and undeploy applications:
http://localhost:8080/manager/deploy?path=[context_path]
http://localhost:8080/manager/start?path=[context_path]
http://localhost:8080/manager/stop?path=[context_path]
http://localhost:8080/manager/undeploy?path=[context_path]
There are ant tasks that can help you with these.
I am guessing, but do not know for sure, that stopping and starting an application will make it reread the context.xml.
Regarding your second question, I believe it is better for maintenance reasons to keep the war files in the webapps directory.