• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

relocate wwwroot to different drive - CF2023/Tomcat/VSCode/CFBuilder

Community Beginner ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

I am getting File Not Found when trying to move the WWWROOT directory to another drive with CF2023 and VSCode/CFBuilder.

As a note, I have not setup any of the following components before so the issues are due to that.

 

I installed the following on a win 10 laptop to try for CF development.

Coldfusion 2023 Dev (ColdFusion_2023_WWEJ_win64) with Tomcat

VSCode (VSCodeUserSetup-x64-1.87.2)

And added CFBuilder to VSCode.

The default Coldfusion wwwroot is at C:\ColdFusion\cfusion\wwwroot

I need to change the wwwroot to D:\mydir\wwwroot but have been unable to make it work. I get a file not found before it even gets to the web page.

The closest I have got was to add a Linked directory to the project and it now launches the web to D:\mydir\wwwroot\index.cfm and then shows the File not found on the web page. I looked in the error log and it shows:

Error [http-nio-8500-exec-1] - File not found: /WebTest/index.cfm  The specific sequence of files included or processed is: C:\ColdFusion\cfusion\wwwroot\WebTest\index.cfm''

It’s running /WebTest/index.cfm  in d:\mydir\wwwroot but then going back to C:\ColdFusion\cfusion\wwwroot\WebTest\index.cfm' which it cannot find since it isn’t there.

 

Instead of figuring out what I did wrong, can someone tell me how to move the wwwroot from the default location to another Drive location correctly?

Views

461

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Terry, there will be great value in first separating the discussion of cf and CFBuilder. The latter should be configured only once the former is working. 

 

So you're wanting your cf code to be in other than the default cfusion/wwwroot. To be clear, one does not HAVE to use that folder, and indeed many never put their code in there. But I find that what most do instead (and the cf docs show) is to implement a web server (iis or apache) and tell THAT where the files are and then configure the web server to pass cf requests to cf. (The cf docs don't discuss using nginx, but that's possible as well.) 

 

As for that cfusion/wwwroot folder, that's used instead by cf's built-in web server, typically accessed as port 8500. I assume that's what you're trying to keep on using for now, right? (You may prefer not to bother with setting up another web server, I mean.) And that's where you'd then like to tell cf and that builtin web server (which is in fact Tomcat's web server) to look elsewhere than this cfusion/wwwroot.

 

And I'll say that there IS a way to do that. To be clear, there is NO feature in the cf admin or some installer choice where you name a different folder. But there are config files within cf (again, technically tomcat config files) where one can try to do that.

 

But here's one problem with that. As you may know, the files for the cf administrator are also in that cfusion/wwwroot. If you DO try to modify the config files to point to another folder, you'd need to do it in a way that doesn't lose access to the cf admin and other files there. 

 

Can it be done? Yes. But again it's not a simple matter, and the simpler solution (to most) is to just use another web server for your app, which means cf's config files literally know nothing about where the site's files are, as that's the "external" web server's concern.

 

Is that what EVERYONE does to setup their cf development environment? No. Some just default to putting their files in the cfusion/wwwroot. Others use Commandbox (which technically implements its OWN web server/app svr, called undertow).

 

But again one COULD configure cf's (tomcat) config files to point to another folder, or even try to use the Tomcat virtual hosts feature within those files. But I want to say again that Cf does not facilitate this in any way: it's not in the installer or admin, nor is it documented at all. In fact, I'm not aware that anyone's blogged on it--but it's a good idea for someone to consider if not, and I may. Heck, I've written its introduction/problem statement here. 🙂

 

Hope that helps, as a start. Someone may well offer a "simpler" answer, or might point to a resource showing having done it in cf (and hopefully safely, not breaking the admin). 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Thanks for the information. It definitely confirmed what I was looking for.
The reason I was looking at this solution is that because of our security
structure I cannot access the file structures directly from our development
systems so I am trying to set up the environment locally on the laptops and
have the web files on a shared drive. I'll look into the Tomcat setup to
see if I can get that to work and also see if there is any other solution
using the remote servers.

Thanks again.

--

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Terry, a few thoughts and also a possible solution for you.

 

1) First, when you say this is a security issue that "because of our security structure I cannot access the file structures directly from our development systems", are you referring to a remote server that has CF setup, and how you can't access the cfusion/wwwroot in that also? 

 

And so then you add, "I am trying to set up the environment locally on the laptops and have the web files on a shared drive". By that you mean that you will setup a local CF dev instance (good), and rather than "put the code in the cfusion/wwwroot" there, you want instead to point to the code on a shared drive, right? That can indeed be done.

 

Again I'll say first that others solve that readily by just putting a web server on their local CF dev machine (whether IIS or Apache), and configure THAT to find the files on that other folder (or shared drive), and then finally use CF's "web server confiuration tool" to connect that site to the local CF instance.

 

2) That said, and back to my previous response about setting up Tomcat (and as Dave referred to in his subsequent reply), I'll say now that there's a solution I've used that MAY work for you.  It's not about "changing CF to use another folder as its webroot" (as your original request sought).

 

Instead it's about adding to this Tomcat configuration what in other web servers would be considered a "virtual directory" or "alias" configuration. The goal for this would be that when you make a request for a given folder, like localhost:8500/bob/somefile.cfm, the web server would be told to find the code for that "bob" path in a given folder that does NOT need to be in that cfusion/wwwroot, where it would expect to find it by default. (Again to be clear, this is NOT about changing it to think that a request for / should find files in a location other than the cfusion/wwwroot, as that has broader ramifications.)

 

And at least one way to do that (in the modern Tomcat versions that recent CF versions support) is to use what's called a tomcat "preresource" definition, which can be put in the server.xml file of your CF instance (in the cfusion/runtime/conf folder). There are no such presources in there by default, as CF comes packaged. And if you're going to change this file, as Dave said be sure to back it up somehow.

 

Then in an otherwise stock CF server.xml file, at the bottom just above the closing </host> element, you could put in code like this (changing the paths pointing to CF to be correct for your own environment). Note how I have defined effectively an alias (a "webmount") for your /WebTest folder, telling Tomcat/CF that its files should be found in D:\mydir\wwwroot\WebTest:

 

 

<Context path="" docBase="C:\ColdFusion2023\cfusion\wwwroot" WorkDir="C:\ColdFusion2023\cfusion/runtime/conf/Catalina/localhost/tmp" >
  <Resources>
    <PreResources base="D:\mydir\wwwroot\WebTest" className="org.apache.catalina.webresources.DirResourceSet" webAppMount="/WebTest"/>
  </Resources>
</Context>

 

 

Note also that the xml elements and attribute names are all CASE-SENSITIVE, even on Windows which is otherwise NOT. But the folder paths are not, nor even is that webmount value--on a Windows machine, I mean. One could request either localhost:8500/WebTest  or localhost:8500/webtest (which may surprise some, because even on Windows Tomcat can be case-sensitive about some request URLs). I just followed your lead in the casing of those webmount and base attribute values for WebTest.

 

Once you put this code in place and restart CF (and assuming it comes up ok, and that as a test you can still acces your CF Admin ok), you should find you can now access the CF files that are outside the cfusion/wwwroot. I use this myself on all my machines, for accessing one particular set of files that I leave in Dropbox to access from within all my CF instances. In that case, the folder is not a "shared drive" in the classic Windows sense, but I think you should find this works--whether using a mapped drive or a UNC path, etc. Let us know.

 

Again, this "aliased path" approach is not the right solution for everyone (as they may not want to "have to define a bunch of these preresource lines for each top-level folder they need to access"). They may prefer then to really CHANGE what CF regards as the root--and that's where I said that could get sticky. I know Dave said in his later reply that doing it should not affect the CF Admin, but I really think it would. And again I've not yet done or seen anyone do that.

 

But I wanted to share it as an option, whether it works for you or may for others who later find this thread.

 

Finally, if the restart of CF fails (or testing of the CF Admin doesn't work), note how I had proposed those lines for a STOCK server.xml for CF2023 (though it should work as well for CF2021 and 2018, at least). If your server.xml for some reason had been modified already to have already an uncommented "context" element like I show, then mine above would be in conflict with that. Try putting just the resources elements inside that existing context elment you may have. (While a stock server.xml for CF has such a context line as installed out of the box, it's commented out by default.)

 

3) This approach is a pure Tomcat way to effect the sort of redirection that Dave was getting at with his consideration of using operating system hard links/symlinks. That can have ramifications beyond just the CF/Tomcat setup that some may be unwilling or unable to use. I hope the above might help.

 

4) As for your final reference to "using the remote servers" seems perhaps to be referring to a remote CF instance. Is that right? And might you be referring to how to setup CFBuilder to refer to that? If so, you can, but let's put that aside for now.  If we first fix your local CF setup, that might inform how you or others may configure that remote CF servers (but perhaps it's already setup), but THEN we can tackle  how to setup your CFB for both that local and remote CF instance (and the code, wherever it may be for those). 

 

CF setup can be complicated enough for those who don't deal with it often. When you introduce multiple  potential code locations, and dealing with both local and remote CF instances, that can fluster many. And when you add in trying to access all that in CFBuilder (which many struggle with out of the box, for various reasons), that can become quite a hornet's nest.

 

5) To my last point, I'll add that I do make my living helping people untangle such knots (in CF, CFBuilder, Lucee, and related things), whether for free here in the forums (along with Dave and many other helpful folks) or via remote screenshare consulting (carehart.org/consulting). If ever you run out of steam to power through things on your own and/or with our help, just know you don't need to "go it alone"...but I certainly understand that some won't or "can't" pay for assistance. 

 

But let us know if the workaround above helps you.


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

To answer your question, our servers are All CGIS compliant and all ports
closed accept those absolutely needed with multilevel security. This is
driving us to create a development environment that is not on the servers.
I am setting up the system so that CF and VBCode/CFBuilder are on the
laptops and the files are on a shared drive so all could access them as I
thought this would be the easiest way for now. A CI/CD solution would be
implemented later.

Our current production servers are using IIS and are actually doing what I
am trying to do locally. My concern is that the last time I set up IIS was
20+ years ago and it was a nightmare. Compared to the other solutions
suggested, would it be better to just install IIS or to try the other
solutions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

LATEST

Only you can make that call. My last option is a simple single file change. If it works for you, great. 

 

But I'll clarify that I've said more than once that using a web server (like iis) is far more common. And setting it up should take a matter of minutes, but I appreciate you may recall it being more daunting.

 

You've made it clear this is a work-related requirement, so perhaps you could get authority to cover a half hour of time with me (we'd probably not even need that long). But I realize you may be in a situation where even that's "not possible". You can find many free resources on setting up iis, and the cf docs and other resources show how easily to configure cf with such web servers. Or you can ask here...but I'd recommend creating a new discussion thread on that, as it's not related directly to this. 


/Charlie (troubleshooter, carehart.org)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

You're making this more complicated than it has to be. Or at least, differently complicated! First, you can go to Tomcat directly and change the appropriate XML file(s). Here's the Apache documentation for doing that:

 

https://tomcat.apache.org/tomcat-9.0-doc/config/context.html

 

To make this easier, I'd search the Tomcat directory looking for anything beginning with "C:\ColdFusion\cfusion\wwwroot" and replace it with whatever you want. I don't think you'll have to worry about the CF Administrator as I seem to recall it's specified as a URL path from the wwwroot location - but I could be wrong! So, backup your XML files and/or take notes on what you changed.

 

If this turns out to be more difficult than you want to pursue, you could also create a "hard link" that points to the new location. Stop the CF service, create a new directory at the appropriate location by moving the old directory, use the "mklink" tool to create a hard link pointing C:\ColdFusion\cfusion\wwwroot to the new directory. It would probably be easier if you left the directory names and paths alone and just changed the drive letter.

 

Dave Watts, Eidolon LLC 

 

 

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

Thanks, I'm definitely over thinking this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation