You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Pid <pi...@pidster.com> on 2012/03/14 23:35:24 UTC

Re: Help with ROOT.xml and vhosting please? (fwd)

On 14/03/2012 22:25, Dave Shevett wrote:
>> From: Pid <pi...@pidster.com>
>> Exactly which OS, Java & Tomcat versions are you using?
> 
> This is an AWS micro instance running some variant of CentOS
> Tomcat 6.0.33
> [ec2-user@app01 tomcat6]$ java -version
> java version "1.6.0_22"
> OpenJDK Runtime Environment (IcedTea6 1.10.6)
> (amazon-52.1.10.6.41.amzn1-x86_64)
> OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
> 
>>> <Context path="/" docBase="/var/wars/application.war" />
>>
>> path="" would be correct if it was valid here, which it is not - it is
>> redundant because the path is derived from the Context definition file
>> name 'ROOT.xml'.
> 
> Fair enough - I removed the path= entry from the ROOT.xml.
> 
>>> I'm assuming when I hit vhost.REDACTED.com, I should see a deployed
>>> version of the application.war, right? Or am I doing something
>>> blatantly stupidly wrong here?
>>
>> What _do_ you see?
> 
> Right now I'm getting 404's on the root.
> 
> sloop:~ shevett$ curl -I http://REDACTED.com/
> HTTP/1.1 404 Not Found
> Date: Wed, 14 Mar 2012 22:16:30 GMT
> Content-Type: text/html;charset=utf-8
> Content-Length: 952
> Connection: close

What is serving that error?  Tomcat & HTTPD error pages look different.


>> Are there any relevant messages in the Tomcat logs?
> 
> Just that the app was in fact unpacked into the work directory (and I
> can see it there), and it looked like it tried to start (there's a stack
> trace, but that's application specific - it definitely tried to start, I
> just don't know where it is)

If it didn't start, that would explain why you can't get it to respond.
What is the stacktrace?


p

>> How have you defined the Hosts in server.xml?
> 
> Umm, to be honest initially I hadn't. :(  I was trying to come up with a
> way to get 'dynamic' vhost allocation - kick a ROOT.xml and directory
> structure into place, restart / hup, and the vhost goes live.  That
> doesn't look possible (as it appears I need Host entries in server.xml
> to do this, which is hard to dynamically edit).
> 
> Anyway, I created a new Host entry, and added a Valve for logging:
> 
> <Host name="REDACTED.com" appBase="REDACTED.com" unpackWARs="false"
> autoDeploy="true">
> <Valve className="org.apache.catalina.valves.AccessLogValve"
> directory="logs" prefix="REDACTED_access_log." suffix=".txt"
> pattern="common" resolveHosts="false"/>
> </Host>
> 
> When I hit the host, the vhost is obviously getting handled, as I'm now
> getting traffic into the REDACTED_access.log, but it's not actually
> triggering the app:
> 
> [ec2-user@app01 tomcat6]$ cat REDACTED_access_log.2012-03-14.txt
> 96.39.62.78 - - [14/Mar/2012:21:58:01 +0000] "GET / HTTP/1.1" 404 952
> 96.39.62.78 - - [14/Mar/2012:21:58:01 +0000] "GET /favicon.ico HTTP/1.1"
> 404 952
> 
> Hope that's enough information!


-- 

[key:62590808]


Re: Help with ROOT.xml and vhosting please? (fwd)

Posted by Pid * <pi...@pidster.com>.
On 15 Mar 2012, at 15:05, Dave Shevett <sh...@homeport.org> wrote:

> On 3/14/12 6:35 PM, Pid wrote:
>> If it didn't start, that would explain why you can't get it to respond.
>> What is the stacktrace?
>
> So, just to finish this up, I got everything working Just Peachy.  The failed deployment was why the app was not showing up in the end, but getting the Host entries in server.xml and getting the ROOT.xml stable were big components.  I'll probably write up a blog post on this at some point.
>
> My last question is is there a way to bring a vhost live without restarting Tomcat?  I want to dynamically create vhosts programmatically (with scripts and the like) - I can drop the ROOT.xml all configured, and I can probably write a script to modify server.xml, but I can't just hup tomcat, can I?  I have to bring it all the way down and back up again to make the new vhost live, correct?

You can create Hosts programmatically via the JMX API, but YMMV. This
will not automatically persist to the file based config.


p


>
> Again, thanks to everyone for the help!

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Help with ROOT.xml and vhosting please? (fwd)

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave,

On 3/15/12 11:05 AM, Dave Shevett wrote:
> On 3/14/12 6:35 PM, Pid wrote:
>> If it didn't start, that would explain why you can't get it to
>> respond. What is the stacktrace?
> 
> So, just to finish this up, I got everything working Just Peachy.
> The failed deployment was why the app was not showing up in the
> end

That'll do it.

> My last question is is there a way to bring a vhost live without 
> restarting Tomcat?

You can use the host manager webapp to do things like that. The
problem is that the host manager does not persist the changes
anywhere, so you'd have to either write them somewhere (like
server.xml) yourself at the same time you hot-deployed them, or you'd
need to re-hot-deploy every vhost every time you restart Tomcat.

> I want to dynamically create vhosts programmatically (with scripts
> and the like) - I can drop the ROOT.xml all configured, and I can
> probably write a script to modify server.xml, but I can't just hup
> tomcat, can I?  I have to bring it all the way down and back up 
> again to make the new vhost live, correct?

If you modify server.xml, yes: you have to shut down Tomcat and bring
it back up.

Is there a way you could get away with using the hostname for
self-configuration at request-time? If you could do that, you would
only need a single <Host> and a single deployment of the webapp. The
only things that would need to change when you wanted to support a new
"vhost" would be to shove some configuration somewhere that you can
key-off the hostname (db, for instance).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9iITIACgkQ9CaO5/Lv0PA4kwCfZACKXTI+pBb2xfkxu1RAUhPm
3LcAnRJngtQ1ODxoYeMdWF0TYl6iksFp
=ybk1
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Help with ROOT.xml and vhosting please? (fwd)

Posted by Dave Shevett <sh...@homeport.org>.
On 3/14/12 6:35 PM, Pid wrote:
> If it didn't start, that would explain why you can't get it to respond.
> What is the stacktrace?

So, just to finish this up, I got everything working Just Peachy.  The 
failed deployment was why the app was not showing up in the end, but 
getting the Host entries in server.xml and getting the ROOT.xml stable 
were big components.  I'll probably write up a blog post on this at some 
point.

My last question is is there a way to bring a vhost live without 
restarting Tomcat?  I want to dynamically create vhosts programmatically 
(with scripts and the like) - I can drop the ROOT.xml all configured, 
and I can probably write a script to modify server.xml, but I can't just 
hup tomcat, can I?  I have to bring it all the way down and back up 
again to make the new vhost live, correct?

Again, thanks to everyone for the help!

	-d

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org