Funky behavior with getModuleRoot()

When using getModuleRoot() in the file paths to images on a page I get the following error:

Element admin is undefined in a CFML structure referenced as part of an expression.

The code looks like this:

The odd thing is that if I pass the fwreinit query string in the url then the page loads fine. If I remove it again, I get the error again.

Have I adequately explained my problem?

I can validate that …

However, I have more detail about my error.

I used the method two different ways.

  • with a forward slash after the method:
  • #event.getModuleRoot()#/- without the forward slash:
  • #event.getModuleRoot()#


I took the basic CB3 Application Template within the “simple” directory.
I created a test directory and put the “simple” Application template in it.
I then edited one line of code - the line the deals with CB logo - to include the getModuleRoot method.

  • (file location): /views/home.cfm
  • Line 2

Line of Code that was changed:

  • Original:
  • ColdBox #rc.welcomeMessage#

    - Modified1:
  • ColdBox #rc.welcomeMessage#

    - Modified2:
  • ColdBox #rc.welcomeMessage#

Test Results:

Apache (test server - cf9 debug on, verbose on, line debug on):

ISS (production server - debug off): (same results with both changes)

Invalid CFML construct found on line 84 at column 33.

ColdFusion was looking at the following text:


The CFML compiler was processing:

  • A script statement beginning with modelMappings on line 84, column 17.
  • A script statement beginning with function on line 69, column 9.
  • A cfscript tag beginning on line 14, column 2.

My solution:

I just used either relative or physical paths. (the old fashon way)

I have no real solution within the framework. I have no real answers for you. But, I can confirm your issue and hope for a resolve.

  • Russell

I did find a viable solution to this problem.

Use the getSetting(‘htmlBaseURL’) method, instead of the getModuleRoot(). This method seems to work within any page - located anywhere within your app.

A note about getSetting(‘htmlBaseURL’) :

  • it only works in CB3. The routine does not exists in previous versions.
  • It needs to be encapulated within the tags.

The following are example of the syntax.




I hope this helps you.

  • Russell