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

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>

Related

How to deploy multiple moqui wars on Tomcat

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

Tomcat8 remove unnecessary app name in the path

I am using Tomcat8. I deployed a war file by name admin.war.This resulted in my URL turning out to
http://localhost:8080/admin.
Nevertheless, I want the URL to be http://localhost:8080. So I tried adding the following inside /conf/server.xml as mentioned here.
< Context path="" docBase="Advocatoree" debug="0" reloadable="true" >
However, this did not work. Is there an alternative?
Try to add a file called ROOT.xml in <catalina_home>/conf/Catalina/localhost/
And enter there the following:
<Context
docBase="yourAppName"
path=""
reloadable="true"
/>
Now your application is default application on your server and you can access it with URL http://localhost:8080

How to configure apache tomcat to point to my project?

I have apache tomcat running into a specific server and I've deployed a project named where2go. So I have a file named:
where2go.war and I deployed this one.
Right now when I try to access this link:
where2go.ca is going to no where and you get a blank page.
If I want to access the project I need to go to:
where2go.ca/where2go
How do I configure my server to show where2go project when I access where2go.ca?
If I understand right your question, you want to put your project on the root of the server and call it like the following: where2go.ca/ instead of where2go.ca/where2go/
If so, in order to achieve that, you need to modify your server.xml (you can find it in the tomcat configuration folder.
Open the server.xml file using your favorite text editor, and add the following directive the file, before the </Engine> directive
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="where2go" reloadable="true" override="true"></Context>
</Host>
The above will change your server root path to your project folder.
This change is good when you don't have other project deployed on the same server.
Another solution (to my opinion less preferable) is to manually deploy your project into the ROOT folder inside your /webapps folder.
Hope it will help,
Liron
After looking a while I found the solution on this link:
How can I remove the application name from a Grails application’s URL?
I used the first method:
first shutdown your tomcat [from the bin directory (sh shutdown.sh)] then you must delete all the content of your tomcat webapps folder (rm -fr *) then rename your WAR file to ROOT.war finally start your tomcat [from the bin directory (sh startup.sh)]

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.

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.