Tomcat doesn't load the docbase configure file


I put a docbase configure file in \tomcat\conf\Catalina\localhost\, the file as simple as


if tomcat starts via startup.bat (in dos command prompt), the above file loaded, and application loaded; if using IDEA to start tomcat, tomcat can start but the docbase file doesn't seem to be loaded, and the application wasn't deployed, even though I set the IDEA start tomcat script to startup.bat.

Can any one figure it out?




There's no need to put the XML file in your Tomcat installation.

Just put a file called 'context.xml' in the META-INF directory of your web project (next to the WEB-INF). Tomcat will pick it up and use it.

The benefit is that then the file becomes part of your (versioned) source tree, instead of some separate file 'somewhere on your local disk'. All developers on the same project benefit from it.


Thanks for the tip.

However, by placing my.xml file in that /localhost folder, tomcat will know where to pick up my web app code, and the key thing is that, the source code can be placed in another dirve, doesn't even need to be within tomcat's folder; thus in my case, tomcat doesn't know there is context.xml in my web, as it doesn't look at the specified folder.



Isn't that the same with the context.xml in the META-INF folder?

All I do is tell IDEA to run my exploded archive on Tomcat. IDEA starts Tomcat and deploys the archive (automatically, no configuration) and Tomcat picks up the context.xml, where I typically have the DataSource configured.

>thus in my case, tomcat

doesn't know there is context.xml in my web, as it
doesn't look at the specified folder.

I don't understand what you mean by this. Instead of hard-copying your WAR to Tomcat by hand, you now hard-copy a context.xml to Tomcat by hand. It might load quicker, but it's essentially the same. All I do is let IDEA copy the context.xml automatically on deployment. I can switch to any other Tomcat instance directly, without having to copy any files.



The following is a detailed description of my case:

In IDEA, configure local server Tomcat, then start tomcat;
IDEA then created a folder named
C:\Documents and Settings\me\.IntelliJIdea60\system\tomcat__8dc3b62e\conf\Catalina\localhost,
in which there is only a file manager.xml

but within my tomcat installation folder,
C:\tomcat5\conf\Catalina\localhost, I created a file named my.xml,
which has

if tomcat started in command line or by eclipse, tomcat will deploy all web codes (including all classes, jsp..) in C:\my_project\web folder, there is no need to make a war file at all.

but IDEA fails to copy my.xml to the folder it created, even I hard copy the file to that folder, whenever using IDEA to start tomcat, IDEA just removes that file.

not sure it's IDEA's bug or unpleasant feature at this point.


Isn't this a much too complicated way to work with Tomcat?

Just let IDEA handle it.

Sure, deploying from Eclipse won't work then, but who uses that anyway? ;)

Using a combination of IDEA and Maven works fine. I maintain 1 IDE-less build with Maven. On top of that, anybody can put his/her own personal configuration in her/her favorite IDE.

I see that you're using IDEA 6. IMHO IDEA 7 has much to offer, especially in the Web department!


Please sign in to leave a comment.