I am pretty new to Apache/Tomcat configuration. Here is my situation:
We have more than two thousands applications in ten categories under on Tomcat server. Originally, those two thousands applications are all under Catalina_home/webapps/. I am asked to organize those applications into categories during our server migration. Ideally, when Apache sees a request with URI like
It worked. But, if I do it this way, I will need to add 1,300 <Context> tags into server.xml. Each tag is only for one application. Is it too much?! Did I do something wrong?
DON'T put them into server.xml! That's been discouraged for a long time.
You can create a set of XML files with one Context in each file and place them into the TOMCAT_HOME/conf/Catalina/localhost directory. Please note, however, that the webapp context names will be defined based on the name of the context file, NOT on the "path" attribute of the Context element ( ). I've never tried subdirectories on this directory, however, so I don't know if that will work.
Customer surveys are for companies who didn't pay proper attention to begin with.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
1
More out of curiosity than because I have a different approach to suggest: are these functionally different applications, or is it an attempt to establish a form of multi-tenancy?
Tim Holloway wrote:DON'T put them into server.xml! That's been discouraged for a long time.
You can create a set of XML files with one Context in each file and place them into the TOMCAT_HOME/conf/Catalina/localhost directory. Please note, however, that the webapp context names will be defined based on the name of the context file, NOT on the "path" attribute of the Context element ( ). I've never tried subdirectories on this directory, however, so I don't know if that will work.
Thank you, Tim!
Here is the "myapp1.xml" file and I put it under TOMCAT_HOME/conf/Catalina/localhost /category1/myapp1 directory:
<?xml version="1.0" encoding="utf-8"?>
Still, the servlet of myapp1 cannot be found. Do I need to add more stuff in it? If you could post an example of the context.xml file, that will be great. By the way, the file name of the XML file should be "context.xml" or "myapp1.xml"?
Then, I tried to put the configuration inside server.xml like this:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
Then it works and I saw a directory is created under /catalina_home/work/Catalina/localhost/category1_myapp1/
I tried to call my context XML file category1_myapp1.xml, it did not work either.
Again, thank you so much for your help! Very much appreciated!
If you name your context XML file "context.xml", the webapp will respond to the URL context "context". If you name the context.xml file "webapp1.xml", the webapp will respond to the URL context "webapp1". The context path within the context XML file is ignored; the name of the context XML file itself is all that's used.
The only thing worse, however, than putting Context elements in server.xml is putting 2000 Context elements in server.xml. It makes server administration a nightmare. So I repeat:
DON'T put the Context definitions into server.xml!
Julia Ding
Greenhorn
Joined: Apr 02, 2011
Posts: 5
posted
0
Tim Holloway wrote:If you name your context XML file "context.xml", the webapp will respond to the URL context "context". If you name the context.xml file "webapp1.xml", the webapp will respond to the URL context "webapp1". The context path within the context XML file is ignored; the name of the context XML file itself is all that's used.
The only thing worse, however, than putting Context elements in server.xml is putting 2000 Context elements in server.xml. It makes server administration a nightmare. So I repeat:
DON'T put the Context definitions into server.xml!
Yes, I agree with you. It will be a nightmare. I am desperately seek another solution!
I created a category1#myapp1.xml in CATALINA_HOME\conf\Catalina\localhost\
I got a "Fatal Error" right after I restarted tomcat:
INFO: Deploying configuration descriptor category1#myapp1.xml from CATALINA_HOME\conf\Catalina\localhost
Apr 5, 2011 3:34:36 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
Here is the content of the category1#myapp1.xml file:
Ulf Dittmer wrote:More out of curiosity than because I have a different approach to suggest: are these functionally different applications, or is it an attempt to establish a form of multi-tenancy?
These are group of legacy applications developed during 1999 - 2000. It is an attempt to establish a form of multi-tenancy as you have guessed. Switched from few Application Servers, but the application themselves stayed pretty much as they were. No plan to rewrite them yet. I wish they do.
I am still struggling with the configuration. I have created an XML file called category1#myapp1.xml
in CATALINA_HOME\conf\Catalina\localhost\category1#myapp1.xml
I got a "Fatal Error" right after I restarted tomcat:
----------------------------------------------------------
INFO: Deploying configuration descriptor category1#myapp1.xml from CATALINA_HOME\conf\Catalina\localhost
Apr 5, 2011 3:34:36 PM org.apache.tomcat.util.digester.Digester fatalError
SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
----------------------------------------------------------
Here is the content of the category1#myapp1.xml file:
--------
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="CATALINA_HOME/webapps/category1/myapp1"
reloadable="true" crossContext="true">
</Context>
--------
What could be wrong with my configuration?
Thanks.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
1
posted
1
SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
Is usually due to extra characters before the <?xml start - probably accidentally introduced by editing the file.
SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog.
Is usually due to extra characters before the <?xml start - probably accidentally introduced by editing the file.
Bill
Thank you, Bill.
I tried manually type all the contents of this xml file to avoid paste extra characters. But still, it gives me the same error. Sigh.
- Julia
Chandra Barnett
Greenhorn
Joined: Apr 08, 2011
Posts: 1
posted
0
Interestingly, I'm having this problem too. I dug around in the logs and noticed that in my case, the file Tomcat is failing to parse isn't myapp.xml. It seems to be a generated temp file in the same directory, called ._myapp.xml, which I'd presume is based on the content of myapp.xml.
It's a mystery to me why Tomcat would generate a file it then can't parse. Does anybody know what files Tomcat references when creating this temporary file?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Tomcat Configuration with more than 2,000 apps