+ Start a Discussion
andrew taylor 3andrew taylor 3 

Lightning - Controller Error

I'm following the example shown on Peter Knolle's post here: https://developer.salesforce.com/blogs/developer-relations/2015/03/lightning-component-framework-custom-events.html

When creating the contactSearch Component, I'm getting the following error:

"Failed to save undefined: No CONTROLLER named apex://mynamespace.ContactSearchController found: Source"

I'm not sure what I've missing - any thoughts?
Ajay K DubediAjay K Dubedi
Hi Andrew...
I have seen the example the hierarchy of example is wrong.I think the error you got may be because you save the component with controller name before creating the controller or may be because of your namespace. Use the below link it is salesforce lightning guide :

Please let me know if this is help you.

Ejaz MullaEjaz Mulla
I am getting the same error, the namespace is correct. I tried with controller = "namespaceName.controllerName" and also with controller = "controllerName". Please help.
Leandro ValdesLeandro Valdes
I'm getting a similar erro with the tutorial "Create a Lightning Component".

I created the controller first and still ahving the issue.

The error message is "Failed to save undefined: No CONTROLLER named apex://lvv.MyContactLestController found: Source". I don't know if this is related to my dev org having a namespace prefix?
Sebastian Ortiz 1Sebastian Ortiz 1
Closing and reopening the lightning component in the Dev Console did the trick for me. Just then I was able to set the controller attr by using namespace.class_name (omit namespace if your Org doesn't have one set)

Hope it helps.
Leandro ValdesLeandro Valdes
That didn't work for me. :(
GGE SalesGGE Sales
I have the same issue, I'm using a dev org in which I have a managed package. I am attempting to complete the challenge for the section "Using Apex in Components" 

I am definitely using the correct namespace and I created the apex controller before the component so it definitely exists. 
Simon FSimon F
I wasn’t able to resolve this by deleting the component/class and starting again. Adding the namespace didn’t work either.
I eventually got this working by switching to a new Developer Org instead of my usual one.
Try creating a new Developer Org and then create the component. You can then connect trailhead to the new org, complete the challenge and then switch trailhead back to the original org.  
Adrian ChiewAdrian Chiew
Had this exact problem. I tried deleting the Apex Class, and creating it again.

This did the trick, and I was then able to reference the Class in the Component and save it.
Mahesh AdiMahesh Adi
I have the same problem, I tried all the above but no use. Is there any other solution for this?
Dima 8Dima 8
I had the same problem and I was able to fix
1 - closed everything in the console
2 - logged out
3 - closed my browser
4 - logged in
5 - opened my component and put some other old class that I had in the system as controller
6 - it saved successfully
7 - changed it to new class name and saved
Anand SinghAnand Singh
I was able to resolve this issue by appending 2 underscores after namespace)
<aura:component controller="MyNamespace__.MyContactListController">

Once the lightning component is saved, it will display the code as:
<aura:component controller="MyNamespace.MyContactListController">

Hope this helps.
Ben NaylorBen Naylor
I did Steps 5->7 of Dima 8, and it worked. So to be clear I did this:
1. Save the component with a random class you currently have in the system
2. Change the class to what you want it to be, and press save

Good times.....
Nitish SinghalNitish Singhal
Thanks Dima 8 and Ben Naylor.. it worked for me by following steps 5 --> 7
Vyankatesh Choulwar 15Vyankatesh Choulwar 15

I deleted the existing controller and then created new one and new one defined in controller of Aura:component.
It worked for me.

Hope this helps for you as well!!!

Happy Lightning!!! :)

Mahesh AdiMahesh Adi
I resolved this issue by appending 2 underscores after namespace.
<aura:component controller="MyNamespace__.MyContactListController">  
This worked :)
Jayamaruthyraman JaganathJayamaruthyraman Jaganath

The double underscore approach worked for me and thanks for the suggestion. Any idea where it is documented?


Bhuvan PashamBhuvan Pasham
Same exact issue - and double underscore approach working. Once the the component is successfully saved - you can remove the namespace part and it will still save with or without namespace prefix. This looks more like a bug than a feature. It seems like when we use the ns__. option, developer console is forcing metarefresh on the controller. Looks like @Anand_Singh just found an easter egg :)
Thanks for saving my night.
Chirag MehtaChirag Mehta
Yes. We need to first add namespace__. save it and then once saved, remove it and re-save it.

Reason why I had to remove it is because one of Trailhead challenge too assumes there's no namespace__. else it wasn't verifying the step :( 
Sangeetha MadrasiSangeetha Madrasi
ANy of the above solution didn help me

totally stuck help pls...!!!!!!!!!!
sravani adirajusravani adiraju
Dima8 's idea worked for me - try with some other controller and re-change controller name ! Done... :) Thanks Dima
Martina PastorkovaMartina Pastorkova
I have been trying to do this "easy" module and I can not solve the problem.  Nothing works for me, any idea, how the APEX should look like?  I have tried all the above recommendations but nothing works.

Thank you!!!

I had the same issue with the "Create a Lightning Component" unit.

I had to create a new Apex Class in Developer Console for this to work properly.

Go to : File > New > Apex Class

Name it the same as your controller. Then click File > SAVE.

Then go back to your Lightning Component and add the controller="MyContactListController" to the aura: component tag and click File > Save.

pooja sharma 137pooja sharma 137
I created apex class with the same name of controller and i was able to resolve this issue.