2 votes

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

I have the following exception: how can I solve it

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
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.beust.jcommander.ParameterException
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

the code I am executing is this:

package globalTest;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import pages.contactUsPage;
import pages.fiftyPage;
import pages.footerPage;
import pages.footerProjectsPage;
import pages.hamburgerMenu;

public class suite {
WebDriver driver = new FirefoxDriver();

@BeforeClass
public void beforeClass() {
    // driver.manage().window().maximize();
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    System.out.println("Primera prueba");
}

@AfterClass
public void afterClass() {
    driver.quit();
    System.out.println("finaliza");
}

@Test
public void hamburguer() {
    driver.get(URL);
    hamburgerMenu hamburguer= new hamburgerMenu(driver);
}

@Test(priority = 1, enabled = true, invocationCount = 2)
public void contactUs() {
    driver.get(URL);

    contactUsPage contact = new contactUsPage(driver);
    contact.contact();
    contact.name();
    contact.email();
    contact.subject();
    contact.message();
    contact.send();

}

@Test(priority = 2, enabled = true)
public void contactUs2() {
    driver.get(URL);

    contactUsPage contact = new contactUsPage(driver);
    contact.email();

}

@Test(priority = 3, enabled = true)
public void fiftyPage() {
    driver.get(URL);

    fiftyPage fiftypage = new fiftyPage(driver);
    fiftypage.ourwork();
    fiftypage.fifty();

}

@Test
public void footerpageemail() {
    driver.get(URL);
    footerPage footer = new footerPage(driver);

    footer.hamburguer();
    footer.ourwork();
    footer.fifty();
    footer.up();
    footer.contacemail();

}

@Test
public void footerpagefacebook() {
    driver.get(URL);
    footerPage footer = new footerPage(driver);

    footer.hamburguer();
    footer.ourwork();
    footer.fifty();
    footer.facebook();

}

@Test
public void footerpagelinkendlin() {
    driver.get(URL);
    footerPage footer = new footerPage(driver);

    footer.hamburguer();
    footer.ourwork();
    footer.fifty();
    footer.linkendlin();

}

@Test
public void footerprojectspage() {     
    driver.get(URL);
    footerProjectsPage footerproject = new footerProjectsPage(driver);

    footerproject.hamburguer();
    footerproject.ourwork();
    footerproject.fifty();
    footerproject.mozidorigth();
    footerproject.otteright();
    footerproject.fiftyright();
    footerproject.otteleft();
    footerproject.mozidoleft();
    footerproject.fiftyleft();

}

}

0 votes

Could you show the actual code that causes this problem, also what libraries do you use, it is probably because you are not importing a class to the classpath properly.

0 votes

Hola, selenium-java-2.31.0, selenium-server-standalone-2.7.0.patched, httpclient-4.1.1, testng-6.9.9

0 votes

@Laura claims to have the ParameterException class inside : com/beust/jcommander/

1voto

Elenasys Points 67941

Laura checks the error:

Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException

It means that this class is not in your project or the package to access it is different.

There is a class in your project that is trying to use the class ParameterException but cannot find it.

As @jasilva points out, it seems that the class ParameterException belongs to the bookstore jcommander which apparently is not found, if we check the documentation this is the way to add it through Maven

<dependency>
  <groupId>com.beust</groupId>
  <artifactId>jcommander</artifactId>
  <version>1.48</version>
</dependency>

0 votes

And what happens if I am not using maven? what do I do :(

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X