0

I am trying to run a simple Smallrye Mutiny application using JAR via command line but I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: io/smallrye/mutiny/Multi
        at io.myPage.hello.concat.MultiClass.multiReturn(TestMain.java:25)
        at io.myPage.hello.concat.TestMain.main(TestMain.java:16)
Caused by: java.lang.ClassNotFoundException: io.smallrye.mutiny.Multi
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)

When I run directly via IDE then everything works perfectly but only while running JAR I get the above error.

Following is the sample code I have:

package io.myPage.hello.concat;

import io.smallrye.mutiny.Multi;

public class TestMain {
    public static void main(String[] args) {
        final MultiClass multiClass = new MultiClass();
        multiClass.multiReturn().subscribe().with(
                System.out::println,
                failure -> System.out.println("Failed with " + failure),
                () -> System.out.println("Completed"));
    }
}

class MultiClass {
    public Multi<String> multiReturn() {
        return Multi.createFrom().items("hello", "world", "Batman", "supermain", "london", "köln").onItem().transform(i -> i + "\n");
    }
}

Can someone please let me know why am I seeing this issue and how can I fix this?

BATMAN_2008
  • 2,788
  • 3
  • 31
  • 98
  • the problem is, while those classes are on the classpath of your ide, they aren't on the path if you run the code outside of it – Stultuske Jul 11 '22 at 09:53
  • @Stultuske Thanks a lot for the response. I am actually running in the `project-name/target` folder as the created JAR file for the project is in the `target` folder. Am I executing from the wrong folder? Because if I do not run from the `target` folder then I get the error JAR file not found. – BATMAN_2008 Jul 11 '22 at 09:55
  • Make sure you have mutiny in the classpath. If you are using Mutiny in a classic Quarkus application, check: https://smallrye.io/smallrye-mutiny/1.6.0/tutorials/getting-mutiny/ – Clement Jul 20 '22 at 06:35

0 Answers0