Changing Tomcat docBase doesn't seem to work

1,439 views
Skip to first unread message

Tom McNeer

unread,
Apr 7, 2010, 5:34:08 PM4/7/10
to ra...@googlegroups.com
I apologize for so many recent posts. Obviously I'm new with both Railo and Linux. But I've followed the directions shown in this group and many blog posts, and clearly there's something I'm missing in regard to setting up a site at a location of my choice.

After installing and testing Railo, I followed some instructions from Sean Corfield's old Railo/Dummies posts, and attempted to change the location of the default Railo/Tomcat site by adding a docBase to the Host entry in server.xml:

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
             <Context path="" docBase="/media/site/webroot/" />
      </Host>

I then added a Virtual Host entry into Apache's configuration:

<VirtualHost *:80>
    DocumentRoot /media/site/webroot
    ServerName localhost
    DirectoryIndex index.cfm
</VirtualHost>

After restarting both Apache and Railo/Tomcat, when I browse to "localhost," I get a Missing Include error:

Page /index.cfm [/opt/railo/tomcat/webapps/ROOT/index.cfm] not found

So Tomcat is still looking a its webapps/ROOT directory, instead of the docBase in the server.xml.

Could someone please show me where I've gone wrong?

--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560

Ryan Letulle

unread,
Apr 7, 2010, 6:05:09 PM4/7/10
to ra...@googlegroups.com
I'm not sure if you can put that trailing slash (/) at the end of the docBase.  I don't have it on any hosts.

I get that error when Tomcat can't find the site (i.e. I make a typo somewhere in the host).

</ryan>

whostheJBoss

unread,
Apr 7, 2010, 8:05:34 PM4/7/10
to Railo
Here are my two configs, the first is for running the site with the
default appBase of "webapps", the second is for running it with it's
own appBase:

config 1:

Apache:

<VirtualHost *:80>
DocumentRoot "D:/sites/foo/ROOT/"
ServerName foo.com
DirectoryIndex index.cfm index.html

ProxyPreserveHost On

RewriteEngine On

RewriteRule ^/(.*) ajp://foo.com:8009/$1?path_info=$1 [P,L]

</VirtualHost>

Tomcat:

<Host name="foo.com" appBase="webapps" autoDeploy="true"
unpackWARs="true">
<Context path="" docBase="D:/sites/foo/ROOT/" />
</Host>

----------------

config 2:

Apache:

<VirtualHost *:80>
DocumentRoot "D:/sites/foo/ROOT/"
ServerName foo.com
DirectoryIndex index.cfm index.html

ProxyPreserveHost On

RewriteEngine On

RewriteRule ^/(.*) ajp://foo.com:8009/$1?path_info=$1 [P,L]

</VirtualHost>

Tomcat:

<Host name="foo.com" appBase="D:/sites/foo" autoDeploy="true"
unpackWARs="true">
<Context path="" docBase="D:/sites/foo/ROOT/" />
</Host>

> MediumCoolhttp://www.mediumcool.com

Dave

unread,
Apr 7, 2010, 9:31:01 PM4/7/10
to ra...@googlegroups.com
1. Your apache vhost isn't pass anything on to tomcat and it can't
process the cfm file
2. your apache httpd file might already have a connection to localhost,
I would choose a different name for it.
3. You really don't need all that in the server.xml, below will suffice

<Host name="localhost" appBase="webapps">
<Context path="" docBase="/media/site/webroot/" />
</Host>

Tom McNeer

unread,
Apr 8, 2010, 9:19:59 AM4/8/10
to ra...@googlegroups.com
Thanks to everyone for the replies. Let me go through them one by one.

@Ryan:

I'm not sure if you can put that trailing slash (/) at the end of the docBase.  I don't have it on any hosts.

The trailing slash is in all the examples I've seen, including Sean Corfield's instructions. And the other posters all show the trailing slash, so I believe it is correct, though it must work without it, too.

@whostheJboss:

I appreciate your sharing your configs. In my case, I have used Jordan Michaels' installer, and the httpd.conf file contains instructions to Apache to load and use mod_jk in processing the files. So (at least in the examples I've seen) I don't believe the Proxy statements are necessary.

 @Dave,

On Wed, Apr 7, 2010 at 9:31 PM, Dave <cfl...@jamwerx.com> wrote:
1. Your apache vhost isn't pass anything on to tomcat and it can't process the cfm file

I'm not sure exactly what you mean here. But Apache is forwarding the request to Tomcat, since the error is coming from Tomcat. Tomcat is looking in the wrong place (at least, not where I want it to look).
 
2. your apache httpd file might already have a connection to localhost, I would choose a different name for it.

It does not. There is only one VHost in the conf file.
 
3. You really don't need all that in the server.xml, below will suffice

Perhaps I wasn't clear. I simply changed the docBase location in the existing Host entry in server.xml, which was created during the installation by the Viviotech installer. I may not need the other information. But it was there, so I didn't remove it. I don't think it hurts anything.

Unless someone sees an actual mistake in the two config listings -- and I can tell you that the paths are correct - I've checked many times, and that permissions will allow access to the index.cfm at /media/site/webroot/ -- I'm left with the original question: why, when both the only VHost entry in the httpd.conf and the only Host entry in server.xml point to /media/site/webroot, does Tomcat try to load a non-existent index.cfm from /opt/railo/tomcat/webapps/ROOT?

Ryan Letulle

unread,
Apr 8, 2010, 9:55:13 AM4/8/10
to ra...@googlegroups.com
When I have a TC config error that doesn't show up when restarting (railo_ctl restart) often times it tries to serve from that location. (/opt/railo/tomcat/webapps/ROOT)


</ryan>

MrBuzzy

unread,
Apr 8, 2010, 10:18:11 AM4/8/10
to ra...@googlegroups.com
Tom,

The ROOT app is the one served by default by Tomcat.

If you used Jordans installer, you might need to uncomment a section
in sever.xml and add your own context. Can you share the part in
Tomcat server.xml that you have changed?

Take Apache out of the equation, ie hit http://localhost:8888/ what do you see?

Cheers.

> --
> To unsubscribe, reply using "remove me" as the subject.
>

--
Sent from my mobile device

Tom McNeer

unread,
Apr 8, 2010, 11:07:35 AM4/8/10
to ra...@googlegroups.com
See, this is just the sort of thing I hate. I've presented a problem, gotten all sorts of helpful advice -- caused a number of people to spend their good time trying to help me -- and now the problem appears to have solved itself.

I know that's not what happened. I know I have to have made a silly mistake somewhere, that I didn't convey to the group. But I swear I was very careful in taking all the steps I've noted in earlier posts.

So two frustrations: one, at wasting everyone's time. And two, at not knowing what I did wrong, or why Railo is now serving files from exactly the location I requested.

Once again, I apologize for the trouble - the fault has to have been mine - and I thank all the generous folks who've attempted to help me out here.

Sean Daniels

unread,
Apr 8, 2010, 11:13:48 AM4/8/10
to ra...@googlegroups.com
Is it possible that earlier when you said you had restarted Railo/Tomcat that maybe you actually had only restarted Railo? Because Tomcat requires a restart to pickup changes in the server.xml, and if you only restarted Railo (via the server admin for example) I do not believe that would also restart Tomcat. And that would give you the result you were seeing.

Ryan Letulle

unread,
Apr 8, 2010, 11:16:02 AM4/8/10
to ra...@googlegroups.com
Easy enough to test, just create another site, rinse & repeat.

</ryan>

Jordan Michaels

unread,
Apr 8, 2010, 11:50:15 AM4/8/10
to ra...@googlegroups.com
Glad to hear that it's working, but sorry to hear that it was so
frustrating.

The error you were getting was when Tomcat doesn't know how to resolve a
URL, and passes it off to the default VHost (exactly like Apache does).
So, for one reason or another, Tomcat wasn't picking up your configs.

--
Warm regards,
Jordan Michaels
Vivio Technologies
http://www.viviotech.net/
Open BlueDragon Steering Committee
Railo Community Distributions

Tom McNeer

unread,
Apr 8, 2010, 1:05:04 PM4/8/10
to ra...@googlegroups.com
@Sean,

I don't believe I only restarted Railo, but I can't be absolutely certain. I generally do the restart by opening the Services panel and doing a restart on railo_ctl, which I believe also restarts Tomcat (though I could be wrong, and if so, I'd sure love to know about it).

@Jordan,

Thanks.

The error you were getting was when Tomcat doesn't know how to resolve a URL, and passes it off to the default VHost (exactly like Apache does). So, for one reason or another, Tomcat wasn't picking up your configs.

I assumed that. But what was mystifying is that there didn't _seem_ to be a default VHost for Tomcat, other than the one I specified. All I did was add a context/docBase statement into the default Host entry in your file. Does Tomcat assume (without any Host entries in server.xml) that /webapps/ROOT is the default location?

All that aside, I still obviously did something wrong. Thanks to everyone for helping, and for trying to help me understand what went wrong.


Ryan Letulle

unread,
Apr 8, 2010, 1:06:55 PM4/8/10
to ra...@googlegroups.com
Services Panel?

</ryan>

Tom McNeer

unread,
Apr 8, 2010, 1:28:18 PM4/8/10
to ra...@googlegroups.com
On Thu, Apr 8, 2010 at 1:06 PM, Ryan Letulle <bayo...@gmail.com> wrote:
Services Panel?

The actual label on the app is "Service Configuration." In the KDE desktop, it's found under System > Services.

Ryan Letulle

unread,
Apr 8, 2010, 1:37:25 PM4/8/10
to ra...@googlegroups.com
I always restart from the command line.

installer default on Ubuntu:

"sudo /opt/railo/railo_ctl restart" 

 
</ryan>
Reply all
Reply to author
Forward
0 new messages