[英]java.lang.ClassNotFoundException when container.deployVerticle is called in Verticle
I am a newbie regarding Vertx, so this might be a simple question. 我是Vertx的新手,所以这可能是一个简单的问题。 When i try to run a verticle from commandline i allways get a ClassNotFoundException when i try to programatically deploy another verticle :
当我尝试从命令行运行一个Verticle时,当我尝试以编程方式部署另一个Verticle时,我总是得到ClassNotFoundException:
container.deployVerticle("melby.poc.verticles.AuditVerticle"); container.deployVerticle( “melby.poc.verticles.AuditVerticle”); AuditVerticle is itself a verticle, and is located in a sub package from the main" verticle that i try to run
AuditVerticle本身是一个顶点,位于我尝试运行的主要“顶点”的子包中
I have also tried to run this as a module as well without any luck command i use to run the verticle is : vertx run src\\main\\java\\melby\\poc\\Server.java 我也尝试过将此模块作为模块运行,而没有任何运气命令来运行verticle:vertx运行src \\ main \\ java \\ melby \\ poc \\ Server.java
Consolle output when i try to start the verticle is : 当我尝试启动verticle时,Consolle输出为:
Succeeded in deploying verticle
Exception in Java verticle
java.lang.ClassNotFoundException: melby.poc.verticles.AuditVerticle
at org.vertx.java.platform.impl.ModuleClassLoader.loadFromModule(ModuleC
lassLoader.java:127)
at org.vertx.java.platform.impl.ModuleClassLoader.loadClass(ModuleClassL
oader.java:108)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.vertx.java.platform.impl.java.JavaVerticleFactory.createVerticle(
JavaVerticleFactory.java:55)
at org.vertx.java.platform.impl.DefaultPlatformManager$21.run(DefaultPla
tformManager.java:1748)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:175
)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(Single
ThreadEventExecutor.java:370)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThread
EventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)
I use vertx 2.1.5 and java 8 Do i somehow need to change/add the classpath for vertx so it is able to load the classes in the same source folder ? 我使用vertx 2.1.5和java 8我是否需要以某种方式更改/添加vertx的类路径,以便它能够将类加载到同一源文件夹中?
Update : I was able to make it work by adding a mod.json file defining the runnable verticle and adding this file to the root catalog. 更新: 通过添加定义可运行的vertfile的mod.json文件并将此文件添加到根目录中,我能够使其工作。 From this catalog i am now able to run the command : vertx run src\\main\\java\\melby\\poc\\Server.java -cp target/classes I still dont anderstand why I need a mod.json file and why i need to define -cp If i dont programatically deploy verticles i dont need this.
从这个目录中,我现在可以运行命令:vertx run src \\ main \\ java \\ melby \\ poc \\ Server.java -cp target / classes我仍然不理解为什么我需要一个mod.json文件以及为什么我需要定义-cp如果我不以编程方式部署垂直版本,则不需要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.