krasa / MavenHelper

IntelliJ plugin - https://plugins.jetbrains.com/plugin/7179
Apache License 2.0
254 stars 92 forks source link

java.lang.NoClassDefFoundError: com/intellij/sh/run/ShConfigurationType #96

Open meiMingle opened 2 years ago

meiMingle commented 2 years ago

Describe the bug Got a NoClassDefFoundError when Ctrl+Shift+R to run mvnd clean install -DskipTests

To Reproduce Steps to reproduce the behavior: Idea 2022.2.1 、Mavenhelper 4.21.222.2964.0 Expected behavior

Screenshots image

Environment : Use Help | About | Copy button

Additional context Add any other context about the problem here.

java.lang.NoClassDefFoundError: com/intellij/sh/run/ShConfigurationType at krasa.mavenhelper.action.ProgramRunnerUtils.executeInTerminal(ProgramRunnerUtils.java:85) at krasa.mavenhelper.action.ProgramRunnerUtils.run(ProgramRunnerUtils.java:32) at krasa.mavenhelper.action.RunGoalAction.run(RunGoalAction.java:67) at krasa.mavenhelper.action.RunGoalAction.actionPerformed(RunGoalAction.java:62) at krasa.mavenhelper.action.RunGoalAction.actionPerformed(RunGoalAction.java:54) at krasa.mavenhelper.action.QuickRunMavenGoalAction$MyActionGroup.actionPerformed(QuickRunMavenGoalAction.java:221) at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:315) at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:294) at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:337) at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:294) at com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction(ActionUtil.java:516) at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:232) at com.intellij.ui.popup.ActionPopupStep.lambda$onChosen$1(ActionPopupStep.java:220) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105) at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94) at com.intellij.ui.popup.AbstractPopup.lambda$dispose$18(AbstractPopup.java:1543) at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:113) at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:180) at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:133) at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:164) at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1540) at com.intellij.ui.popup.WizardPopup.dispose(WizardPopup.java:162) at com.intellij.ui.popup.list.ListPopupImpl.dispose(ListPopupImpl.java:326) at com.intellij.ui.popup.PopupFactoryImpl$ActionGroupPopup.dispose(PopupFactoryImpl.java:266) at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:126) at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:158) at com.intellij.openapi.util.Disposer.dispose(Disposer.java:217) at com.intellij.openapi.util.Disposer.dispose(Disposer.java:205) at com.intellij.ui.popup.WizardPopup.disposeAllParents(WizardPopup.java:266) at com.intellij.ui.popup.list.ListPopupImpl.handleNextStep(ListPopupImpl.java:434) at com.intellij.ui.popup.list.ListPopupImpl._handleSelect(ListPopupImpl.java:406) at com.intellij.ui.popup.list.ListPopupImpl.handleSelect(ListPopupImpl.java:356) at com.intellij.ui.popup.list.ListPopupImpl$1.actionPerformed(ListPopupImpl.java:269) at com.intellij.ui.popup.WizardPopup.proceedKeyEvent(WizardPopup.java:378) at com.intellij.ui.popup.WizardPopup.dispatch(WizardPopup.java:354) at com.intellij.ui.popup.PopupDispatcher.dispatchKeyEvent(PopupDispatcher.java:112) at com.intellij.ui.popup.PopupDispatcher.dispatch(PopupDispatcher.java:148) at com.intellij.ide.IdePopupManager.dispatch(IdePopupManager.java:109) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:730) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113) at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92) Caused by: java.lang.ClassNotFoundException: com.intellij.sh.run.ShConfigurationType PluginClassLoader(plugin=PluginDescriptor(name=Maven Helper, id=MavenRunHelper, descriptorPath=plugin.xml, path=~\AppData\Roaming\JetBrains\IntelliJIdea2022.2\plugins\MavenRunHelper, version=4.21.222.2964.0, package=null, isBundled=false), packagePrefix=null, instanceId=358, state=active) at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:214) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 53 more

meiMingle commented 2 years ago

Now I'm sure this exception happens after I installed BashSupport Pro plugin, it disables the idea bundled Shell Script plugin

jansorg commented 2 years ago

(Author of BashSupport Pro here) Apologies for the problems! I briefly checked the code of this plugin. As far as I understand, the MavenHelper plugin declares an optional dependency on the JetBrains Shell plugin (in plugin.xml). But the code seems to use it always, not just when the Shell plugin is actually enabled. https://github.com/krasa/MavenHelper/blob/cb7818af5890f65f9e7adf4f32cc09592b9f4ee2/src/main/java/krasa/mavenhelper/action/ProgramRunnerUtils.java

BashSupport Pro disables the Shell plugin, that‘s correct. But manually disabling it would have the same effect. Either check in your code if JetBrains Shell is available at runtime, or make it a custom extension point which is only loaded when the Shell plugin is available, or make it a hard/non-optional dependency.

@meiMingle as a workaround, just enable the JetBrains Shell plugin again. It just work and BashSupport Pro‘s notification should remain silent after the 2nd or 3rd time it‘s shown. Please let me know if that‘s not working for you…

meiMingle commented 2 years ago

(Author of BashSupport Pro here) Apologies for the problems! I briefly checked the code of this plugin. As far as I understand, the MavenHelper plugin declares an optional dependency on the JetBrains Shell plugin (in plugin.xml). But the code seems to use it always, not just when the Shell plugin is actually enabled. https://github.com/krasa/MavenHelper/blob/cb7818af5890f65f9e7adf4f32cc09592b9f4ee2/src/main/java/krasa/mavenhelper/action/ProgramRunnerUtils.java

BashSupport Pro disables the Shell plugin, that‘s correct. But manually disabling it would have the same effect. Either check in your code if JetBrains Shell is available at runtime, or make it a custom extension point which is only loaded when the Shell plugin is available, or make it a hard/non-optional dependency.

@meiMingle as a workaround, just enable the JetBrains Shell plugin again. It just work and BashSupport Pro‘s notification should remain silent after the 2nd or 3rd time it‘s shown. Please let me know if that‘s not working for you…

If I follow this workaround, I wonder if enabling both BashSupport Pro and JetBrains Shell would cause a conflict.

jansorg commented 2 years ago

@meiMingle Both plugins are assigned to the same file extensions, add menu items to create new shell files, BashSupport Pro supports Shell‘s run configurations, etc. I‘ve tried to make things work even with Shell enabled, but it‘s still possible that I haven‘t found all of the conflicts and problems. If possible, it should be turned off. If that‘s not possible, e.g. because another plugin needs it, it should work okay with both plugins. If you have questions, I think it‘s best to move to BashSupport Pro‘s support channels, https://www.bashsupport.com/support/

@krasa Please let me know if I can help to get this fixed.

krasa commented 2 years ago

Hello, the problem was that I was checking that the Terminal plugin is enabled, but not the Shell Script plugin.

But using it together with BashSupport Pro is kinda not compatible. It either fails on:

java.lang.ClassCastException: class pro.bashsupport.g cannot be cast to class com.intellij.sh.run.ShRunConfiguration (pro.bashsupport.g is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @247dc319; com.intellij.sh.run.ShRunConfiguration is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @18cf62a5)
    at krasa.mavenhelper.action.ProgramRunnerUtils.executeInTerminal(ProgramRunnerUtils.java:97)
    at krasa.mavenhelper.action.ProgramRunnerUtils.run(ProgramRunnerUtils.java:34)
    at krasa.mavenhelper.action.RunGoalAction.run(RunGoalAction.java:67)
    at krasa.mavenhelper.action.RunGoalAction.actionPerformed(RunGoalAction.java:62)
    at krasa.mavenhelper.action.RunGoalAction.actionPerformed(RunGoalAction.java:54)
    at krasa.mavenhelper.action.QuickRunMavenGoalAction$MyActionGroup.actionPerformed(QuickRunMavenGoalAction.java:221)

(I've added a check for that)

or the IDE initializes differently and my code works, but BashSupport throws:

pro.bashsupport.gj@4f9b66aa produced wrong type

java.lang.ClassCastException: class com.intellij.sh.run.ShRunConfiguration cannot be cast to class pro.bashsupport.g (com.intellij.sh.run.ShRunConfiguration is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @500f7588; pro.bashsupport.g is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @48383836)
    at pro.bashsupport.bo.setupConfigurationFromContext(bo.java:12)
    at com.intellij.execution.actions.RunConfigurationProducer.createConfigurationFromContext(RunConfigurationProducer.java:100)
    at com.intellij.execution.actions.PreferredProducerFind.doGetConfigurationsFromContext(PreferredProducerFind.java:119)
    at com.intellij.execution.actions.PreferredProducerFind.getConfigurationsFromContext(PreferredProducerFind.java:100)
    at com.intellij.execution.actions.ConfigurationContext.createConfigurationsFromContext(ConfigurationContext.java:423)
    at com.intellij.execution.ExecutorRegistryImpl$ExecutorAction.getRunConfigsForCurrentFile(ExecutorRegistryImpl.java:462)
    at com.intellij.execution.ExecutorRegistryImpl$ExecutorAction.getRunCurrentFileActionStatus(ExecutorRegistryImpl.java:408)
    at com.intellij.execution.ExecutorRegistryImpl$ExecutorAction.getRunCurrentFileActionStatus(ExecutorRegistryImpl.java:387)
    at com.intellij.execution.ExecutorRegistryImpl$ExecutorAction.update(ExecutorRegistryImpl.java:345)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performDumbAwareUpdate$0(ActionUtil.java:150)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareUpdate(ActionUtil.java:173)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.doUpdate(ActionUpdater.java:660)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$updateActionReal$4(ActionUpdater.java:128)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.callAction(ActionUpdater.java:173)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.callAction(ActionUpdater.java:153)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.updateActionReal(ActionUpdater.java:129)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$new$0(ActionUpdater.java:116)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.update(ActionUpdater.java:649)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandGroupChild(ActionUpdater.java:498)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroup$20(ActionUpdater.java:477)
    at com.intellij.util.containers.ContainerUtil.concat(ContainerUtil.java:1398)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.doExpandActionGroup(ActionUpdater.java:477)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandGroupChild(ActionUpdater.java:550)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroup$20(ActionUpdater.java:477)
    at com.intellij.util.containers.ContainerUtil.concat(ContainerUtil.java:1398)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.doExpandActionGroup(ActionUpdater.java:477)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandGroupChild(ActionUpdater.java:550)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroup$20(ActionUpdater.java:477)
    at com.intellij.util.containers.ContainerUtil.concat(ContainerUtil.java:1398)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.doExpandActionGroup(ActionUpdater.java:477)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandActionGroup(ActionUpdater.java:272)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroupAsync$12(ActionUpdater.java:340)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroupAsync$13(ActionUpdater.java:359)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1154)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$tryRunReadActionAndCancelBeforeWrite$17(ActionUpdater.java:391)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:158)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.tryRunReadActionAndCancelBeforeWrite(ActionUpdater.java:387)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroupAsync$14(ActionUpdater.java:359)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
    at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:365)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroupAsync$15(ActionUpdater.java:358)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun$$$capture(BoundedTaskExecutor.java:241)
    at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java)
    at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:31)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:214)
    at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:212)
    at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:203)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
    at java.base/java.lang.Thread.run(Thread.java:829)
meiMingle commented 1 year ago

Through learning I think I now have the skills to help deal with this problem, I will debug and solve it in my spare time