我正在尝试在容器内执行Grizzly HTTP Server。
为什么我在运行jar时遇到此错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/glassfish/grizzly/http/server/HttpServer
所有人都在和pom一起玩,但我在gradle中遇到了这个错误。 这是我的 build.gradle :
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.13.0",
}
}
group 'com.mycompany'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'com.palantir.docker'
docker {
name "${project.group}/${jar.baseName}"
files 'build/libs'
buildArgs(['JAR_FILE': "${jar.archiveName}"])
}
jar {
manifest {
attributes 'Main-Class': 'com.mycompany.json_validator.Main'
}
baseName = 'JSON_validator-boot-docker'
version = '0.2.0'
archiveName = 'JSON_validator-boot-docker-0.2.0.jar'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-moxy', version: '2.26'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-multipart', version: '2.7'
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-grizzly2-http', version: '2.17'
compile group: 'org.glassfish.jersey', name: 'jersey-bom', version: '2.17', ext: 'pom'
}
总而言之,我想为docker构建jar。
答案 0 :(得分:0)
java.lang.NoClassDefFoundError: 组织/的glassfish /灰色/ HTTP /服务器/ HttpServer的
NoClassDefFoundError
表示可以在运行时找到类的定义,这可能是缺少jar / libraries。请确保您已在classpath中包含grizzly-http-server-x.x.x.jar
和相关的jar。