12 sites -> 157 contexts?

I recently, finally, got Lucee working on my local mac for development purposes. It’s working, more or less, perfectly, but I think I have done something wrong. As the title indicates, I have a LOT of contexts for 12 sites. I have put the contexts in their own folder so they aren’t ‘in the way’, but as I was testing a remotely called component in a subfolder earlier today, it wouldn’t trigger the datasource set in application.cfc. I tried a bunch of different ways of setting the datasource (normal has just been ‘this.datasource = xxx’), both in application.cfc and then also by calling it specifically in the query. It seems like that component is not reading the right application.cfc, which I think is probably down to it having it’s own context, and thus expecting an application.cfc?

So site layout is as follows:
/callingpage.cfm -> queries here see the datasource.
/components/remote.cfc -> a query on this page can’t see the datasource.

I also tested a page /components/index.cfm with a single query on it and I get the same error:

“attribute [datasource] is required when attribute [dbtype] is not [query] and no default datasource is defined”

If I look at the lucee server config, I have a list with literally (I guess) 157 different web contexts. Basically any sub folder to the main root folder for each site has a context. It doesn’t appear to go 2-deep.

What have I done wrong here? I assume I should just have the one context for the main root for each site (and then I hope each folder will find the correct application.cfc from there)? That’s in any case how it looks on my production server.

It’s set up with apache 2.4 / tomcat and the lucee war file. I have this under web.xml, and the only reason for the non-default web-directory is all the web-inf files drove me crazy (I don’t mind one on the main folder obviously).

    <description>CFML runtime Engine</description>
       <description>Lucee Server configuration directory (for Server-wide configurations, settings, and libraries)</description>
        <description>Lucee Web Directory (for Website-specific configurations, settings, and libraries)</description>

Under server.xml a site mazzy.local has this:

  <Host name="mazzy.local" appBase="/Users/XXX/Sites/mazzy">
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="mazzy_access_log" suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />

And under conf > Catalina > mazzy.local there is a ROOT.xml with JUST the following:

<?xml version='1.0' encoding='utf-8'?>

Not using mod_cfml at the moment. Just manually added the sites in virtual hosts and tomcat.


Don’t forget to tell us about your stack!

OS: Mac 10.15.6
Java Version: openjdk version “11.0.8” 2020-07-14
Tomcat Version:
Lucee Version: Lucee

In case anyone ends up here via Google, I fixed this by doing the following:

Stop tomcat.

Comment out lucee-web-directory under web.xml so it just defaults (this is not really necessary, but i like having the web-inf’s match production).

Delete the ROOT.xml file under conf > Catalina > wwww.
Instead, stick this under each in server.xml (it’s not recommended, but this is local so I can live with the restarts):

<Context path="" docBase="/Users/name/Sites/wwww" />

Last but not least, replace directory in appBase with standard ‘webapps’, so this:

 <Host name="wwww.local" appBase="webapps">

Delete the superfluous web-inf folders, then restart tomcat and it will just create in root.

Hope that helps someone. There’s like a few dozen guides to getting lucee working on a mac and most are quite old, so it’s not exactly straightforward for someone like me that isn’t super duper into the inner workings of all of this jazz.


Hi Sam, thanks for sharing this. Thank you for placing it here. I didn’t had time to answer/check this earlier, because I think this has to do with the LuceeExpress Config I’ve sent to you with a PM. I’ve checked this and my conclusion is that this behaviour has something to do with the configuration I’ve sent to you as an example for configuring Tomcat to use with URLRewrite in stand alone mode. Please apologize. Sorry for that. Looks like I’ve set the appBase location just the same as the “docBase” location, and that was wrong. Altough this should have been prompted by tomcat somehow, instead of creating WEB-Infs inside every directory of a CFML-App.

When Tomcat starts and looks at the server.xml, it finds the <host> entries and it’s attribute “appBase”. Then it will look inside “appBase” for any root folder in there. A phyisical folder found in there is automatically associated as “docBase”, so you don’t need necessarily add a docBase attribute. In that case a file ROOT.xml in your path-to-your-lucee-installation/tomcat/conf/Catalina/<hostname> would have been prompted with a “WARNING: A docBase xxx inside the host appBase has been specified, and will be ignored". In other means: This ROOT.xml is only necessary if your docBase (or your webroot) resides somehwere outside. My faulty configuration was specifying a “appBase” and “docBase” with exactly the same folder name, and that was wrong. Sorry!!!

NP, I was just glad to figure it out. My webroot does live outside of tomcat/the webapps appbase, so I think the docbase in server.xml is still necessary? Anyway, it works a treat now, so all good!

1 Like