Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy multiple webapps with application specific config in Tomcat from Eclipse

I have a Tomcat 7 Server in Eclipse with two webapps a and b and need to find out how to have application specific configuration files for tomcat that works with Eclipse.

Now I want for each webapp a custom config file, like described here: Apache Tomcat: multiple webapps. So I created a <TomcatDirectory>/conf/Catalina/localhost folder and put the a.xml and b.xml there. This works fine when I run Tomcat from command line.

But where have I to put the application specific configuration files a.xml and b.xml when I run Tomcat from within eclipse?

I already tried to put the files in Eclipse in <EclipseWorkspace>\Servers\<ServerName>\conf\Catalina\localhost\ but WTP does not copy this files to <EclipseWorkspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\Catalina\localhost

like image 414
David Avatar asked Sep 30 '14 09:09

David


People also ask

Can we deploy multiple applications in Tomcat?

In order to be able to deploy additional application on a different port, you will need to create an additional Service configuration. In order to do so, edit the server. xml file once again and additional configuration group. The new group, must have a different name, different ports, both for HTTP and AJP traffic.

How do I Host multiple websites on one Tomcat server?

You may host multiple domains and map them to particular web applications. First step is to map a domain or a directory under it to the Tomcat (this is done with mod_jk or mod_proxy_ajp using our JVMCP control panel), second step is to add virtual host in server. xml. See the below example.


2 Answers

Leave them in <TomcatDirectory>/conf/Catalina/localhost

Server > Open > Server Locations

Change from: Use workspace metadata To: Use Tomcat instalation

Now a.xml and b.xml from <TomcatDirectory>/conf/Catalina/localhost will be used.

like image 99
bigGuy Avatar answered Oct 15 '22 14:10

bigGuy


If it's for development's purpose, you can specify a folder into the "docBase" attribute of context file like this :

<?xml version="1.0" encoding="UTF-8"?>
<Context crossContext="true" docBase="C:/devel/MyApp/web/target/MyApp-web" path="/MyApp" reloadable="true">
    <Resource
        ... />
</Context>

By adding these context files directly into /conf/Catalina/localhost, everything is configured and should work like you want but you'll have to stop the tomcat server every time you'll want to clean and build your project.

like image 34
Fabien Thouraud Avatar answered Oct 15 '22 13:10

Fabien Thouraud