NoClassDefFoundError at Runtime with Gradle
我使用gradle作为JavaFX插件。即使在构建和运行可执行的分发/之后,一切都完美地工作,除了一个类:CloseableHttpClient
出于几个目的,我创建了以下对象,如下所示:
CloseableHttpClient client = HttpClients.createDefault();
在IDE中运行程序没有问题,一切正常。但是,如果我构建并尝试运行.exe文件,我会得到以下 -StackTrace:Throwable
java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955)
at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
at ch.itcb.tools.lom.util.JsonSimpleUtil.http(JsonSimpleUtil.java:29)...
我真的不明白。怎么可能只有这个类没有被找到,但我的所有其他类都找到了呢?
我的 build.gradle 文件:
apply plugin: 'java'
apply plugin: 'eclipse'
apply from: 'javafx.plugin'
sourceCompatibility = 1.8
version = '0.1'
jar {
manifest {
attributes 'Implementation-Title': 'LogoffManager',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'lib', include: ['*.jar'])
compile 'ch.qos.logback:logback-classic:1.1.3'
compile 'org.apache.httpcomponents:httpclient:4.5.1'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
test {
systemProperties 'property': 'value'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
如果您需要更多信息,请发表评论。感谢。