After migrating my plugin to 2021.3 I got NoClassDefFoundError: Could not initialize class com.intellij.javascript.web.webTypes.WebTypesLoadUtilKt

Answered

When we are trying to execute our tests in our plugin we got the following error:
our plugin - https://plugins.jetbrains.com/plugin/9238-jetforcer--the-smartest-force-com-ide

idea version in build.gradle is 2021.3

intellij {
type = 'IU'
version = '2021.3'
updateSinceUntilBuild = false
}

com.intellij.diagnostic.PluginException: Cannot create class com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader (classloader=jdk.internal.loader.ClassLoaders$AppClassLoader@1698c449) [Plugin: com.intellij] at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:869) at com.intellij.serviceContainer.ComponentManagerImpl.createLightService(ComponentManagerImpl.kt:809) at com.intellij.serviceContainer.ComponentManagerImpl.getOrCreateLightService(ComponentManagerImpl.kt:655) at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:607) at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:569) at com.intellij.openapi.client.ClientAwareComponentManager.getFromSelfOrCurrentSession(ClientAwareComponentManager.kt:37) at com.intellij.openapi.client.ClientAwareComponentManager.getService(ClientAwareComponentManager.kt:22) at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$Companion.getInstance(WebTypesEmbeddedDefinitionsLoader.kt:102) at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$Companion.getDefaultWebTypesContainer(WebTypesEmbeddedDefinitionsLoader.kt:36) at com.intellij.javascript.web.symbols.impl.WebSymbolsRegistryManagerImpl.getFrameworkAgnosticContainers(WebSymbolsRegistryManagerImpl.kt:297) at com.intellij.javascript.web.symbols.impl.WebSymbolsRegistryManagerImpl.get(WebSymbolsRegistryManagerImpl.kt:144) at com.intellij.javascript.web.symbols.WebSymbolsRegistryManager$Companion.get(WebSymbolsRegistryManager.kt:31) at com.intellij.javascript.web.codeInsight.html.WebSymbolsHtmlTextInjector$getLanguagesToInject$$inlined$let$lambda$2.compute(WebSymbolsHtmlTextInjector.kt:49) at com.intellij.psi.util.CachedValuesManager$1.compute(CachedValuesManager.java:158) at com.intellij.psi.impl.PsiCachedValueImpl.doCompute(PsiCachedValueImpl.java:39) at com.intellij.util.CachedValueBase.lambda$getValueWithLock$3(CachedValueBase.java:227) at com.intellij.util.CachedValueBase.computeData(CachedValueBase.java:42) at com.intellij.util.CachedValueBase.lambda$getValueWithLock$4(CachedValueBase.java:227) at com.intellij.openapi.util.RecursionManager$1.computePreventingRecursion(RecursionManager.java:114) at com.intellij.openapi.util.RecursionGuard.doPreventingRecursion(RecursionGuard.java:44) at com.intellij.openapi.util.RecursionManager.doPreventingRecursion(RecursionManager.java:68) at com.intellij.util.CachedValueBase.getValueWithLock(CachedValueBase.java:228) at com.intellij.psi.impl.PsiCachedValueImpl.getValue(PsiCachedValueImpl.java:28) at com.intellij.util.CachedValuesManagerImpl.getCachedValue(CachedValuesManagerImpl.java:72) at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:155) at com.intellij.psi.util.CachedValuesManager.getCachedValue(CachedValuesManager.java:121) at com.intellij.javascript.web.codeInsight.html.WebSymbolsHtmlTextInjector.getLanguagesToInject(WebSymbolsHtmlTextInjector.kt:47) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl.processInPlaceInjectorsFor(InjectedLanguageManagerImpl.java:442) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtilBase.probeElementsUp(InjectedLanguageUtilBase.java:248) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtilBase.enumerate(InjectedLanguageUtilBase.java:178) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtilBase.findInside(InjectedLanguageUtilBase.java:412) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtilBase.tryOffset(InjectedLanguageUtilBase.java:391) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtilBase.findInjectedElementNoCommit(InjectedLanguageUtilBase.java:371) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl.findInjectedElementAt(InjectedLanguageManagerImpl.java:298) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtilBase.findInjectedPsiNoCommit(InjectedLanguageUtilBase.java:203) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(InjectedLanguageUtil.java:132) at com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(InjectedLanguageUtil.java:68) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.setupEditorForInjectedLanguage(CodeInsightTestFixtureImpl.java:1517) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$configureInner$45(CodeInsightTestFixtureImpl.java:1499) at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$1.run(EdtTestUtil.kt:25) at com.intellij.testFramework.EdtTestUtil.runInEdtAndWait(EdtTestUtil.java:33) at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:25) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureInner(CodeInsightTestFixtureImpl.java:1474) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFileInner(CodeInsightTestFixtureImpl.java:1468) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFileInner(CodeInsightTestFixtureImpl.java:1450) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.configureByFilesInner(CodeInsightTestFixtureImpl.java:1359) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.getReferenceAtCaretPosition(CodeInsightTestFixtureImpl.java:629) at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.getReferenceAtCaretPositionWithAssertion(CodeInsightTestFixtureImpl.java:637) at com.jetforcer.apex.test.resolve.ApexResolveTestBase.getReferenceAtCaretPosition(ApexResolveTestBase.java:192) at com.jetforcer.apex.test.resolve.ApexResolveTestBase.getResolveResultsFromCaret(ApexResolveTestBase.java:159) at com.jetforcer.apex.test.resolve.ApexResolveTestBase.doTest(ApexResolveTestBase.java:53) at com.jetforcer.apex.test.resolve.ApexResolveTestBase.doTest(ApexResolveTestBase.java:34) at com.jetforcer.apex.test.ApexWithAnswersTestCase.performStandardTest(ApexWithAnswersTestCase.java:24) at com.jetforcer.apex.test.resolve.visualforce.VisualforceJsResolveTest.testResolveToAngularJSDirective(VisualforceJsResolveTest.java:20) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at junit.framework.TestCase.runTest(TestCase.java:176) at com.intellij.testFramework.UsefulTestCase.lambda$runBare$11(UsefulTestCase.java:533) at com.intellij.testFramework.UsefulTestCase.lambda$wrapTestRunnable$13(UsefulTestCase.java:554) at com.intellij.testFramework.UsefulTestCase.runTestRunnable(UsefulTestCase.java:454) at com.intellij.testFramework.fixtures.BasePlatformTestCase.runTestRunnable(BasePlatformTestCase.java:106) at com.jetforcer.apex.test.ApexLightPlatformCodeInsightTestCase.runTestExpectingFailure(ApexLightPlatformCodeInsightTestCase.java:586) at com.jetforcer.apex.test.TestWithExpectedFailures$ExpectedFailureDelegate.runTest(TestWithExpectedFailures.java:77) at com.jetforcer.apex.test.ApexLightPlatformCodeInsightTestCase.runTestRunnable(ApexLightPlatformCodeInsightTestCase.java:591) at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:470) at com.intellij.testFramework.UsefulTestCase.lambda$runBare$12(UsefulTestCase.java:541) at com.intellij.testFramework.EdtTestUtil.lambda$runInEdtAndWait$1(EdtTestUtil.java:40) at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214) at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21) at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805) at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$7(ApplicationImpl.java:450) at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:134) at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82) at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131) at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47) at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90) Caused by: java.lang.reflect.InvocationTargetException at jdk.internal.reflect.GeneratedConstructorAccessor30.newInstance(Unknown Source) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:850) ... 98 more Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.intellij.javascript.web.webTypes.WebTypesLoadUtilKt at com.intellij.javascript.web.webTypes.WebTypesDefinitionsEP.createInstance(WebTypesDefinitionsEP.kt:36) at com.intellij.javascript.web.webTypes.WebTypesDefinitionsEP.createInstance(WebTypesDefinitionsEP.kt:15) at com.intellij.serviceContainer.LazyExtensionInstance.getInstance(LazyExtensionInstance.java:44) at com.intellij.serviceContainer.BaseKeyedLazyInstance.getInstance(BaseKeyedLazyInstance.java:38) at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$State.<init>(WebTypesEmbeddedDefinitionsLoader.kt:64) at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$state$1.get(WebTypesEmbeddedDefinitionsLoader.kt:43) at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$state$1.get(WebTypesEmbeddedDefinitionsLoader.kt:18) at com.intellij.openapi.util.ClearableLazyValue$1.compute(ClearableLazyValue.java:17) at com.intellij.openapi.util.ClearableLazyValue.getValue(ClearableLazyValue.java:39) at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader.<init>(WebTypesEmbeddedDefinitionsLoader.kt:45) ... 102 more
4 comments
Comment actions Permalink

There is a known problem when running tests against 2021.3, please see first item in https://plugins.jetbrains.com/docs/intellij/api-changes-list-2021.html#intellij-platform-20213 and make sure the flag is set when executing tests.

Make sure to use the latest version of gradle-intellij-plugin as it contains important changes and fixes for targeting the latest IDE releases.

Please double-check the dependency on JavaScript plugin is set both in intellij 'plugins' block as well as plugin.xml (https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html).

 

1
Comment actions Permalink

Yann Cebron I already used this property in my build.gradle

tasks.test {
systemProperty("idea.force.use.core.classloader", "true")
}

Also, I have a dependency on JavaScript in my build.gradle

intellij {
plugins = [
'IntelliLang',
'coverage',
'JavaScript',
'CSS',
'platform-images',
'AngularJS',
'java'
]
}

And inside plugin.xml 

<depends optional="true" config-file="salesforce-javascript.xml">JavaScript</depends>




0
Comment actions Permalink

Fixed. The problem was caused by the following error:
(see https://youtrack.jetforcer.com/issue/JF-2257)

Caused by: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.databind.type.TypeFactory com.fasterxml.jackson.databind.type.TypeFactory.withClassLoader(java.lang.ClassLoader)'
    at com.intellij.javascript.web.webTypes.WebTypesLoadUtilKt.<clinit>(WebTypesLoadUtil.kt:12)
    at com.intellij.javascript.web.webTypes.WebTypesDefinitionsEP.createInstance(WebTypesDefinitionsEP.kt:36)
    at com.intellij.javascript.web.webTypes.WebTypesDefinitionsEP.createInstance(WebTypesDefinitionsEP.kt:15)
    at com.intellij.serviceContainer.LazyExtensionInstance.getInstance(LazyExtensionInstance.java:44)
    at com.intellij.serviceContainer.BaseKeyedLazyInstance.getInstance(BaseKeyedLazyInstance.java:38)
    at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$State.<init>(WebTypesEmbeddedDefinitionsLoader.kt:64)
    at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$state$1.get(WebTypesEmbeddedDefinitionsLoader.kt:43)
    at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader$state$1.get(WebTypesEmbeddedDefinitionsLoader.kt:18)
    at com.intellij.openapi.util.ClearableLazyValue$1.compute(ClearableLazyValue.java:17)
    at com.intellij.openapi.util.ClearableLazyValue.getValue(ClearableLazyValue.java:39)
    at com.intellij.javascript.web.webTypes.WebTypesEmbeddedDefinitionsLoader.<init>(WebTypesEmbeddedDefinitionsLoader.kt:45)
    ... 82 more
0
Comment actions Permalink

I see. Bundling these libraries in your plugin's distribution didn't fix it either?

0

Please sign in to leave a comment.