Print this page

"Previous load of class failed : MyApexClass" error

Knowledge Article Number 000181260
Description In Deployment Scenarios and while uploading a Managed Package, Partners get the following error :  Previous load of class failed : MyApexClass
Resolution In most scenarios, this error message is related to the "IsValid"  checkbox for the code which is being referred to in the message.

"IsValid" Checkbox is unchecked for an Apex Class or a Trigger when the metadata on which the code is dependent, has been changed and the code is not compiled after that. The code can be compiled by running the Run All Test, or clicking "Compile All Classes" link, or by Editing and saving that class, or by executing the code in the class. When the code is compiled, either an error message is displayed which can be rectified, or the code is saved successfully and the isValid checkbox is checked.

 
As per the link : http://na1.salesforce.com/help/doc/en/code_define_package.htm 
 
"To aid backwards-compatibility, classes are stored with the version settings for a specified version of Apex and the API. If the Apex class references components, such as a custom object, in installed managed packages, the version settings for each managed package referenced by the class is saved too. Additionally, classes are stored with an isValid flag that is set to true as long as dependent metadata has not changed since the class was last compiled. If any changes are made to object names or fields that are used in the class, including superficial changes such as edits to an object or field description, or if changes are made to a class that calls this class, the isValid flag is set to false. When a trigger or Web service call invokes the class, the code is recompiled and the user is notified if there are any errors. If there are no errors, the isValid flag is reset to true."

As per the link : http://na1.salesforce.com/help/doc/en/code_define_trigger.htm

"Triggers are stored with an isValid flag that is set to true as long as dependent metadata has not changed since the trigger was last compiled. If any changes are made to object names or fields that are used in the trigger, including superficial changes such as edits to an object or field description, the isValid flag is set to false until the Apex compiler reprocesses the code. Recompiling occurs when the trigger is next executed, or when a user re-saves the trigger in metadata."

So, if you receive the Error, go to the specific Class/Trigger -->Edit -->Save. If there are any errors,it will be rectified. If not, it will be recompiled and the "IsValid" checkbox will be checked automatically.

 




promote demote