ClassNotFoundException when plugin as jar.but in debug ,there is no problem Follow
I am developing a plugin that depends on importing compile group: 'cn.hutool', name: 'hutool-all', version: '5.7.9' . When I am in debug mode, there is no problem. When this plugin is packaged, there will be oClassDefFoundError, the specific battle is as follows, I don't know why it will cause,how to fix?
the track:
2022-09-09 21:05:08,418 [ 73303] INFO - STDERR - java.lang.NoClassDefFoundError: cn/hutool/http/Method
2022-09-09 21:05:08,418 [ 73303] INFO - STDERR - at com.citicbank.ada.restful.ApiUtils.getHttpRequest(ApiUtils.java:275)
2022-09-09 21:05:08,418 [ 73303] INFO - STDERR - at com.citicbank.ada.handler.CallApiHandler$1.run(CallApiHandler.java:52)
2022-09-09 21:05:08,418 [ 73303] INFO - STDERR - at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:819)
2022-09-09 21:05:08,418 [ 73303] INFO - STDERR - at com.citicbank.ada.handler.CallApiHandler.onQuery(CallApiHandler.java:47)
2022-09-09 21:05:08,418 [ 73303] INFO - STDERR - Caused by: java.lang.ClassNotFoundException: cn.hutool.http.Method PluginClassLoader(plugin=PluginDescriptor(name=多宝, id=com.citicbank.uap-idea-plugin, descriptorPath=plugin.xml, path=~\AppData\Roaming\JetBrains\IdeaIC2021.1\plugins\uap-idea-plugin-1.0.5-snapshot.jar, version=1.0.5-snapshot, package=null), packagePrefix=null, instanceId=60, state=active)
2022-09-09 21:05:08,419 [ 73304] INFO - STDERR - at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:215)
2022-09-09 21:05:08,419 [ 73304] INFO - STDERR - at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
2022-09-09 21:05:08,419 [ 73304] INFO - STDERR - ... 4 more
2022-09-09 21:05:21,610 [ 86495] WARN - arketplace.MarketplaceRequests - Can not get JetBra
the gradle import the dependency:
buildscript {
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6-rc1"
}
}
plugins {
id 'java'
id 'org.jetbrains.intellij' version '0.6.0'
}
group 'xxxx'
version '1.0.5-snapshot'
repositories {
// mavenCentral()
mavenLocal()
maven {
url "http://28.4.198.84:8081/repository/maven-aliyun/"
}
}
tasks.withType(JavaCompile){
options.encoding='UTF-8'
}
//CompileOptions{
// sourceCompatibility JavaVersion.VERSION_11
// targetCompatibility JavaVersion.VERSION_11
//}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.7.2")
compile group: 'org.apache.ant', name: 'ant', version: '1.10.5'
compile group: 'jakarta.servlet', name: 'jakarta.servlet-api', version: '4.0.3'
compile group: 'org.apache.maven', name: 'maven-plugin-api', version: '3.6.3'
compile group: 'xerces', name: 'xercesImpl', version: '2.9.1'
// compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.10.3'
compile( group: 'org.apache.lucene', name: 'lucene-queryparser', version: '8.0.0'){
exclude module:'lucene-core'
}
compile (group: 'org.apache.lucene', name: 'lucene-analyzers-common', version: '8.0.0'){
exclude module:'lucene-core'
}
// compile group: 'com.github.adedayo.intellij.sdk', name: 'git4idea', version: '142.1'
compile group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc6'
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc6'
compile group: 'cn.hutool', name: 'hutool-all', version: '5.7.9'
}
apply plugin: 'jacoco'
apply plugin: 'org.sonarqube'
sonarqube {
properties{
property "sonar.host.url","http://22.4.15.55:9000"
property "sonar.login","e0b81757fd4beb8ccfdfeb71c6c25ab5ef3f507b"
property "sonar.projectName","uap-idea-plugin"
// property "sonar.java.source","11"
}
}
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version '2020.2.3'
plugins =['Git4Idea','java','maven','maven-model']
}
patchPluginXml {
// changeNotes """
// Add change notes here.<br>
// <em>most HTML tags may be used</em>"""
//方法1:配合plugin.xml中含有<idea-version
// intellij {untilBuild="203.*"}
//方法2:仅在此添加。实际起作用位置为patchPluginXml配置内容
sinceBuild 'IC-202.7660.26'
untilBuild ''
}
test {
useJUnitPlatform()
}
Please sign in to leave a comment.
Hi,
I don't understand the issue. Please rephrase your question and provide more information, at least the Gradle build script, and expected and actual behaviors with exact errors or stack traces you get.
Karol Lewandowski hello,I re-described the problem, printed the stack and gradle configuration, please take a look
You use a very outdated Gradle IntelliJ Plugin version: 0.6.0. Please update it to the latest 1.9.0. The same should be done with Gradle - update it to the latest version.
Also, how is the plugin packaged? Is it a ZIP distribution? Does it contain the JAR with the class that is not found?
@Karol Lewandowski the plugin packeged as .jar 。change to zip ,it can work well . there is a question.
i always package the plugin as jar . i use class in the jar which in dependencies
compile group: 'xerces', name: 'xercesImpl', version: '2.9.1'
why it will not throw class no found?
If your plugin uses the dependencies that are not part of the platform, you have to bundle your plugin as ZIP and make the dependency JAR a part of this ZIP.