i try to set my domain as vhost.
My config looks like this:
<Host name="example.de" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias>www.example.de</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="example_access" suffix=".log"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="/opt/tomcat/webapps/app1" debug="0" reloadable="true" />
</Host>
This config works with every subdir in the webapps-directory, except for the directory I want. If I try to open the Domain, there is an empty browsertab. (Error 404) But if I call it like www.example.de/app1, the app still works and everything ist fine :/
I don't have any idea :/
PS: It's a clean setup of Tomcat, just extracted and edited the server.xml for the vHost-settings
Remember to deploy every application you'd like to appear in a virtual host, including the ROOT application. If you don't have a ROOT application, there is no "default" application that Tomcat can fall-back to, and your clients will get 404 responses when requesting /.
Related
I'm running a quartz job in my web application which is deployed in tomcat. But the problem is the job is executed twice.
After some internet research I've found that adding a new Host with autoDeploy in tomcat's server.xml may cause twice deployment. Which I guess is causing my quartz scheduler executed twice.
I tried with autoDeploy = "false". But the problem continues.
Here is the host config in my server.xml:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="false">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
<Host name="demo.example.com" appBase="webapps/demo" unpackWARs="true" autoDeploy="false">
<Context path="/" docBase="." reloadable="true" />
</Host>
Edit (FYI):
my cron expression: 0 50 12 * * ? which is scheduled to run everyday at 12:50 pm.
Is this configuration will deploy my application twice? What can I do to avoid that? Thanks is advance.
If your observation is indeed correct then there could be multiple problems here -
In addition to custom location that you specified in server.xml, your app might be present in tomcat/webapps folder as well.
You might be using hot deployment from within some IDE and saving a file within IDE might be reloading the context, thus having quartz reinitialized again, which might be giving your wrong impression.
You indeed have some code problem.
It hard to say what's going on w/o looking at the code snippet but this should be fairly simple problem.
I am using/trying to deploy grails war app to the tomcat7 virtual host configured in server.xml. I have modified etc/hosts to redirect www.mytest.com to localhost (referred from ramkitech). There seems no problem in the code as it works in development(By this, I mean I run my code from grails run-app and access http://localhost:8080/app/). The problem is when I deploy it to independent tomcat7 and put it as ROOT.war in the webapps folder and run the tomcat service, I can access the war based app at http://www.mytest.com:8080/ and when I try to set cookies, they do not seem to be stored and hence, I can't access the cookies set. By the way, the war was generated by the grails dev war. What could be going wrong here?
Server.xml
<Host name="www.mytest.com" appBase="webapps"
unpackWARs="true" autoDeploy="true" >
<Alias>mytest.com</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
I referred this from http://www.ramkitech.com/2012/02/understanding-virtual-host-concept-in.html and I am using grails cookie plugin 1.4 and basically call savePreference() with ajax providing sample cookie from the the view.
def savePreference(Map cleanParams=[:]) {
cleanParams.each{key,val->
cookieService.setCookie(key, val)
}
return "OK"
}
and here is sample cookie key value pairs I store:
prod_type:A
prod_categoryId:2
prod_id:3
I know this has been touched upon in several ways already, but i'm still having issues - I have a webapp in:
/var/lib/tomcat7/webapps/abc.war
I have a domain at say, my.domain.com
I've added this to my conf/server.xml (which i believe is set correctly?)
Docbase points to the war folder?
<Host name="my.domain.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context path="" docBase="/abc" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
My domain ip is in the /etc/hosts along w/ the local host ip:
127.0.0.1 localhost
123.123.123.33 HostName.my.domaing.com HostName
$ /etc/hostnames
HostName
With my current settings above i'm am not getting any results in seeing my webapp online. Any thoughts would be very grateful!
My domain already is mapped to my /var/www/html directory too. I can see my temp index.html file online. My tomcat webapp works fine through ip:8080/abc
I'm working on Ubuntu Server 14.04 - Apache2
This is my first time working w/ tomcat and it's a bit confusing.
Thank You!
Your /etc/hosts should contain an entry like this:
123.123.123.33 my.domain.com
or
123.123.123.33 HostName.my.domaing.com HostName my.domain.com
Otherwise you won't be able to resolve the name my.domain.com to connect to your Tomcat.
If you already configured your firewall earlier, to redirect ports you type
sudo firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
and reboot it.
Somehow I cannot normally map domain to my webapp in tomcat7.
Here is the parts from server.xml:
<Engine name="Catalina" defaultHost="localhost">
<Host name="mydomain.com" appBase="webapps" autoDeploy="true" unpackWARs="true">
<Alias>www.mydomain.com</Alias>
<Context path="" docBase="myapp"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Does the defaultHost must be localhost or mydomain.com?
I have written a script which deploys myapp in ubuntu:
#!/bin/bash
service tomcat7 stop
rm -rf /usr/share/tomcat/webapps/myapp/
cp myapp.war /usr/share/tomcat/webapps/
service tomcat7 start
After running this script I can access my app only like this: mydomain.com/myapp
If I restart tomcat then it maps to the domain ok, but there is two webapps running.
What am I doing wrong?
To make your web application the default webapp you can simply
rename your myapp.war to ROOT.war,
rm -r /usr/share/tomcat/webappas/ROOT
cp ROOT.war /usr/share/tomcat/webapps
more information available at: http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F
I have a Java based web application which is deployed on Ubuntu machine. I can access the web application at localhost:8080 and it is working as expected.
Now I have domain name for the web application and I want to access web application through the browser using the domain name(http://www.xyz.com).
I want to know the steps which are required to achieve it. Before posting this question, I search over the google.
I have already added the host details in the conf/server.xml.
<Host name="xyz.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>www.xyz.com</Alias>
<Context path="" docBase="" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Also, I made changes in the /etc/hostname and added following
<IP Address> www.xyz.com xyz
What else do I need to do?