1

I am having some troubles trying to work with vertx. I am developing on Windows, using IntelliJ. I am simply trying to instentiate a vertx object, as follow : vertx vertx = Vertx.vertx().

When running int on Windows I am getting a warning concerning netty :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/C:/Users/souki/.m2/repository/io/netty/netty-common/4.1.19.Final/netty-common-4.1.19.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

But the application does not stop and works fine. But for some reasons, I can't test my program on my Windows, and have to run it on a Linux VM.

When running it on the VM as follow java -jar myjar.jar, I am getting the following error :

Exception in thread "main" java.lang.NoClassDefFoundError: io/vertx/core/Vertx
        at Ecmg.main(Ecmg.java:16)
Caused by: java.lang.ClassNotFoundException: io.vertx.core.Vertx
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 1 more

When I remove Vertx vertx = Vertx.vertx();, everything works fine.

My question is, why am I getting this error on Linux?

In case you're wondering, java -version output on linux is :

OpenJDK Runtime Environment (build 1.8.0_20-b26)
OpenJDK Server VM (build 25.20-b23, mixed mode)

Here is my pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>JavaEcmg</groupId>
    <artifactId>JavaEcmg</artifactId>
    <version>1.0-SNAPSHOT</version>


    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>3.5.1</version>
        </dependency>
    </dependencies>

</project>

About my Intellij configuration :

enter image description here

enter image description here enter image description here

Thanks in advance!

souki
  • 1,305
  • 4
  • 23
  • 39

1 Answers1

1

Regarding the JVM warnings: welcome to Java 9 and 10 :-) (but yes, it works fine)

You are likely getting a ClassNotFoundException because the Jar is made of just your code classes. Try building a fat jar, like in https://github.com/vert-x3/vertx-examples/tree/master/fatjar-examples

jponge
  • 510
  • 2
  • 4
  • I am trying this, and will let you know if it worked – souki Apr 26 '18 at 13:00
  • It worked following these steps : https://stackoverflow.com/questions/39273877/intellij-java-2016-maven-how-to-embed-dependencies-in-jar Thanks – souki Apr 26 '18 at 13:07