We help IT Professionals succeed at work.

components being called issue!

422 Views
Last Modified: 2013-12-24
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!
Comment
Watch Question

CERTIFIED EXPERT

Commented:
If it is out side ur admin folder u cannot call that  using  "components.abc" it  will search for components folder in the admin folder it self .

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

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
(no points ...)

@srikanthmadishetti - yes, but they should be able to create a Mapping for the "components" folder. Then it should work.
CERTIFIED EXPERT

Author

Commented:
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
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
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.
CERTIFIED EXPERT

Commented:

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","components.abc")>


 /wwwroot/components/abc.cfc
CERTIFIED EXPERT

Author

Commented:
well it is like wwwroot/websitename/components

CERTIFIED EXPERT

Commented:

> well it is like wwwroot/websitename/components

which is the root folder?

If you go to www.yourdomain.com which folder are you in?

wwwroot/websitename/

or

wwwroot/



CERTIFIED EXPERT

Author

Commented:
this one:

wwwroot/websitename/
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
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.

CERTIFIED EXPERT

Commented:
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/components


This is the folder that contains this command:  <cfset a = CreateObject("component","components.abc")>

wwwroot/websitename/admin



Seems like it should work as is.
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
@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 ?

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
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/components


What does #ExpandPath("/")# return ?
CERTIFIED EXPERT

Commented:
@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 .



CERTIFIED EXPERT

Commented:
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.websitefolder.cfcname")>

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.websitefolder" />
<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"() />







CERTIFIED EXPERT

Author

Commented:
thanks
CERTIFIED EXPERT

Commented:

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","components.abc")>  should have worked just fine without the need for a mapping.


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.


CERTIFIED EXPERT

Commented:

Be sure to try this..

<cfset a = CreateObject("component","websitename.components.abc")>
CERTIFIED EXPERT

Author

Commented:
did a try but itsay components interface not found!

actually the folder is like this:

myname.com.components.abc

CERTIFIED EXPERT

Commented:


> actually the folder is like this:
> myname.com.components.abc

so your folder structure is exactly like this?

 C:/wwwroot/myname/com/components/abc.cfc ?


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.

CERTIFIED EXPERT

Author

Commented:
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
CERTIFIED EXPERT

Commented:
> 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/components/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/components/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("/")#</cfoutput>


This would be a lot easier if you could answer a question clearly and completely.
CERTIFIED EXPERT

Author

Commented:
it is like this:

C:/wwwroot/myname.com/components/abc.cfc  ?

ok i if put

 <cfoutput>#ExpandPath("/")#</cfoutput> in Application.cfc, and index.cfm  i get the following:

it shows nothing means nothing


CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
>> 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 ;-)
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
>>  That's the exactly the problem.

Ugh.  Typo correction:  That's exactly the problem ...
CERTIFIED EXPERT

Author

Commented:
where i should i mark and give points to gdmeria
CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
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/Software/Server_Software/Web_Servers/ColdFusion/Q_26319942.html?cid=748#a33183246
CERTIFIED EXPERT

Commented:

 Thanks agx !

  and thanks myselfrandhawa, hope it works for you

CERTIFIED EXPERT
Most Valuable Expert 2015

Commented:
gdemaria - You're welcome :)

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.