2

我正在开发 IntelliJ 插件,并且正在使用 apache httpcore-4.2.1.jar。我按照 Jetbrains 在他们的 Confluence 页面上声明的插件结构文档,并正在使用这个结构:

.IntelliJIDEAx0
plugins
    Sample
        lib
            libfoo.jar
            libbar.jar
        classes
            com/foo/.....
            ...
            ...
        META-INF
            plugin.xml 

我的目录结构是这个

c:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.0.1
plugins
    myplugin
        lib
            commons-codec-1.6.jar
            commons-logging-1.1.1.jar
            httpclient-4.2.1-atlassian-2.jar
            httpcore-4.2.1.jar
            jackson-core-asl-1.9.12.jar
            jackson-mapper-asl-1.9.12.jar
            list.txt
            myplugin.jar
                META-INF
                    plugin.xml
                com/..... #classes here

然后我通过 IntelliJ/Settings/Plugins/Install 使用 myplugin.jar 从硬盘安装了这个插件。

重新启动后,我得到了这个异常

org/apache/http/protocol/HttpContext [Plugin: maca.myplugin]: org/apache/http/protocol/HttpContext [Plugin: maca.myplugin]
com.intellij.diagnostic.PluginException: org/apache/http/protocol/HttpContext [Plugin: maca.myplugin]
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.a(ComponentManagerImpl.java:470)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.a(ComponentManagerImpl.java:435)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.access$000(ComponentManagerImpl.java:421)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:102)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.initComponents(ComponentManagerImpl.java:346)
    at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:86)
    at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:307)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.a(ProjectManagerImpl.java:279)
    at com.intellij.openapi.project.impl.ProjectManagerImpl.access$300(ProjectManagerImpl.java:81)
    at com.intellij.openapi.project.impl.ProjectManagerImpl$9.compute(ProjectManagerImpl.java:529)
    at com.intellij.openapi.project.impl.ProjectManagerImpl$9.compute(ProjectManagerImpl.java:525)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$4.run(ProgressManagerImpl.java:275)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:501)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:310)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:191)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:232)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
    at com.intellij.openapi.application.impl.ApplicationImpl$8$1.run(ApplicationImpl.java:692)
    at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:465)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
    at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:153)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/protocol/HttpContext
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentsRegistry.a(ComponentManagerImpl.java:445)
    ... 25 more
Caused by: java.lang.ClassNotFoundException: org.apache.http.protocol.HttpContext PluginClassLoader[maca.myplugin, 0.1]
    at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:77)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
    ... 28 more

似乎 IntelliJ 没有将其他库放在插件类加载器的类路径上,我不知道为什么。

有人可以帮助我吗?

谢谢

4

0 回答 0