Application and Request Scope Disapearing when accessed from a Coldfusion CFC via CFAjaxProxy

I'm having some strange behaviour in my CFC that is being called via CFAjaxProxy.

I have a page that uses cfajaxproxy to run a sql query.

All the functionallity is correct and it works just fine if I specify the exact datasource name string in the CFC.

The DSN ofcourse should be handled by either #application.myDSN# or

I have tried both the application scope and the request scope but then I get an error message saying:

"myDSN is not defined in Application" and "myDSN is not defiend in REQUEST".

I don't know why it looses these scopes.

Any advice would be greatly appreciated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

is you cfc in a folder NOT under the folder of Application.cfc/cfm ?
FastEddie___Author Commented:
Yes it is Not under the same folder in which application.cfm is located.
It is in a different directory which is still under the webroot in a folder called cfcomponents.
That directory has many other cfc's that use the #application.dsn# variable with no problem.
the other cfc (the ones that do work) are not accessed via cfajaxproxy, are they? otherwise they would not work either...

using cfajaxproxy and calling a cfc method via a js proxy is NOT the same as using crateobject or cfinvoke.

request-scope vars, and in your case - when your cfc is not under the Application.cfm - application-scope vars as well, will NOT be defined inside that call because this call is a completely separate request:
a) the request-scope vars defined in the calling page will not be available to remote cfc methods
b) since the cfc is NOT under the same application as the calling page, it can't see the application-scoped vars that the calling page can.

you have 2 choices:
1) pass the dsn name as an argument to your cfc method (you will need to edit the functions to accept that argument)
2) move the cfc to a location under the same Application.cfm as the page or set up an application proxy which extends your main Application.cfm in the cfc folder


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

FastEddie___Author Commented:
Yes Azadi, you are correct. The other cfc's are not accessed via cfajaxproxy.
Thank you very much for this explaination.
I'm curious about your solution #2. I'm using application.cfm not application.cfc.  
Is it possible to extend the .cfm file or do I have to convert it to a .cfc first?
>> Is it possible to extend the .cfm file or do I have to convert it to a .cfc first?

yes, you will have to convert it to Application.cfc in order to be able to extend it.
may be a good idea, since Application.cfc gives you so much more control over your app...

FastEddie___Author Commented:
Excellent.  Thank you.
FastEddie___Author Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.