Generally we get this error when we are not doing type casting properly.
Recently I got this error when I am saving the below apex class.
Apex class :
public class OpportunityStatusChartController {
public Opportunity opp;
public OpportunityStatusChartController(ApexPages.StandardController std) {
opp=(Opportunity) std.getRecord();
}
}
Error:
Even though code is correct,I am getting this error.
Finally I understood that a class with name "Opportunity" is created in my instance
which is causing this error.
Solution: When ever you face this error,please check whether a class with that name
is created and if a class exists,delete it
Recently I got this error when I am saving the below apex class.
Apex class :
public class OpportunityStatusChartController {
public Opportunity opp;
public OpportunityStatusChartController(ApexPages.StandardController std) {
opp=(Opportunity) std.getRecord();
}
}
Error:
Even though code is correct,I am getting this error.
Finally I understood that a class with name "Opportunity" is created in my instance
which is causing this error.
Solution: When ever you face this error,please check whether a class with that name
is created and if a class exists,delete it