Coast Line
asked on
components being called issue!
i have a folder named ADMIN and a folder named COMPONENTS
now my Application.cfc which is inside the admin folder, i am calling the CFC as: Please note COMPONENTS Folder is outside the ADMIN Folder
So abc is the CFC inside the components folder:
<cfset a = CreateObject("component"," components .abc")>
now i run a page i poften get two kinds of eror:
1. coldfusion compoenet or instance not found!
2. Element ABC is undefined in a Java object of type class [Ljava.lang.String; referenced as
Please guide!
now my Application.cfc which is inside the admin folder, i am calling the CFC as: Please note COMPONENTS Folder is outside the ADMIN Folder
So abc is the CFC inside the components folder:
<cfset a = CreateObject("component","
now i run a page i poften get two kinds of eror:
1. coldfusion compoenet or instance not found!
2. Element ABC is undefined in a Java object of type class [Ljava.lang.String; referenced as
Please guide!
(no points ...)
@srikanthmadishetti - yes, but they should be able to create a Mapping for the "components" folder. Then it should work.
@srikanthmadishetti - yes, but they should be able to create a Mapping for the "components" folder. Then it should work.
ASKER
hmm! i was aware of that thing! i asked for confirmation that if somehow something is possible and u said mappings! that need access to cfadmin and if u tell me how! we can solve it
Sorry, you must have access to the CF admin (or restricted files) to create a mapping. There's no way around it. If there's a custom tag folder *that's already defined* in the CF admin, like c:\ColdFusion8\CustomTag, you could put your "components" folder inside that directory.
If you don't have access to either one, then AFAIK it's not possible.
If you don't have access to either one, then AFAIK it's not possible.
I could be wrong, but I didn't see this covered in the thread..
Is the "components" folder at the root?
The createObject starts at the root, so the path must be from the root folder down.
In this case components folder must be at the root level, if not add the other folders to it.
<cfset a = CreateObject("component","
/wwwroot/components/abc.cf
ASKER
well it is like wwwroot/websitename/compon ents
> well it is like wwwroot/websitename/compon
which is the root folder?
If you go to www.yourdomain.com which folder are you in?
wwwroot/websitename/
or
wwwroot/
ASKER
this one:
wwwroot/websitename/
wwwroot/websitename/
Wait .. I may have totally misunderstood this. I thought "components" was outside the web accessible folders entirely. If "components" IS inside any web accessible folder, then you *can* access it simply by using an absolute path as gdemaria said.
agx, this is the way I understand it.. I could be wrong of course..
This is web root
wwwroot/websitename/
This is where the cfc is located..
wwwroot/websitename/compon ents
This is the folder that contains this command: <cfset a = CreateObject("component"," components .abc")>
wwwroot/websitename/admin
Seems like it should work as is.
This is web root
wwwroot/websitename/
This is where the cfc is located..
wwwroot/websitename/compon
This is the folder that contains this command: <cfset a = CreateObject("component","
wwwroot/websitename/admin
Seems like it should work as is.
@gdemaria - I think you're on the right path. When you describe it that way, I was thinking it should work too. But I'm wondering what CF considers the "webroot" in this context. Maybe it's not really
wwwroot/websitename/
... and that's why CF can't find it ?
wwwroot/websitename/
... and that's why CF can't find it ?
To clarify that last comment, one of the places CF looks is in the web root. So if CF thought the web root was something else, like
wwwroot/
Then
<cfset a = CreateObject("component"," components .abc")>
... might not work, because the "components" folder isn't directly under the web root. So CF might be looking:
wwwroot/components
Not here:
wwwroot/websitename/compon ents
What does #ExpandPath("/")# return ?
wwwroot/
Then
<cfset a = CreateObject("component","
... might not work, because the "components" folder isn't directly under the web root. So CF might be looking:
wwwroot/components
Not here:
wwwroot/websitename/compon
What does #ExpandPath("/")# return ?
@agx
"
@srikanthmadishetti - yes, but they should be able to create a Mapping for the "components" folder. Then it should work."
I actually mentioned that the current path which he is mentioning is wrong and gave how the path is being searched and it's up to myselfrandhawa how he wants to point now , he wants mapping which is good but need cfadmin access or want to use the webroot stuff create a component folder in webroot and place all files there .
I think my comment pretty much cover all the info he needs .
"
@srikanthmadishetti - yes, but they should be able to create a Mapping for the "components" folder. Then it should work."
I actually mentioned that the current path which he is mentioning is wrong and gave how the path is being searched and it's up to myselfrandhawa how he wants to point now , he wants mapping which is good but need cfadmin access or want to use the webroot stuff create a component folder in webroot and place all files there .
I think my comment pretty much cover all the info he needs .
to clarify
webroot is wwrwroot folder of our coldfusion installation .
Our application folder can be any where depending the type of webserver we use for example if we use IIS we may create some where outside wwwroot and create a virtual mapping.
so best way which i do is go to wwwroot folder create a folder called components and under that folder create ur website folder and place all cfc of that website under that folder
u can access them directly like this
<cfset obj = createobject("component"," components .websitefo lder.cfcna me")>
if cf9 then
CreateObject() In ColdFusion 9 No Longer Requires The Type Parameter
<cfset obj= createObject( "components.websitefolder. cfcname" ) />
u can even use this the best one
<cfimport path="components.websitefo lder" />
<cfset obj= new cfcname() />
and for even best one we can create like this using dynamic class path
<cfset cfcroot = "components.websitefolder" >
<cfset obj = new "#cfc_root#.cfcname"() />
webroot is wwrwroot folder of our coldfusion installation .
Our application folder can be any where depending the type of webserver we use for example if we use IIS we may create some where outside wwwroot and create a virtual mapping.
so best way which i do is go to wwwroot folder create a folder called components and under that folder create ur website folder and place all cfc of that website under that folder
u can access them directly like this
<cfset obj = createobject("component","
if cf9 then
CreateObject() In ColdFusion 9 No Longer Requires The Type Parameter
<cfset obj= createObject( "components.websitefolder.
u can even use this the best one
<cfimport path="components.websitefo
<cfset obj= new cfcname() />
and for even best one we can create like this using dynamic class path
<cfset cfcroot = "components.websitefolder"
<cfset obj = new "#cfc_root#.cfcname"() />
ASKER
thanks
Mapping is a good last resort. I would not use a mapping unless the components folder is outside the webroot.
It could lead to errors if one of your websites creates a local folder called components.
The webroot is the defined to be the website's folder located at "/"
I prefer to keep application specific code together under the application rather than mixing it in with other code.
IMHO, the best way to do components is under the webroot so you're not mixing code from different apps in a folder.
<cfset obj= createObject( "components.cfcname" ) />
@myselfrandhawa, if this "wwwroot/websitename/" really is your webroot, then this
<cfset a = CreateObject("component","
As agx suggested, you should check #ExpandPath("/")# and see what that returns. If it does not return "wwroot/websitename/" then you have more problems.
I recall an asker on EE had two webroots for an application. One root accessed via http://myapp.domain.com and the other web root accessed by www.domain.com/myapp/ Each one pointed to a different folder. If that is your situation, you have a significant problem that needs to be addressed before you go much further.
Be sure to try this..
<cfset a = CreateObject("component","
ASKER
did a try but itsay components interface not found!
actually the folder is like this:
myname.com.components.abc
actually the folder is like this:
myname.com.components.abc
> actually the folder is like this:
> myname.com.components.abc
so your folder structure is exactly like this?
C:/wwwroot/myname/com/comp
and what do you get when you run this?
#ExpandPath("/")#
This would be a lot easier if you could answer a question clearly and completely.
ASKER
website name is: myname.com
components folder is: myname.com.components.abc
i have defined in Application.cfc as:
<cfset Application.path = myname.com.components>
<cfset Application.abc = #application.path#.abc>
and that shows error
components folder is: myname.com.components.abc
i have defined in Application.cfc as:
<cfset Application.path = myname.com.components>
<cfset Application.abc = #application.path#.abc>
and that shows error
> components folder is: myname.com.components.abc
that is NOT a path to a folder. Folder paths have / and a directory letter (assuming windows)
Something like this: C:/wwwroot/myname/com/comp onents/abc .cfc ?
This "myname.com.components.abc " may be the path you are entering for the CFC, but I want to know what DIRECTORY it is in.
Is it this: C:/wwwroot/myname/com/comp onents/abc .cfc ?
And what do we have to do to get you to answer this question?
Put this in your code and let us know what is displayed:
<cfoutput>#ExpandPath("/") #</cfoutpu t>
This would be a lot easier if you could answer a question clearly and completely.
that is NOT a path to a folder. Folder paths have / and a directory letter (assuming windows)
Something like this: C:/wwwroot/myname/com/comp
This "myname.com.components.abc
Is it this: C:/wwwroot/myname/com/comp
And what do we have to do to get you to answer this question?
Put this in your code and let us know what is displayed:
<cfoutput>#ExpandPath("/")
This would be a lot easier if you could answer a question clearly and completely.
ASKER
it is like this:
C:/wwwroot/myname.com/comp onents/abc .cfc ?
ok i if put
<cfoutput>#ExpandPath("/") #</cfoutpu t> in Application.cfc, and index.cfm i get the following:
it shows nothing means nothing
C:/wwwroot/myname.com/comp
ok i if put
<cfoutput>#ExpandPath("/")
it shows nothing means nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> Here is your problem. You have a "." in the name of your folder.
@gdemaria - Great detective work. That's the exactly the problem.
@myselfrandhawa - IMO, I'd reopen this question and mark 33183246 as the correct answer (because it is ;-)
@gdemaria - Great detective work. That's the exactly the problem.
@myselfrandhawa - IMO, I'd reopen this question and mark 33183246 as the correct answer (because it is ;-)
>> That's the exactly the problem.
Ugh. Typo correction: That's exactly the problem ...
Ugh. Typo correction: That's exactly the problem ...
ASKER
where i should i mark and give points to gdmeria
You can use the "Request Attention" link (bottom right of your original question). You can ask the moderators to reopen the question, so you can reassign points. Once it's reopened, you can assign points to the right answer, which is
https://www.experts-exchange.com/questions/26319942/components-being-called-issue.html?cid=748&anchorAnswerId=33183246#a33183246
https://www.experts-exchange.com/questions/26319942/components-being-called-issue.html?cid=748&anchorAnswerId=33183246#a33183246
Thanks agx !
and thanks myselfrandhawa, hope it works for you
gdemaria - You're welcome :)
If you use a cfinvoke or cfobject tag, or the CreateObject function to access the CFC from a CFML page, ColdFusion searches directories in the following order:
Local directory of the calling CFML page
Directories specified on the ColdFusion Mappings page of the ColdFusion MX Administrator
Web root
Directories specified on Custom Tag Paths page of the Administrator