A JNI error has occurred, please check your installation and try again

4.7k Views Asked by At

I'm trying to deploy java-SpringBoot project (Building a messenger bot) into

heroku, but when i try to use : heroku local command, i get this Error:

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

My Procfile look like this :

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

My main class:

@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 configuration my is application.yml and it holds the authentication values.

My pom file :

dependencies and plugin only:

<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>

There are so many different answers to java java.lang.ClassNotFoundException/NoClassDefFoundError and i've tried it all.

I believe it's a java classpath issue (because it run from command line) but all suggestion online don't work for me.

0

There are 0 best solutions below