ColdFusion component initiating from the wrong path

I initiate CFC:

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

      

This works great. But suddenly and in my opinion for no reason, it initiates:

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

      

Although the code shows the first instance, and if I delete or rename the file anotherdir.dir.dir1.config

, it throws an error that the component cannot be found.

What circumstances might cause this behavior? I am at the end of the road with my wisdom.

+3


source to share


1 answer


When using dot notation, CF will first consider the path relative to the folder you are in. CF can find cfc in a path relative to the file you are in before it checks the path from the root.

If your code says



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

      

and the file where your code is executed is in the 'anotherdir' directory, after which anotherdir.dir.dir1.config instance will be created. If you are outside of 'anotherdir' and the relative path cannot be resolved, it will try to find the component from the root directory.

+10


source







All Articles