ColdFusion Component gets initiated from wrong path

174 views Asked by At

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

There are 1 answers

1
beloitdavisja On BEST ANSWER

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.