ClassNotFoundException in plugin development

I got started a idea development with Gradle as it says 
I created the plugin with following dependencies 
   compile group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.3' 
   compile group: 'io.github.swagger2markup', name: 'swagger2markup', version: '1.3.1' 
   compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.44' 
The plugin worked well while compiling,but ClassNotFoundException happened during debugging.

Here is the error stack: 
org.apache.commons.configuration2.ex.ConfigurationRuntimeException: java.lang.ClassNotFoundException: org.apache.commons.configuration2.PropertiesConfiguration 
at org.apache.commons.configuration2.beanutils.BeanHelper.fetchBeanClass(BeanHelper.java:549)
at org.apache.commons.configuration2.beanutils.BeanHelper.createBeanCreationContext(BeanHelper.java:616)
at org.apache.commons.configuration2.beanutils.BeanHelper.createBean(BeanHelper.java:456) 
at org.apache.commons.configuration2.beanutils.BeanHelper.createBean(BeanHelper.java:479) 
at org.apache.commons.configuration2.beanutils.BeanHelper.createBean(BeanHelper.java:492) 
at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.createResultInstance(BasicConfigurationBuilder.java:447)
at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.createResult(BasicConfigurationBuilder.java:417)
at org.apache.commons.configuration2.builder.BasicConfigurationBuilder.getConfiguration(BasicConfigurationBuilder.java:285)
at org.apache.commons.configuration2.builder.fluent.Configurations.properties(Configurations.java:318)
at io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder.getDefaultConfiguration(Swagger2MarkupConfigBuilder.java:135)
at io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder.<init>(Swagger2MarkupConfigBuilder.java:74) 
at io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder.<init>(Swagger2MarkupConfigBuilder.java:59) 
at io.terminus.common.util.pdoc.core.builder.SwaggerDocBuilder.build(SwaggerDocBuilder.java:42) 
at io.terminus.common.util.pdoc.core.builder.BaseMarkDownDocBuilder.write(BaseMarkDownDocBuilder.java:20)
at io.terminus.common.util.pdoc.core.builder.BaseMarkDownDocBuilder.lambda$write$0(BaseMarkDownDocBuilder.java:24)
at java.util.ArrayList.forEach(ArrayList.java:1251) 
at io.terminus.common.util.pdoc.core.builder.BaseMarkDownDocBuilder.write(BaseMarkDownDocBuilder.java:23)
at io.terminus.common.util.pdoc.core.SummaryWriter.lambda$accept$0(SummaryWriter.java:88) 
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) 
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1376) 
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) 
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) 
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) 
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) 
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) 
at io.terminus.common.util.pdoc.core.SummaryWriter.accept(SummaryWriter.java:88) 
at io.terminus.common.util.pdoc.action.OutPutContentUI.doOKAction(OutPutContentUI.java:151) 
at io.terminus.common.util.pdoc.action.PDocAction.lambda$actionPerformed$0(PDocAction.java:43) 
at io.terminus.common.util.pdoc.action.MyDialogWrapper.doOKAction(MyDialogWrapper.java:40) 
at com.intellij.openapi.ui.DialogWrapper$OkAction.doAction(DialogWrapper.java:1880) 
at com.intellij.openapi.ui.DialogWrapper$DialogWrapperAction.actionPerformed(DialogWrapper.java:1840)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022) 
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348) 
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
at java.awt.Component.processMouseEvent(Component.java:6548) 
at javax.swing.JComponent.processMouseEvent(JComponent.java:3325) 
at java.awt.Component.processEvent(Component.java:6313) 
at java.awt.Container.processEvent(Container.java:2237) 
at java.awt.Component.dispatchEventImpl(Component.java:4903) 
at java.awt.Container.dispatchEventImpl(Container.java:2295) 
at java.awt.Component.dispatchEvent(Component.java:4725) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889) 
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526) 
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467) 
at java.awt.Container.dispatchEventImpl(Container.java:2281) 
at java.awt.Window.dispatchEventImpl(Window.java:2746) 
at java.awt.Component.dispatchEvent(Component.java:4725) 
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) 
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.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737) 
at java.awt.EventQueue$4.run(EventQueue.java:735) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) 
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:781) 
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:718) 
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109) 
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190) 
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235) 
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233) 
at java.awt.Dialog.show(Dialog.java:1077) 
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:698)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:430) 
at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1690) 
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1639) 
at io.terminus.common.util.pdoc.action.PDocAction.actionPerformed(PDocAction.java:52) 
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:220) 
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:237) 
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$1.performAction(IdeKeyEventDispatcher.java:620)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.lambda$processAction$2(IdeKeyEventDispatcher.java:669)
at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.java:668)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.java:520)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.java:475)
at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.java:212)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:697) 
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:382) 
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) 
Caused by: java.lang.ClassNotFoundException: org.apache.commons.configuration2.PropertiesConfiguration 
at com.intellij.util.lang.UrlClassLoader.findClass(UrlClassLoader.java:224) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
at java.lang.Class.forName0(Native Method) 
at java.lang.Class.forName(Class.java:348) 
at org.apache.commons.lang3.ClassUtils.getClass(ClassUtils.java:909) 
at org.apache.commons.lang3.ClassUtils.getClass(ClassUtils.java:975) 
at org.apache.commons.lang3.ClassUtils.getClass(ClassUtils.java:958) 
at org.apache.commons.configuration2.beanutils.BeanHelper.loadClass(BeanHelper.java:507) 
at org.apache.commons.configuration2.beanutils.BeanHelper.fetchBeanClass(BeanHelper.java:545) 
... 94 more

It seem like the IDEA loading the class org.apache.commons.configuration2.PropertiesConfiguration by its own classLoader , but there is no class like that in the IDEA PLUGIN SDK ?

I have tried many times to solve this problem, but I failed. 
AS it says , I added my dependencies into IDEA PLUGIN SDK(not using gradle) .And it worked. 
But once I installed the plugin on other Idea,it failed again!

The program works well without plugin project, and did not lack dependencies.

So what is the problem with my plugin , and how can I fix it? 
thx

8 comments
Comment actions Permalink

Hi,

> I got started a idea development with Gradle as it says 

What's your build.gradle?

> java.lang.ClassNotFoundException: org.apache.commons.configuration2.PropertiesConfiguration 

The exception tells nothing. Where org.apache.commons.configuration2.PropertiesConfiguration comes from? From what dependencies, from what jar. Why do you think it should be available in the IDE?

What the version of the IDE you're building against? What's the version of IDE you're running the plugin in?

> But once I installed the plugin on other Idea,it failed again!

How did you build the plugin? How did you install it?

0
Comment actions Permalink

1. my build.gradle

 

plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.3.12'
}

group 'io.terminus.common'
version '1.0.4'

sourceCompatibility = 1.8

repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.3'
compile (group: 'io.github.swagger2markup', name: 'swagger2markup', version: '1.3.1'){
exclude group: 'org.slf4j'
}
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.44'
}

jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}

apply plugin: 'idea'
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'

intellij {
version '2018.2.1'
type 'IU'
}
patchPluginXml {
changeNotes """
Add change notes here.<br>`
<em>most HTML tags may be used</em>"""
}

 

2.1. PropertiesConfiguration comes from a jar(group:org.apache.commons name:commons-configuration2 version:2.1) which is the dependency of  swagger2markup.

2.2. So I think it might be in my project and indeed it is in the External Liraries

2.3. The version when building and running is always '2018.2' ultimate

 

3.1. When I build this with gradle ,I use script 'gradle buildPlugin'

       When I build this with DevKit , I press a button 'Build | Prepare Plugin Module <module name> for Deployment ' as the document says.

 

3.2. I install it by press a button 'install plugin from disk'

 

0
Comment actions Permalink

2.2. So I think it might be in my project and indeed it is in the External Liraries

When you built a plugin, does it contain commons-configuration.jar in it?

 

 > 3.2. I install it by press a button 'install plugin from disk'

What file do you choose while installing plugin from disk?

0
Comment actions Permalink

No , building result is just one jar, and all I need is all in it because I add

jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}

in the build.gradle file

 

That jar.

 

I write a simple demo to show this problem 

https://github.com/h2562961224/plugin-demo

 

 

And I meet another problem with the plugin

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001228419-How-to-run-shell-script-in-the-plugin 

My dear Alexander,could you please help me to solve that problem by the way ?

Thank you very very very much!

0
Comment actions Permalink

> No , building result is just one jar, and all I need is all in it because I add

The result of `buildPlugin` is never jar, it is a zip with all dependencies. Likely, you just use the wrong plugin archive.

> And I meet another problem with the plugin

Have you tried to debug it using Remote run configuration?

 

0
Comment actions Permalink

emmm......what do you mean about "Remote run configuration". Is there any demo .....You know, I am just a beginner...Thanks a lot

0
Comment actions Permalink

Here are the instructions: https://stackoverflow.com/questions/21114066/attach-intellij-idea-debugger-to-a-running-java-process

You can set needed jvm args in `Help | Edit custom vm options` of IDE you want to debug, restart it and debug your plugin.

0
Comment actions Permalink

hello,what do you do to resolve this question?

0

Please sign in to leave a comment.