dennis_chen_canada
dennis_chen_canada

Reputation: 82

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

I follow tutorial to install MUnit plugin as this page: https://docs.mulesoft.com/munit/v/1.1.1/using-munit-in-anypoint-studio

But, when I run an empty test case, AnyPoint return me an error as: A JNI error has occurred, please check your installation and try again.

In console, I saw the exception as:

Exception in thread "main" java.lang.NoClassDefFoundError: org/mule/munit/runner/mule/result/notification/NotificationListener at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.privateGetMethodRecursive(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.validateMainClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.mule.munit.runner.mule.result.notification.NotificationListener at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 more

Please help to check whats the problem.

Thanks in advance.

Upvotes: 1

Views: 3393

Answers (2)

V1ma-8
V1ma-8

Reputation: 71

You may not have the MUnit runner at runtime. You can resolve the issue by adding munit runner to my pom.

Dependency

<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>mule-munit-support</artifactId>
<version>${mule.munit.support.version}</version>
<scope>test</scope>

<dependency>
<groupId>com.mulesoft.munit</groupId>
<artifactId>munit-runner</artifactId>
<version>${munit.version}</version>
<scope>test</scope>

plugin

<plugin>
            <groupId>com.mulesoft.munit.tools</groupId>
            <artifactId>munit-maven-plugin</artifactId>
            <version>${munit.version}</version>
            <executions>
                <execution>
                    <id>test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <coverage>
                    <runCoverage>true</runCoverage>
                    <formats>
                        <format>html</format>
                    </formats>
                </coverage>
            </configuration>
        </plugin>

Also remember to add you munit source as maven test resource like,

<testResources>
        <testResource>
            <directory>src/test/munit</directory>
        </testResource>
    <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources

Upvotes: 0

Abhishek Bera
Abhishek Bera

Reputation: 141

I am assuming a few things here: 1) You are using Anypoint Studio and 2) Your project is Mavenized

1) Install MUnit: Go to Help menu in the Anypoint Studio and Click on Install New Software . In the Work With column enter http://studio.mulesoft.org/r4/munit and add.

Once it is done, we need to add this MUnit to the Maven Path.

2) Adding to Path: In your project explorer go to src/test/munit and right click on it. From the DropDown select Munit and select Configure MUnit Maven Support.

After this Maven will automatically trigger a build and all the necessary files including the one you have mentioned in the question will be downloaded.

Hope this helps!

Upvotes: 2

Related Questions