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
SJTTSJTT 

java.lang.reflect.InvocationTargetException on saving Test Class

I am getting java.lang.reflect.InvocationTargetException when I am trying to edit and save an existing Test Class. The same test class, I am able to edit and save in another sandbox of the same Production instance. Any help is appreciated.

Best Answer chosen by Admin (Salesforce Developers) 
Ashish_SFDCAshish_SFDC

Hi SJTT, 

 

This is identified and is a known issue, R&D is working towards fixing the issue soon. 

 

Try the work around suggested, 

 

Workaround
Clear your test history from the UI (setup/develop/ApexTestExecution/ViewTestHistory/ClearTestResults), however, the condition will return after running all test and you will need to clear the test history again.

 

Also, add yourself to the "This issue effects me button" to notify the Impact and also to keep a track. 

 

https://success.salesforce.com/issues_view?id=a1p30000000T17j

 

 

Regards,

Ashish

All Answers

AidanAidan

Can't directly help you, but I'm getting the same error.

 

The only workaround I've found is to delete the class and recreate it. But as soona as you run your tests, it goes wrong again.

Ashish_SFDCAshish_SFDC

Hi SJTT, 

 

This is identified and is a known issue, R&D is working towards fixing the issue soon. 

 

Try the work around suggested, 

 

Workaround
Clear your test history from the UI (setup/develop/ApexTestExecution/ViewTestHistory/ClearTestResults), however, the condition will return after running all test and you will need to clear the test history again.

 

Also, add yourself to the "This issue effects me button" to notify the Impact and also to keep a track. 

 

https://success.salesforce.com/issues_view?id=a1p30000000T17j

 

 

Regards,

Ashish

This was selected as the best answer
SJTTSJTT

Thanks Ashish.

 

The workaround helped. But its reallly troublesome to go and clear test history after each test run. Hope sfdc resolves this fast.

FletchFletch

https://success.salesforce.com/issues_view?id=a1p30000000T17j states that this is fixed on CS30.

 

It is not.  I am still having the same problem.

Glenn WeinsteinGlenn Weinstein

I don't believe that "known issue" (https://success.salesforce.com/issues_view?id=a1p30000000T17j), which is marked as "Fixed", is the same issue.  

 

That issue says you get "An unexpected error has occured." when saving Apex.  But the current (unresolved) issue is that you get "Visualforce Error: java.lang.reflect.InvocationTargetException" when saving Apex.

 

 

 

Ashish_SFDCAshish_SFDC

Hi Fletch, 

 

Clear your test history from the UI "setup/develop/ApexTestExecution/ViewTestHistory/ClearTestResults and try again now. 

 

Regards,

Ashish

Ashish_SFDCAshish_SFDC

Hi Glenn, 

 

Usually Salesforce doesnot throw the direct java error but throws an error like this "An unexpected error has occured. 1633970562-57921 (1021097749)" but sometimes the errors like "java.lang.reflect.InvocationTargetException" also come up. 

 

Regards,

Ashish

FletchFletch
Hi Ashish, clearing the test history does allow me to save but the problem then recurs after running more tests.

The point I am making is that the problem is not fixed on the CS30 instance, despite the issue page stating that it is.

The problem itself delays rather than blocks development work so we can live with your workaround in short term, I just wanted to make it clear that it isn't fixed yet!
Ashish_SFDCAshish_SFDC

Hi Fletch, 

 

Thank you for brining this up, will put this forward. 

 

Regards,

Ashish

Baird_SBaird_S

Am having same problem while trying save a test class.  Attempted to save an empty test class to test it - got the same error.  It manifests a little differently in BrainEngine (unexpected error 2122083432-31331 (120197083) ) and the IDE, but it seems to be the same thing.

 

 

 

 

Ashish_SFDCAshish_SFDC

Hi Fletch and Baird, 

 

This would need specific troubleshooting, hence Please log a support case with the details so that one of our reps according to your timezones will assist you further. 

 

Regards,

Ashish