ClassCastException error on generating offline symbol table

Issue #803 resolved
Omar Rodriguez Alvarez created an issue

Hi Scott, I started running into an issue shortly after updating IntelliJ(2017.3, Build #IU-173.3727.127) and IC(1.8.1.3), though I cannot be certain if that is related. I get an error stating com.sforce.soap.tooling.sobject.ApexClass cannot be cast to com.sforce.soap.tooling.sobject.ApexClass when trying to generate the offline symbol table. Portion of log I believe to be relevant below (with full log attached):

2017-12-01 13:32:01,365 [  55267]   INFO - ct.OfflineSymbolTableGenerator - Starting activity Loading system classes with 1034 steps. 
2017-12-01 13:32:01,535 [  55437]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Boolean.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,535 [  55437]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Boolean.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,537 [  55439]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__Database.getAsyncLocator.result; using Object. 
2017-12-01 13:32:01,537 [  55439]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Database.update.allOrNothing; adjusted type Boolean is already correct. 
2017-12-01 13:32:01,537 [  55439]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Database.update.allOrNothing; adjusted type Boolean is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Date.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Date.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Datetime.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Datetime.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Decimal.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Decimal.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Double.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,538 [  55440]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Double.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,539 [  55441]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Id.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,540 [  55442]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Id.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,540 [  55442]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Integer.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,540 [  55442]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Integer.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,542 [  55444]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Long.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,542 [  55444]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Long.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,568 [  55470]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__String.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,568 [  55470]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__String.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,569 [  55471]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Time.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,569 [  55471]   INFO - loud.symtab.SystemDeclarations - Ignoring type adjustment for parameter System__Time.addError.msg; adjusted type Exception is already correct. 
2017-12-01 13:32:01,570 [  55472]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__WebServiceCallout.beginInvoke.stub; using Object. 
2017-12-01 13:32:01,570 [  55472]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__WebServiceCallout.beginInvoke.request; using Object. 
2017-12-01 13:32:01,570 [  55472]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__WebServiceCallout.beginInvoke.continuation; using Object. 
2017-12-01 13:32:01,570 [  55472]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__WebServiceCallout.endInvoke.future; using Object. 
2017-12-01 13:32:01,570 [  55472]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__WebServiceCallout.invoke.stub; using Object. 
2017-12-01 13:32:01,570 [  55472]   WARN - loud.symtab.SystemDeclarations - Failed to find an adjustment for APEX_OBJECT typed parameter System__WebServiceCallout.invoke.request; using Object. 
2017-12-01 13:32:01,576 [  55478]   INFO - ct.OfflineSymbolTableGenerator - Completed activity Loading system classes in 210 ms. 
2017-12-01 13:32:01,583 [  55485]   INFO - ct.OfflineSymbolTableGenerator - Starting activity Loading custom classes with 1 steps. 
2017-12-01 13:32:01,641 [  55543]   INFO - y.ReflectionServiceFactoryBean - Creating Service {urn:tooling.soap.sforce.com}ToolingService from class com.sforce.soap.tooling.ToolingApi 
2017-12-01 13:32:11,183 [  65085]   INFO - cloud.client.ForceComApiClient - JAXB initialization for com.sforce.soap.tooling.SessionHeader took 511ms. 
2017-12-01 13:32:11,806 [  65708]   INFO - cloud.client.ForceComApiClient - JAXB initialization for com.sforce.soap.tooling.CallOptions took 623ms. 
2017-12-01 13:32:12,580 [  66482]   INFO - ct.OfflineSymbolTableGenerator - Completed activity Loading custom classes in 10997 ms. 
2017-12-01 13:32:12,583 [  66485]   WARN - .IlluminatedCloudExceptionUtil - com.sforce.soap.tooling.sobject.SObject cannot be cast to com.sforce.soap.tooling.sobject.ApexClass 
java.lang.ClassCastException: com.sforce.soap.tooling.sobject.SObject cannot be cast to com.sforce.soap.tooling.sobject.ApexClass
    at com.illuminatedcloud.symtab.OfflineSymbolTable$29$1.process(SourceFile:3467)
    at com.illuminatedcloud.client.ToolingQueryResultProcessor.process(SourceFile:54)
    at com.illuminatedcloud.symtab.OfflineSymbolTable$29.compute(SourceFile:3455)
    at com.illuminatedcloud.symtab.OfflineSymbolTable$29.compute(SourceFile:3448)
    at com.illuminatedcloud.symtab.OfflineSymbolTable.runActivity(SourceFile:631)
    at com.illuminatedcloud.symtab.OfflineSymbolTable.runActivity(SourceFile:670)
    at com.illuminatedcloud.symtab.OfflineSymbolTable.loadCustomClasses(SourceFile:3447)
    at com.illuminatedcloud.symtab.OfflineSymbolTable.generateOfflineSymbolTable(SourceFile:794)
    at com.illuminatedcloud.intellij.settings.project.OfflineSymbolTableGenerator$3.run(SourceFile:203)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:704)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:157)
    at com.intellij.openapi.progress.impl.CoreProgressManager.a(CoreProgressManager.java:534)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:479)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:94)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:165)
    at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:315)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
2017-12-01 13:32:31,174 [  85076]   INFO - il.indexing.FileBasedIndexImpl - Rebuild requested for index CaseInsensitiveFilenameIndex 
java.lang.Throwable: Rebuilding CaseInsensitiveFilenameIndex
    at com.illuminatedcloud.intellij.index.IlluminatedCloudIndexUtil.rebuildIndices(SourceFile:399)
    at com.illuminatedcloud.intellij.index.IlluminatedCloudIndexUtil.rebuildIndices(SourceFile:301)
    at com.illuminatedcloud.intellij.index.IlluminatedCloudIndexUtil.access$100(SourceFile:58)
    at com.illuminatedcloud.intellij.index.IlluminatedCloudIndexUtil$2.run(SourceFile:460)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:315)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.a(LaterInvocator.java:424)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:407)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
    at com.intellij.ide.IdeEventQueue.h(IdeEventQueue.java:822)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:650)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2017-12-01 13:32:31,195 [  85097]   INFO - il.indexing.FileBasedIndexImpl - scheduleIndexRebuild, reason: checkRebuild 
2017-12-01 13:32:31,406 [  85308]   INFO - g.FileBasedIndexProjectHandler - Reindexing refreshed files: 4224 to update, calculated in 202ms 

Comments (5)

  1. Scott Wells repo owner

    Thanks for the log, Omar. I'm seriously confused as to what's happening, though. I'm running the following Tooling API query:

    SELECT Id, Name, NamespacePrefix FROM ApexClass
    

    and then iterating over the result set assuming each entry is an ApexClass. That code hasn't changed in over two years. That means to me that something has changed on the server.

    Can you let me know anything else about the connection on which this is happening? What is the API version? Is it a DE org, a sandbox, a scratch org, or something else? I'm going to need to reach out to Salesforce to get some idea of what's going on.

    Oh, there is one other thing you could do that would definitely help. Would you mind adding the following under Help>Debug Log Settings, restarting IDE, and reproducing the error?

    #com.illuminatedcloud.client.ForceComApiClient
    #com.illuminatedcloud.client.ForceComApiClient!trace
    

    That will show me the exact SOAP requests and responses which I can provide to Salesforce as concrete evidence of what's happening. Since that ends up being quite verbose, I'd need you to send me all log file corresponding to the OST generation to ensure I'd have the correct client/server interaction.

    Thanks! Scott

  2. Omar Rodriguez Alvarez Account Deactivated reporter

    Thank you for the reply, Scott. This occurs when working with a scratch org using the connection API version 36.0. I have attached the log that was generated with the specified log levels.

  3. Scott Wells repo owner

    Thanks, Omar. So actually that SOAP envelope looks correct to me. Just out of curiosity, if you change the API version to, say, 41.0 during OST generation, does that make a difference?

  4. Omar Rodriguez Alvarez Account Deactivated reporter

    Scott, OST generation started working after updating the sourceApiVersion value in sfdx-project.json from 36.0 to 41.0. Thank you!

  5. Scott Wells repo owner

    Okay. Good to know, but VERY curious that it would fail on that API version. I wonder if there's something unique about that older API version and scratch orgs or something. Anyway, I'm going to resolve this as there's very likely little I'll be able to do in IC to accommodate for whatever the difference is in that environment at that older API version. I recommend that you remove the debug logging entries and restart the IDE (or at least close and reopen your project). That level of verbose debug logging can have a performance impact, albeit slight. Might as well remove it.

  6. Log in to comment