3
votes

I am initiating a CFC:

<cfset config = new dir.dir1.config() />

This works fine. But suddenly and in my opinion without given reason it initiates:

<cfset config = new anotherdir.dir.dir1.config() />

Although the code shows the first instantiation and if I delete or rename the anotherdir.dir.dir1.config file it throws an error that the component can't be found.

Which circumstances can cause such behavior? I am at the end of the road with my wisdom.

1
First of all I thought there is some mapping somewhere in the application but there isn't. - Bernhard Kraus
I just found out that if I instantiate the component by <cfset configObj = new "/dir/dir1/config"() /> it works. How can be wrong with the dot notation? After I restart the CF service the issue is gone. - Bernhard Kraus

1 Answers

10
votes

When using dot notation, CF will first look at a path relative to the folder you are in. CF might be finding a cfc on a path relative to the file you are in before it checks a path from the root.

If your code says

<cfset config = new dir.dir1.config() >

and the file you are running your code in is in the directory 'anotherdir' then it will instantiate anotherdir.dir.dir1.config. If you are outside 'anotherdir' and a relative path cannot be resolved, it will attempt to find the component from the root directory.