Can't run 3.5.0 mqtt-example using vertx command line

53 views
Skip to first unread message

C. Minos Niu

unread,
Oct 20, 2017, 10:49:39 PM10/20/17
to vert.x
I'm trying to run the mqtt-example in Java, it ran succesfully in Intellij IDEA but failed when using command line vertx.

The console kept reporting errors of not finding mqtt libraries as below. I've tested running it in console in Groovy, js and Kotlin, but got pretty much the same errors everywhere. What should be done to get it go?


vertx-examples/mqtt-examples/src/main/java/io/vertx/example/mqtt/app/Client.java:19: error: package io.netty.handler.codec.mqtt does not exist
import io.netty.handler.codec.mqtt.MqttQoS;
 
mqtt-examples/src/main/java/io/vertx/example/mqtt/app/Client.java:24: error: package io.vertx.mqtt does not exist
import io.vertx.mqtt.MqttClient;
 
 ...                               


Julien Viet

unread,
Oct 21, 2017, 4:50:52 AM10/21/17
to vert.x
can you check that it is enabled in the vertx-stack.json file of your CLI distribution ?

-- 
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/fd740f65-89af-432d-a161-9a8359e4ceeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

C. Minos Niu

unread,
Oct 21, 2017, 10:07:42 AM10/21/17
to vert.x
My guess is no:

$ vertx resolve --dir=lib
Error while executing command resolve: Cannot find the stack descriptor. Have been tried:
     
- .//usr/local/Cellar/vert.x/3.5.0/libexec/vertx-stack.json
     
- /usr/local/Cellar/vert.x/3.5.0/libexec/vertx-stack.json

I used vanilla vertx-example and vanilla Homebrew vertx-3.5.0. Are there more pointers to configure this mqtt-example out-of-the-box?

C. Minos Niu

unread,
Oct 21, 2017, 10:49:44 AM10/21/17
to vert.x
Hi Julien,

After some tweaking, I can confirm that vertx-mqtt is now enabled in my vertx-stack.json. And "$vertx resolve" reported no errors.

But I'm still getting the following error when running mqtt-example in CLI:

$ vertx run server.js
java.lang.ClassNotFoundException: server.js
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at io.vertx.core.impl.JavaVerticleFactory.createVerticle(JavaVerticleFactory.java:42)
    at io.vertx.core.impl.DeploymentManager.createVerticles(DeploymentManager.java:234)
    at io.vertx.core.impl.DeploymentManager.lambda$doDeployVerticle$2(DeploymentManager.java:207)
    at io.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:81)
    at io.vertx.core.impl.DeploymentManager.doDeployVerticle(DeploymentManager.java:176)
    at io.vertx.core.impl.DeploymentManager.doDeployVerticle(DeploymentManager.java:148)
    at io.vertx.core.impl.DeploymentManager.deployVerticle(DeploymentManager.java:136)
    at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:650)
    at io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer.deploy(VertxIsolatedDeployer.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at io.vertx.core.impl.launcher.commands.ClasspathHandler.deploy(ClasspathHandler.java:164)
    at io.vertx.core.impl.launcher.commands.RunCommand.deploy(RunCommand.java:401)
    at io.vertx.core.impl.launcher.commands.RunCommand.run(RunCommand.java:274)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.execute(VertxCommandLauncher.java:230)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(VertxCommandLauncher.java:365)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(VertxCommandLauncher.java:328)
    at io.vertx.core.Launcher.main(Launcher.java:49)
Failed in deploying verticle
java.lang.ClassNotFoundException: server.js
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at io.vertx.core.impl.JavaVerticleFactory.createVerticle(JavaVerticleFactory.java:42)
    at io.vertx.core.impl.DeploymentManager.createVerticles(DeploymentManager.java:234)
    at io.vertx.core.impl.DeploymentManager.lambda$doDeployVerticle$2(DeploymentManager.java:207)
    at io.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:81)
    at io.vertx.core.impl.DeploymentManager.doDeployVerticle(DeploymentManager.java:176)
    at io.vertx.core.impl.DeploymentManager.doDeployVerticle(DeploymentManager.java:148)
    at io.vertx.core.impl.DeploymentManager.deployVerticle(DeploymentManager.java:136)
    at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:650)
    at io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer.deploy(VertxIsolatedDeployer.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at io.vertx.core.impl.launcher.commands.ClasspathHandler.deploy(ClasspathHandler.java:164)
    at io.vertx.core.impl.launcher.commands.RunCommand.deploy(RunCommand.java:401)
    at io.vertx.core.impl.launcher.commands.RunCommand.run(RunCommand.java:274)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.execute(VertxCommandLauncher.java:230)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(VertxCommandLauncher.java:365)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(VertxCommandLauncher.java:328)
    at io.vertx.core.Launcher.main(Launcher.java:49)

java.lang.ClassNotFoundException: server.js
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at io.vertx.core.impl.JavaVerticleFactory.createVerticle(JavaVerticleFactory.java:42)
    at io.vertx.core.impl.DeploymentManager.createVerticles(DeploymentManager.java:234)
    at io.vertx.core.impl.DeploymentManager.lambda$doDeployVerticle$2(DeploymentManager.java:207)
    at io.vertx.core.impl.FutureImpl.setHandler(FutureImpl.java:81)
    at io.vertx.core.impl.DeploymentManager.doDeployVerticle(DeploymentManager.java:176)
    at io.vertx.core.impl.DeploymentManager.doDeployVerticle(DeploymentManager.java:148)
    at io.vertx.core.impl.DeploymentManager.deployVerticle(DeploymentManager.java:136)
    at io.vertx.core.impl.VertxImpl.deployVerticle(VertxImpl.java:650)
    at io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer.deploy(VertxIsolatedDeployer.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at io.vertx.core.impl.launcher.commands.ClasspathHandler.deploy(ClasspathHandler.java:164)
    at io.vertx.core.impl.launcher.commands.RunCommand.deploy(RunCommand.java:401)
    at io.vertx.core.impl.launcher.commands.RunCommand.run(RunCommand.java:274)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.execute(VertxCommandLauncher.java:230)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(VertxCommandLauncher.java:365)
    at io.vertx.core.impl.launcher.VertxCommandLauncher.dispatch(VertxCommandLauncher.java:328)
    at io.vertx.core.Launcher.main(Launcher.java:49)

On Saturday, October 21, 2017 at 4:50:52 PM UTC+8, Julien Viet wrote:

Alexander Lehmann

unread,
Oct 21, 2017, 11:25:31 AM10/21/17
to vert.x
this looks like javascript support is not enabled in the stack

C. Minos Niu

unread,
Oct 21, 2017, 11:56:28 PM10/21/17
to vert.x
Yes Alexander that was indeed the case, thank you. However, I've enabled javascript in the vertx-stack, but the JS/groovy/Kotlin error proceeds to something like this:

$ vertx run server.js

meanwhile in another term I opened the client:


$ vertx run client.js

Then the server side initially ran all right, waiting for client requests. But the moment I power up the client, the server gave the following error:

Succeeded in deploying verticle
MQTT server is listening on port 1883
MQTT client [c93ad94e-202e-4f64-9d3b-3353f3b45e52] request to connect, clean session = true
Unhandled exception
server.js:15 TypeError: [Boolean false] is not a function
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
at jdk.nashorn.internal.runtime.ScriptObject.notAFunction(ScriptObject.java:1869)
at jdk.nashorn.internal.runtime.ScriptObject.findCallMethod(ScriptObject.java:1865)
at jdk.nashorn.internal.runtime.ScriptObject.lookup(ScriptObject.java:1833)
at jdk.nashorn.internal.runtime.linker.PrimitiveLookup.lookupPrimitive(PrimitiveLookup.java:155)
at jdk.nashorn.internal.runtime.linker.PrimitiveLookup.lookupPrimitive(PrimitiveLookup.java:80)
at jdk.nashorn.internal.objects.NativeBoolean.lookupPrimitive(NativeBoolean.java:167)
at jdk.nashorn.internal.objects.Global.primitiveLookup(Global.java:1129)
at jdk.nashorn.internal.runtime.linker.NashornPrimitiveLinker.getGuardedInvocation(NashornPrimitiveLinker.java:71)
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
at jdk.nashorn.internal.scripts.Script$Recompilation$164$266A$^eval_#88!17^eval_.L:1$L:6(server.js:15)
at jdk.nashorn.internal.scripts.Script$Recompilation$152$3857A$^eval_#88!17^eval_.L:1$MqttServer$endpointHandler$L:99(vertx-mqtt-server-js/mqtt_server.js:100)
at io.vertx.core.Handler$$NashornJavaAdapter.handle(Unknown Source)
at io.vertx.mqtt.impl.MqttServerConnection.handleConnect(MqttServerConnection.java:285)
at io.vertx.mqtt.impl.MqttServerConnection.handleMessage(MqttServerConnection.java:97)
at io.vertx.mqtt.impl.MqttServerImpl.lambda$null$3(MqttServerImpl.java:89)
at io.vertx.core.net.impl.NetSocketImpl.handleMessageReceived(NetSocketImpl.java:356)
at io.vertx.core.net.impl.NetServerImpl$2.handleMessage(NetServerImpl.java:445)
at io.vertx.core.net.impl.NetServerImpl$2.handleMessage(NetServerImpl.java:442)
at io.vertx.core.net.impl.VertxHandler.lambda$channelRead$1(VertxHandler.java:150)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:342)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:200)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:148)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at java.lang.Thread.run(Thread.java:745)

Reply all
Reply to author
Forward
0 new messages