File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Why is it deploying in two contexts? I'm stumped Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Why is it deploying in two contexts? I Watch "Why is it deploying in two contexts? I New topic
Author

Why is it deploying in two contexts? I'm stumped

Claude Forkner
Greenhorn

Joined: Feb 19, 2006
Posts: 24
Hi all. I've been racking my brain on this for a good day and wanted to get some help. I have a tomcat 5.0.28 installation. I used the manager app to install my application. My application has a context.xml file. Here is what the context tag looks like inside of that:

<Context path="/software/data/myportal" docbase="portal">

It installed correctly through the manager app.

I then shutdown tomcat and restarted it. Now when I open the manager app, I see that there are two context entries listed: one for "/software/data/myportal" AND one for "portal".

Let me give some other useful info: the war file I uploaded is named portal.war. When it gets unpacked by tomcat, it creates a directory called webapps/portal

In server.xml I have autoloading off. Here is what that looks like:
<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true" autoDeploy="false" xmlValidation="false" xmlNamespaceAware="false"/>

Can someone help me figure out how to get it so it doesn't deploy two context's for the same app? I'd really appreciate it!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

I suspect Tomcat is creating one instance of the app triggered by your context definition, and another by default because of the presence of the war file in webapps.

But Ben is the expert on these matters...


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Claude Forkner
Greenhorn

Joined: Feb 19, 2006
Posts: 24
Thanks. I also want to mention that for a test I deleted portal.jar from the webapps folder, thereby just leaving the unpacked portal folder inside of webapps. I then stopped and started tomcat and it still deployed two context's.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Bear's got it.
If you shut off autoDeploy in the host entry in server.xml It won't do this.
http://tomcat.apache.org/tomcat-5.0-doc/config/host.html


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Claude Forkner
Greenhorn

Joined: Feb 19, 2006
Posts: 24
In my first post I showed the entry I'm using for host. It looks like I have autodeploy shutoff, yet it is still doing this.... There's got to be something crazy I'm missing....
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Sorry, didn't notice that.

Have you tried without the docBase attribute in your Context file?
Claude Forkner
Greenhorn

Joined: Feb 19, 2006
Posts: 24
Yes. When I take out the docbase, it actually has a problem starting up the "/software/data/myportal" context, but starts the /portal context ok. When I change the docBase back to docBase="portal", it works again.
Claude Forkner
Greenhorn

Joined: Feb 19, 2006
Posts: 24
I may have an uneducated guess here. When tomcat starts up it probably first checks to see what's in the webapps folder. It probably sees the "portal" folder unpacked there and deploys that under the context "/portal". THEN it probably sees that there is a portal.xml file in the conf/catalina/localhost folder and it does what that says - deploy into context "/software/data/myportal" with the docbase in /webapps/portal. So it effectively deploys the same app twice into two different contexts'. This is just what appears to be happening.

I bet if the app in the webapps folder was named "/software/data/myportal" (which obviously isn't a valid name for a folder), that it maybe would only deploy one time? Another thing that might help this is to completely move the portal app out of the webapps directory. Maybe that would work.

I still want to know if it's possible to configure this the way I have it without two context being created.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is it deploying in two contexts? I'm stumped