无法实例化顶点对象
Unable to instentiate vertx object
我在尝试使用 vertx 时遇到了一些问题。我正在使用 IntelliJ 在 Windows 上进行开发。
我只是想实例化一个顶点对象,如下所示:vertx vertx = Vertx.vertx()
.
当 运行ning int on Windows 时,我收到有关 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
但是应用程序没有停止并且工作正常。但由于某些原因,我无法在我的 Windows 上测试我的程序,而必须在 Linux VM 上 运行 它。
当 运行按照 java -jar myjar.jar
在 VM 上安装它时,出现以下错误:
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.run(URLClassLoader.java:372)
at java.net.URLClassLoader.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
当我删除 Vertx vertx = Vertx.vertx();
时,一切正常。
我的问题是,为什么我在 Linux 上收到此错误?
如果您想知道,java - linux 上的版本输出是:
OpenJDK Runtime Environment (build 1.8.0_20-b26)
OpenJDK Server VM (build 25.20-b23, mixed mode)
这是我的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>
关于我的 Intellij 配置:
提前致谢!
关于 JVM 警告:欢迎阅读 Java 9 和 10 :-)
(但是,是的,它工作正常)
您可能会得到一个 ClassNotFoundException
,因为 Jar 是由 您的代码 类 组成的。尝试构建一个 fat jar,例如 https://github.com/vert-x3/vertx-examples/tree/master/fatjar-examples
我在尝试使用 vertx 时遇到了一些问题。我正在使用 IntelliJ 在 Windows 上进行开发。
我只是想实例化一个顶点对象,如下所示:vertx vertx = Vertx.vertx()
.
当 运行ning int on Windows 时,我收到有关 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
但是应用程序没有停止并且工作正常。但由于某些原因,我无法在我的 Windows 上测试我的程序,而必须在 Linux VM 上 运行 它。
当 运行按照 java -jar myjar.jar
在 VM 上安装它时,出现以下错误:
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.run(URLClassLoader.java:372)
at java.net.URLClassLoader.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
当我删除 Vertx vertx = Vertx.vertx();
时,一切正常。
我的问题是,为什么我在 Linux 上收到此错误?
如果您想知道,java - linux 上的版本输出是:
OpenJDK Runtime Environment (build 1.8.0_20-b26)
OpenJDK Server VM (build 25.20-b23, mixed mode)
这是我的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>
关于我的 Intellij 配置:
提前致谢!
关于 JVM 警告:欢迎阅读 Java 9 和 10 :-) (但是,是的,它工作正常)
您可能会得到一个 ClassNotFoundException
,因为 Jar 是由 您的代码 类 组成的。尝试构建一个 fat jar,例如 https://github.com/vert-x3/vertx-examples/tree/master/fatjar-examples