function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
OnDem DevOnDem Dev 

Dependent class is invalid and needs recompilation. Why and when does this error comes



I am getting the below error when i try to save my Apex Controller.


line -1, column -1: Dependent class is invalid and needs recompilation: <Namespace.ApexClassName>: <line No> Didn't understand relationship '<Custom Object Name>' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.


I checked my WSDL file and could see the field in that Object.


Can anyone help me why is this issue being faced.





If you modified a class and other classes use an instance of that class might need recompile, you can simply click the edit button and then save it to finish recompile.

OnDem DevOnDem Dev

Finally was able to resolve it.

But it was a strange experience and struggled a lot to come out of the issue.


Had to delete the Apex class and recreating them resolved the issue.


Can anyone tell why was this required?




Message Edited by OnDem Dev on 08-24-2009 01:24 PM

I was getting the same error while trying to run my tests, what it came down to was that I had an @future callout:

@future (callout=true)

public static void qry_andSend2sys(string id, string sys2go2) { ...


 What happend was I added the 2nd parameter "string sys2go2" after running successful tests.  I never added the 2nd parameter in my test class/call (just forgot about it).  Once I added it, the problem went away.


I just came accross this error, it was because i was using a Static type method.

This error is thrown when changes are made in one class which is dependant on the other.
For example :

--  Class1 : method  calls the method from class2
--  Class2 : method calls the method from class1
--  Both classes are depandant on Class3.
--  Now if I add a variable in Class3 which are used both in Class1 and 2.
-- Then in class1 comment the code where class2  method is called do changes and save. Then make      changes in class2, save it. Finally uncomment the               method  call in class1.
-- If its not done then this error will be thrown.
Mark Tyler CrawfordMark Tyler Crawford
When I had this error I simply needed to resave the classes that were listed. 
1. To compile Classes:
                Go to Setup | Develop | Apex Classes 
                Click 'Compile all classes' Link
2. To compile Triggers:
               Go to Setup | Develop | Apex Triggers
               Click 'Compile all triggers' Link