Tôi đang sử dụng gradle làm plugin JavaFX. Tất cả mọi thứ hoạt động hoàn hảo ngay cả sau khi xây dựng và runnig các excecutable tại phân phối/, trừ trường hợp một lớp: CloseableHttpClient
NoClassDefFoundError at Runtime with Gradle
Đối với nhiều mục đích tôi tạo ra các đối tượng sau đây như thế này:
CloseableHttpClient client = HttpClients.createDefault();
Chạy chương trình trong IDE là không có vấn đề, tất cả mọi thứ hoạt động tốt. Nhưng nếu tôi xây dựng và cố gắng chạy .exe-File tôi nhận được Throwable
-StackTrace sau:
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)...
Tôi thật sự không hiểu điều đó. Làm thế nào nó có thể được rằng chỉ lớp này không được tìm thấy, nhưng tất cả các lớp học khác của tôi làm gì?
tập tin build.gradle của tôi:
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'
}
}
}
Hãy viết một bình luận nếu bạn cần thêm thông tin. Cám ơn.
Vui lòng chia sẻ tệp build.gradle của bạn. – Opal
@Opal hoàn tất. vẫn không tìm thấy giải pháp:/ – jntme
Bình apache trong bản phân phối chưa? Nó có chứa lớp bị thiếu không? –