1

I've been using vhosts on my XP dev machine with little to no problems, but I can't seem to duplicate the environment on Ubuntu. I've already added a line to /etc/hosts like so:

127.0.0.1    localhost
127.0.0.1    test    # ADDED

Then, a new Host entry in server.xml:

<Host name="test"  appBase="webapps2" unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
</Host>

Then to verify it works, I copied over the default webapps into webapps2. Then made sure the permissions and even the owners and groups were exactly the same. Yet when I point my browser to http://test:8080, I get:

The requested resource (/) is not available. 

It's got me stumped these past few days and I know I'm probably missing something really simple. Anyone have any ideas?

edl
  • 111
  • 2

2 Answers2

0

Finally got it working. In the tomcat documentation, I interpreted the line:

For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place
<Context> elements directly in the server.xml file.

to mean context elements should not defined in server.xml at all. So as recommended, I used the myWebappROOT/META-INF directory and defined a context.xml in there. However this paragraph:

* Only if a context file does not exist for the application in the
$CATALINA_BASE/conf/[enginename]/[hostname]/, in an individual file at /META-
INF/context.xml inside the application files. If the web application is
packaged as a WAR then /META-INF/context.xml will be copied to
$CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to match the
application's context path. Once this file exists, it will not be replaced if
a new WAR with a newer /META-INF/context.xml is placed in the host's appBase.

...seems to indicate that the first context I define in META-INF will be placed in the above mentioned directory and not be replaced by subsequent edits. I have elected to remove the [enginename]/[hostname] conf files which for me would be Catalina/test and add a minimal context element in server.xml. This seemed to fix the problem for now, at least from a dev environment perspective. Hopefully, someone can shed some more light on the proper way to deploy additional vhosts in a production environment.

edl
  • 111
  • 2
0

I had the same problem. I am not sure if I understand your answer. What I have done is:

  1. moved the app to a folder right aside the webapps (in my example let's call it my-folder), the application was moved to its ROOT subfolder
  2. removed the ROOT.xml from $CATALINA_BASE/conf/[enginename]/[hostname]/ for the second host, I am not even sure if this step was actually needed
  3. added context element inside the host element, like this:

    <Host name="my-domain.name" appBase="my-folder" autoDeploy="true" unpackWARs="true">
    <Context path="/"></Context>
    </Host>
    

Somehow it worked the default app, located in webapps/ROOT responds to all domains and direct IP http calls. The my-folder/ROOT responds to my-domain.name as expected.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
jakubiszon
  • 101
  • 5