How to deploy multiple moqui wars on Tomcat - moqui

I have two war files moquiA.war and moquiB.war. Now I want to access different instances via different URLs say
http://localhost:8080/moquiA
http://localhost:8080/moquiB
When tried deploying both wars, I was unsuccessful. Anyone tried this?
Additional Details:
I tried deploying a war file on Tomcat other than ROOT, still its is not working. After bit research I feel getPathInfoList (WebFacadeImpl.groovy) might be responsible for this.

Take a look at conf/server.xml:
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
You can nest elements within the element and have different ones corresponding to different virtual hosts, different appBase's etc.
enter link description here

Related

How to set context path in Tomcat 8 for link and script tags

I have a web-site that I have deployed locally on IIS/ColdFusion but Tomcat/Lucee in production (the production server is Windows Server). Tomcat is not running as a Windows Service
I am trying to set up virtual directories since IIS and Tomcat seem to handle relative paths differently. I have a virtual directory called "/style" set in IIS that points to my style sheet directory which works just fine. When I try to modify the server.xml file in Tomcat8, it never works.
I am using the following tag in my cfm header file:
<link rel="Stylesheet" media="screen" href="/style/styles.css">
Here is a portion of my server.xml file:
<Host name="127.0.0.1" appBase="webapps" unpackWARs="true" autoDeploy="true">
<context path="/style" docBase="C:\lucee\tomcat\webapps\ROOT\mysite\_style" ></context>
I have tried moving the context to different locations within the server.xml file, I have tried different context attributes. Nothing seems to work.
Any suggestions?
I used the information from the following link:
https://www.petefreitag.com/item/867.cfm
and used the following:
<Context path=""
docBase="C:\lucee\tomcat\webapps\ROOT"
WorkDir="C:\lucee\tomcat\temp">
<Resources>
<PreResources base="C:\lucee\tomcat\webapps\ROOT\mysite\_style"
className="org.apache.catalina.webresources.DirResourceSet"
webAppMount="/mysite/style"/>
</Resources>
</Context>

Tomcat server.xml redirection: new class files not loaded

I have have a domain name (for example myapp.com) that I am using it to redirect to a web application (for exmple "myapp"), which is deployed on my tomcat server (for example in "myserver.es/myapp"). I added this fragment to the server.xml file of the tomcat to configure the redirection:
<Host name="myapp.com" appBase="webapps/myapp"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="."/>
<Alias>www.myapp.com</Alias>
</Host>
Apparently it is working good, if I write "mydomain.com" in the browser the app is shown correctly.
The problem: when I generate a new WAR file of that app and I upload it to the Tomcat server (after stopping and undeploying the previous version), the changes related with Java code are not shown. I have to restart my tomcat server to access to the last version of the app from "myapp.com".
In contrast, if I access to "mydomain.com/myapp", I can see the last version of the app, showing the changes made in the last WAR.
So, I think that the problem is related with the redirection. It is anything wrong with the previous XML code?
The other "Host" configured in the server.xml is this one:
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
You might be having issues with Parallel Deployement
You could set undeployOldVersions="true" inside your host to see if that works.
Finally, I've discovered the solution! I needed to set privileged="true" inside the Context tag.

How to preserve Apache Tomcat7 configuration files when reinstalling application

I am using Apache Tomcat7 for one of my projects and in order to store some container specific configuration, I am using an XML file under the /etc/tomcat7/Catalina/localhost/ directory (in linux). For example /etc/tomcat7/Catalina/localhost/my-app.xml if the app in question is called my-app.
When I reinstall (update) the application, the afore mentioned file, seems to be deleted during the installation process. Is there any way to preserve this file?
Yes! Have done this mistake quite some time.
There are several conditions (like changing the war file, deleting the webapp or replacing it with new content) under which tomcat will undeploy the context including removing the context file.
You should stop your server before making any changes like changing your war file. If you try to edit or move the deployed war file the corresponding configuration in conf/Catalina/localhost/ will get deleted.
If you do not wish this behavior you can edit the server.xml file located in conf/ directory.
Change
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
and make autoDeploy="false"
For more details you can refer to Apache Tomcat Configuration Reference

Running jsp files from /srv/http using Apache HTTP server and Tomcat

I'd like run jsp files directly from /srv/http without deploying them the Tomcat-way. For example, I want to be able to create symbolic link to my webapp directory (e.g. /home/user/myapp/) in /srv/http and access some app's page through http://localhost/myapp/page.jsp.
Is this possible and how would I set this up?
NOTE: This is not for production. We have to use JSP at university and I want to be able to quickly test my pages.
Open the server.xml of your Tomcat. Assuming if your are using Tomcat 6.x+ then it would be at /tomcatDir/conf/server.xml.
Make an entry with your path
<Context path="/myapp" docBase="yourPathGoesHere" debug="0" reloadable="true" />
Restart Tomcat if already running.
What I did at the moment was creating a symlink in /var/lib/tomcatX/webapps to my project path. This is not the answer I was looking for though, but it is a way to deploy an app without much work.
(X in the above path means your Tomcat version)
If you set <Host name="localhost" appBase="/srv/http"> then all of the directories in it will be deployed as web applications.
If you want /srv/http to be the ROOT application/directory add a file: tomcat/conf/Catalina/localhost/ROOT.xml
with the Context docBase="/srv/http", rather than adding a Context definition to server.xml - this has been strongly discouraged for years.

Deploying multiple grails applications with Apache/Tomcat + Virtual Hosts

I haven't been able to figure out how to deploy multiple grails applications with Apache/Tomcat where a virtual host is mapped to each grails app
I can get it so that
http://virtualhost1.example.com/myGrailsApplication-0.1/
works, but what I want is for
http://virtualhost1.example.com/
to go directly to my application. A lot of tutorial sites on the web just have you make your web app the "ROOT" one, but that won't work in a mutiple grails-app virtual host environment.
I tried using the
<Host name="virtualhost1.example.com" ...> </Host>
tags in the tomcat/conf/server.xml file, but it didn't seem to do anything (and, yes, I restarted tomcat each time I changed it.)
I also tried everything I could think of in my apache config file for the virtual host, and couldn't get it to work.
So, how can I get rid of the app name in the URL when I have multiple grails webapps, virtual hosts, and I don't want my webapp to be "ROOT"?
I'm assuming that you are using mod_jk to connect Apache & Tomcat. If so, You will have to have to configure virtual hosting within Tomcat as well as Apache (multiple <Host> declarations in your conf/server.xml)
This basically means that you'll have two <Host ...> declarations within conf/server.xml. They will have different names, and appBase, but you will still have to name the war ROOT.war
The example that they gave was:
<Engine name="Catalina" defaultHost="ren">
<Host name="ren" appBase="renapps"/>
<Host name="stimpy" appBase="stimpyapps"/>
</Engine>
After you've configured the DNS of your virtual '<host>s'(much like Apache) you'll have to put your ROOT.war(s) into separate folders {renapps,stimpyapps} instead of the default 'webapps' folder
This method works, but there is another method using mod_proxy instead of mod_jk. I'm not that familiar with mod_proxy but basically you would have the connector handle translating the root context to the actual context. So after its configured it would proxy & forward requests sent to http://virtualhost1.example.com/ to the right context within Tomcat (/myGrailsApplication-0.1/)
Let us know what you find! Anyone else do this with mod_proxy?