File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]]" Watch "WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]]" New topic
Author

WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]]

Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
VMWare - cloned a working server. This source server was in xxx.org domain. The destination server is in yyy.org domain. Went through this destination server changing the ip address, the hostname, the hosts file, the resolv.conf file, the Tomcat server.xml file. Checked out the apache2.conf, workers.properties, mod-jk.conf, apache2 files in sites-enabled, (xxx.domain.org) sites available, (xxx.domain.org). Searched /usr/share/tomcat/Catalina, I found a directory in there named localhost, ran ls -al, just came up with . and .. px -aux shows that Tomcat is running. But I can't connect to it. I've searched the destination server for references to the old host name and domain (grep -r string) and googled for info. Read the Tomcat doc on connectors. Checked the apache2 access and error logs, the mod_jk.log. Searched this forum. I need a hint on how to sort this out? Is there a log or config file I should check out? What files come into play for the connectors? Server.xml would be one, workers.properties, would be another. Thanks

Here's a snip from the catalina.out log file.

INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 18, 2013 11:10:33 PM org.apache.catalina.connector.MapperListener findDefaultHost
WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]]
Sep 18, 2013 11:10:33 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 18, 2013 11:10:33 PM org.apache.catalina.connector.MapperListener findDefaultHost
WARNING: Unknown default host [localhost] for connector [Connector[AJP/1.3-8009]]
Sep 18, 2013 11:10:33 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 159730 ms


Debian 7, Java 7, Tomcat 7.0.42.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Tomcat supports multiple virtual hosts. The concept is not quite identical to how Apache HTTPD does it, but it's similar: you define a Host with a discrete hostname that requests can be sent to.

By default, Tomcat is pre-configured with a single Host, whose name is "localhost". The TOMCAT_HOME/conf/Catalina directory contains 1 subdirectory for each host that that particular Tomcat instance is serving, which is why there's a TOMCAT_HOME/conf/Catalina/localhost directory. It is where the Context definitions are stored for that host when you are deploying with external Context definitions - which is to say that you're neither letting Tomcat synthesize a default definition for a WAR nor using a META-INF/context.xml file within a WAR.


Customer surveys are for companies who didn't pay proper attention to begin with.
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Tim Holloway wrote:Tomcat supports multiple virtual hosts. The concept is not quite identical to how Apache HTTPD does it, but it's similar: you define a Host with a discrete hostname that requests can be sent to.

By default, Tomcat is pre-configured with a single Host, whose name is "localhost". The TOMCAT_HOME/conf/Catalina directory contains 1 subdirectory for each host that that particular Tomcat instance is serving, which is why there's a TOMCAT_HOME/conf/Catalina/localhost directory. It is where the Context definitions are stored for that host when you are deploying with external Context definitions - which is to say that you're neither letting Tomcat synthesize a default definition for a WAR nor using a META-INF/context.xml file within a WAR.


I understand some of what your explaining. So are you saying you can't clone a server like I've done and have Tomcat work? I was expecting to find a file, in that /localhost directory but it's empty. How can the Context definitions be store for the host in /localhost if the directory is empty? In the /usr/share/tomcat/Catalina directory there are two directories. /localhost and /hostname.domain.org both are empty. Is the /hostname.domain.org the Context definition you're referring too?

Thanks

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

Your definition of "clone a server" and mine are not the same. Tomcat allows you to share code with multiple server instances and separate server.xml files (among other resources) by using the CATALINA_HOME and CATALINA_BASE environment variables. In that particular definition of "clone", however, each Tomcat runs as an independent OS process under a separate JVM.

VirtualHosts are defined WITHIN a server. Normally, as I said, there's only "localhost" per server instance, but you can define other virtual hosts as well. Because of the 1-application-per port rule, if you have multiple server instances, each server instance must have at least one Service that defines ports that no other application in the system uses.

The Context is what defines a Tomcat deployed webapp. J2EE actually maintains 2 deployment descriptors: the server-dependent deployment descriptor (Context) and the server-independent deployment description (WEB-INF/server.xml). Together they completely define what a webapp is.

The server-dependent deployment description (Context) is described in the Tomcat system documentation. Basically, this is a small XML file which maps a given URL context (the part of the URL that determines WHICH webapp the URL gets routed to) and the codebase that handles the URL. For simple cases, Tomcat will take a WAR file or exploded WAR directory in the TOMCAT_HOME/webapps directory and build a Context internally whose URL context path is the same name as the WAR and whose codebase is the WAR file or directory.

More complex contexts need explicit definitions. Cases where an explicit Context definition is needed include: webapps which are deployed to some other place than the Host's default WAR directory (TOMCAT_HOME/webapps), webapps that define one or more JDBC connection pools, webapps that employ Tomcat security Realms, and webapps which provide external customization via JNDI parameters.

An explicit context definition can be bundled into the WAR itself in a META-INF/context.xml file or be attached externally as a standalone xxx.xml file in the host's context directory (TOMCAT_HOME/conf/Catalina/localhost, for example). There are precedence rules that determine which context definition is actually used if a context is defined in more than one place.
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Sorry my bad, when I said clone. I meant that I'd used VMware to clone a vm I had working just the way they wanted it to. To another vm they want in a different domain. Same app just a different domain, and they wanted this one exposed to the outside. I thought it would be faster to clone it, than to install it from scratch. Now I'm jammed up with this localhost msg. I've read the Context documentation but I'll admit I don't really understand it at this point. I need more trigger time with Tomcat, Apache, etc. http://tomcat.apache.org/tomcat-7.0-doc/config/context.html http://tomcat.apache.org/connectors-doc/generic_howto/quick.html.

So thanks for the detailed explanation it. There's just one app and it's in the /Tomcat_Home/webapps folder. Can't get much simpler than this but I can't sort it out. At this point I'm thinking I should just rip out Tomcat and reinstall it.

Tim Holloway wrote:Your definition of "clone a server" and mine are not the same. Tomcat allows you to share code with multiple server instances and separate server.xml files (among other resources) by using the CATALINA_HOME and CATALINA_BASE environment variables. In that particular definition of "clone", however, each Tomcat runs as an independent OS process under a separate JVM.

VirtualHosts are defined WITHIN a server. Normally, as I said, there's only "localhost" per server instance, but you can define other virtual hosts as well. Because of the 1-application-per port rule, if you have multiple server instances, each server instance must have at least one Service that defines ports that no other application in the system uses.

The Context is what defines a Tomcat deployed webapp. J2EE actually maintains 2 deployment descriptors: the server-dependent deployment descriptor (Context) and the server-independent deployment description (WEB-INF/server.xml). Together they completely define what a webapp is.

The server-dependent deployment description (Context) is described in the Tomcat system documentation. Basically, this is a small XML file which maps a given URL context (the part of the URL that determines WHICH webapp the URL gets routed to) and the codebase that handles the URL. For simple cases, Tomcat will take a WAR file or exploded WAR directory in the TOMCAT_HOME/webapps directory and build a Context internally whose URL context path is the same name as the WAR and whose codebase is the WAR file or directory.

More complex contexts need explicit definitions. Cases where an explicit Context definition is needed include: webapps which are deployed to some other place than the Host's default WAR directory (TOMCAT_HOME/webapps), webapps that define one or more JDBC connection pools, webapps that employ Tomcat security Realms, and webapps which provide external customization via JNDI parameters.

An explicit context definition can be bundled into the WAR itself in a META-INF/context.xml file or be attached externally as a standalone xxx.xml file in the host's context directory (TOMCAT_HOME/conf/Catalina/localhost, for example). There are precedence rules that determine which context definition is actually used if a context is defined in more than one place.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

OK, that's an entirely different type of virtual host. Each VM has its own set of TCP/IP ports, so the uniqueness rule doesn't apply. In the simplest configuration, you'd just clone the VM, change its hostname and IP address, and that would essentially be it. No funny messing around with Tomcat's config files.

You'd still need a Context definition if you wanted to use advanced Tomcat configuration options, but that's unrelated to the cloning process. You'd do that even if your had one and only one Tomcat but you needed a Realm or Connection Pool or something like that.
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Tim Holloway wrote:OK, that's an entirely different type of virtual host. Each VM has its own set of TCP/IP ports, so the uniqueness rule doesn't apply. In the simplest configuration, you'd just clone the VM, change its hostname and IP address, and that would essentially be it. No funny messing around with Tomcat's config files.

You'd still need a Context definition if you wanted to use advanced Tomcat configuration options, but that's unrelated to the cloning process. You'd do that even if your had one and only one Tomcat but you needed a Realm or Connection Pool or something like that.


I was kinda hoping it was going to be that simple. I knew I'd have to change the ip, hostname, hosts file, and resolv.conf, and any reference to the old hostname in any and all config files, Apache2, the app itself, etc. I'm just stymied on why Tomcat is throwing this localhost error.

Thanks Jim
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
So I have it a bit sorted out. For clarity I'm going to call the source server (server1), destination server (server2). I had used VMWare to clone server1 to server2.

After removing and reinstalling Tomcat on server2. I'm comparing the server.xml files between server1 and server2 . The first one is unmodified right after installing Tomcat on server2. The second one is what I'm currently using on server2. Note the Host name = localhost, and this works, no errors in catalina out. If I change "localhost" to "vhost.domain.org" it stops working, and I have the same error msg's in catalina.out

The third one is on server1. Note the host name is vhost.domain.org. This works on server1, no errors in catalina.out. I'm puzzled on why it works on server1 but not on server2. Looks like the error has more to do with Apache2 and mod_jk. I used the link at the bottom of the page to setup mod-jk. When I installed Debian I chose to install Apache2, maybe there's some file in Apache that's holding on to the original host name. Any ideas?

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path=""
docBase="/usr/share/tomcat/webapps/"
reloadable="true" />

<Host name="servername.domain.org" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path=""
docBase="/usr/share/tomcat/webapps/"
reloadable="true" />

http://www.sysadminslife.com/linux/howto-tomcat-7-installation-via-mod_jk-und-apache-vhosts-unter-debian/
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16303
    
  21

I didn't quite understand that, but it sounds like you renamed the host from "localhost" to "servername.domain.org" in the Host element.

Not how the error message reads:

WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]

In other words, don't rename localhost, add a new virtual host and leave localhost alone. It's needed for requests that come into the machine that don't match on the virtual hostname. Even if they are invalid.

However, you don't need a virtual host at all if you are constructing an entire new VM or JVM. In web parlance "virtual host" means "alternative host", and you'd only define them if the machine had more than one hostname with each hostname serving a different set of services.
Jim Armstrong
Greenhorn

Joined: Aug 08, 2013
Posts: 18
Tim Holloway wrote:I didn't quite understand that, but it sounds like you renamed the host from "localhost" to "servername.domain.org" in the Host element.

That's exactly what I did. Sorry to be so long winded and confusing.

Not how the error message reads:

WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]

In other words, don't rename localhost, add a new virtual host and leave localhost alone. It's needed for requests that come into the machine that don't match on the virtual hostname. Even if they are invalid.

However, you don't need a virtual host at all if you are constructing an entire new VM or JVM. In web parlance "virtual host" means "alternative host", and you'd only define them if the machine had more than one hostname with each hostname serving a different set of services.

Thanks again for schooling me on the finer points. I think we can consider this one resolved. Many thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WARNING: Unknown default host [localhost] for connector [Connector[HTTP/1.1-8080]]