I have placed my virtual directory config into App...
# lucee
g
I have placed my virtual directory config into Application.cfc's pseudo-constructor with the following code;
Copy code
this.mappings["/dbsetup"] = "#this.basePath#/dbsetup/";
And when I dump the variables scope, inside the this struct is;
Copy code
/dbsetup	    string	/srv/www/app/dbsetup/
Where the path is shown, correctly. If I attempt to go the URL;
<http://myApp.localhost:8080/dbsetup/index.cfm>
I get an error, stating the page can't be found because the
dbsetup/index.cfm
is being appended to the Application Root, as you can see from the CGI scope;
Copy code
cf_template_path	 string	/srv/www/app/webroot/dbsetup/index.cfm
If I create the mapping within the Lucee Administrator, the mapping works correctly / as expected. What am I missing? Thanks!
z
there's a flag in the admin code to make a mapping web accesible
g
Hi @zackster Any ideas where? I have been searching for "mapping" in the code and while I have found quite a lot of different files - but nothing that reads anything (to me) like copy / duplicate to web contexts.
Eg. I found this source and maybe its the boolean "appMapping"? But I am guessing and even if it is - how do I use it? Is it just an attribute to add to the this.mapping? I don't see how to use it - if it is... Thanks.
I actually found it; "Web Accessible." But according to the docs it is not available for use in Application.cfc
b
@gavinbaumanis Let's back up and forget about that flag for a second-- I'm still confused as to your original example. Where exactly on your hard drive does the file live?
Is this this correct path tot he file you want?
Copy code
/srv/www/app/webroot/dbsetup/index.cfm
And if not, where is the file you were expecting to load?
Because, based on your setup above, that's exactly what I would have thought you wanted to load.
So if that's not the file you wanted to load, forget about the web accessable bits and let's talk about your expectations first! lol
g
HI Brad, The physical location of the file is;
Copy code
/srv/www/app/dbsetup
The
this.mapping
setting in Application.cfc is correct; The issue is, that mappings defined in the Application.cfc are not "Web Accessible", unlike the Lucee Admin there is no option to make them so, either. So at least with our MachII application, the "/dbsetup/filename.cfm" is being appended to the path of the application root.
b
@gavinbaumanis Ok, I understand what you are doing here.
The issue is, that mappings defined in the Application.cfc are not "Web Accessible",
No, this is not correct. This has nothing to do with whether or not the CF admin is "web accessible" and has everything to do with a chicken/egg problem
Mappings in an Application.cfc can't affect the resolution of a .cfm file in the URL because this is the order things happen in
• request for /foo/bar.cfm comes in • Lucee finds physical file on disk • Lucee uses rules to locate the applicable Application.cfc or Application.cfm (known as the application listener) • Lucee creates the app listener, which executes the pseudo constructor • Lucee processes onRequestStart/onRequest methods • Lucee finally runs bar.cfm
The issue is you want a mapping that doesn't exist on until bullet #4 to influence a decision that happens back in bullet #2!
So the issue isn't that Lucee knows about you rmapping, but it's wrong type, the issue is Lucee never knows about your mapping because Lucee never even finds that Application.cfc because Lucee never finds the cfm you want to run in the first place!
g
How does it work if it is set in the Lucee Admin?
b
The rule here is simple, when you want to run cfm's from a virtual directory, you need to create the matching mapping in the Lucee admin, which is global to add applications.
How does it work if it is set in the Lucee Admin?
Because that mapping exists during bullet #2!! 😉
g
Can I do something in onApplicationStart to solve this, then?
b
no, same problem!
read what I said above again
applicationstart doesn't run until after bullet #4!
way too late in the process
You simply cannot influence the finding of a .cfm from the URL in any Application.cfc file
It makes no sense when the application.cfc itself is determined by the location of the .cfm file!
This would be circular logic
g
Right... agreed.
b
Now, what you need to do is vote for this ticket (give me a sec)
g
so could "my" solution - if I want to NOT use the Lucee admin , create virtualdirectories for the host?
b
This sort of crap "just works" in Adobe CF because it uses the servlet context's
getRealPath()
method t help location the file
Lucee doesn't do this, and you can see this ticket from 2016 has just been rotting in the backlog with an open pull request suggested fix getting no feedback
If this ticket was in place, you wouldn't even be having this issue 😕
g
So - who do we beat up then? 🙂
b
Micha, lol
so could "my" solution - if I want to NOT use the Lucee admin , create virtualdirectories for the host?
I don't understand what this means, lol
I'd recommend automating the CF mappings with CFConfig. It's the next best thing
g
From a web server persepctive - say apache - you can use the ALIAS tag to "map" a directory. I was just wondering aloud - would that fix my issue?
I use cfconfig for "other" settings, already - so I could just do the mappings, there 👍
b
I don't understand what you're suggesting about Apache, but you cannot solve the problem entirely with Apache
Based on how your proxy is setup to send requests to CF, chances are all requests to any file ending with
.cfm
just get handed off to Lucee regardless and it's 100% up to Lucee to decide what they map to.
The Apache alias would only be for static files
I also see you cross-posted this basically in the Lucee forum too
g
I have recently volunteered to do some woirk in the documentation, Doing some examples - adding extra information into the "description" of tags/ functions.... And I also volunteered to getting "tagged" in conversations where doc changes are found to be needed. When SVN was all the rage - I was their PATCH manager - it was my job to keep an eye on all the non-committer, patches and keep them "in-view" of the committers - so they didn't get "lost".
👍 1
b
Documentation updates would be a great addition
Lucee has always fallen behind in the area of docs, so the help is great.
g
Perhaps we needs a "patch" guy, too?
After reading the ticket, I realise that an apache virtual directory / alias - won't help in this case either.
b
Yep, when Apache sees a request that ends in
.cfm
it doesn't even bother looking at its alises, it just shoves the request off to Lucee and says, "here, you deal with this!".
So Lucee must have a way to access the alias or have a matching mapping of its own or it won't know how to resolve the path
Adobe CF kept us from even having to think about this back in the day because their CF engine automatically got this information over their customized AJP connector so everything "just worked".