发生jni错误,请检查安装并重试

9vw9lbht  于 2021-07-03  发布在  Java
关注(0)|答案(0)|浏览(269)

我正在尝试将JavaSpringBoot项目(构建一个messenger机器人)部署到
heroku,但是当我尝试使用:heroku local命令时,我得到以下错误:

Error: A JNI error has occurred, please check your 
installation and try again
Exception in thread "main" 

java.lang.NoClassDefFoundError:
com/github/messenger4j/send/MessengerSendClient
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at 
sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at 
sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: 
com.github.messenger4j.send.MessengerSendClient
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 7 more

我的文件如下所示:

web: java $JAVA_OPTS -cp target/classes:target/dependency/* me.messengerBot.SpringDocBotApplication

我的主要课程:

@SpringBootApplication
public class SpringDocBotApplication {

private static final Logger logger = LoggerFactory.getLogger(SpringDocBotApplication.class);

/**
 * Initializes the {@code MessengerSendClient}.
 *
 * @param pageAccessToken the generated {@code Page Access Token}
 */
@Bean
public MessengerSendClient 
messengerSendClient(@Value("${messenger4j.pageAccessToken}")
String pageAccessToken) {
    logger.debug("Initializing MessengerSendClient - pageAccessToken: {}", pageAccessToken);
    return MessengerPlatform.newSendClientBuilder(pageAccessToken).build();
}

public static void main(String[] args) {
    SpringApplication.run(SpringDocBotApplication.class, args);
}

}
我的配置是my application.yml,它保存身份验证值。
我的pom文件:
仅依赖项和插件:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.github.messenger4j</groupId>
        <artifactId>messenger4j</artifactId>
        <version>0.8.0</version>
    </dependency>

    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.10.2</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>

    </plugins>
</build>

java.lang.classnotfoundexception/noclassdeffounderror有很多不同的答案,我都试过了。
我相信这是一个java类路径问题(因为它是从命令行运行的),但所有在线建议对我来说都不起作用。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题