Git Product home page Git Product logo

Comments (10)

vietj avatar vietj commented on August 21, 2024

can you try with current vertx 4.0.0-SNAPSHOT to have an idea

from vertx-lang-groovy.

injecteer avatar injecteer commented on August 21, 2024

what's the easiest way to install the snapshot with gradle? a specific repository?

from vertx-lang-groovy.

vietj avatar vietj commented on August 21, 2024

this ?

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
        authentication(userName: ossrhUsername, password: ossrhPassword)
      }

from vertx-lang-groovy.

injecteer avatar injecteer commented on August 21, 2024

the code for 4.0.0-SNAPSHOT compiles but upon start the following exception pops up:

java.lang.NoClassDefFoundError: io/vertx/codegen/annotations/DataObject
at io.vertx.lang.groovy.VertxExtensionModule.asType(VertxExtensionModule.java:17)
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:498)
at org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:54)
at org.codehaus.groovy.runtime.metaclass.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:56)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:935)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:926)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:181)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.asType(ScriptBytecodeAdapter.java:604)
at io.mozaiq.gateway.GatewayVerticle.(GatewayVerticle.groovy)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at io.vertx.lang.groovy.GroovyVerticleFactory.createVerticle(GroovyVerticleFactory.java:91)
at io.vertx.core.impl.DeploymentManager.createVerticles(DeploymentManager.java:232)
at io.vertx.core.impl.DeploymentManager.lambda$null$0(DeploymentManager.java:189)
at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:174)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:68)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$3(ContextImpl.java:172)
at io.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: io.vertx.codegen.annotations.DataObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 31 common frames omitted

from vertx-lang-groovy.

injecteer avatar injecteer commented on August 21, 2024

the issue is still reproducible in 3.7.0

from vertx-lang-groovy.

vietj avatar vietj commented on August 21, 2024

can you provide a reproducer project ?

from vertx-lang-groovy.

injecteer avatar injecteer commented on August 21, 2024

https://github.com/injecteer/sendRepro

from vertx-lang-groovy.

tsegismont avatar tsegismont commented on August 21, 2024

Change HOP_OPTS initialization to:

def HOP_OPTS = [sendTimeout: 5000]

And then it will work as expected. This is because the extension module defines a method that takes a LinkHashMap for options, not a DeliveryOptions instance:

public static <T>io.vertx.core.eventbus.EventBus send(io.vertx.core.eventbus.EventBus j_receiver, java.lang.String address, java.lang.Object message, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.Message<java.lang.Object>>> replyHandler) {
  // ...
}

Consequently at runtime the extension method is not used and the message parameter not converted to JsonObject.

To me this is working as expected but then perhaps we could duplicate all extension methods (one with regular option class, the other with LinkedHashMap). Thoughts @vietj ?

from vertx-lang-groovy.

injecteer avatar injecteer commented on August 21, 2024

I tried it, and with @TypeChecked it brings up the exception:

GatewayVerticle.groovy: 137: [Static type checking] - Cannot find matching method io.vertx.core.eventbus.EventBus#send(java.lang.String, java.util.Map <K extends java.lang.Object, V extends java.lang.Object>, java.lang.Object, groovy.lang.Closure). Please check if the declared type is correct and if the method exists.
@ line 137, column 9.
vertx.eventBus().send( id, body + REPLY, HOP_OPTS ){ AsyncResult rs ->
^

If I omit @TypeChecked the code compiles and runs normally, but I still think it's suboptimal.

from vertx-lang-groovy.

tsegismont avatar tsegismont commented on August 21, 2024

With Vert.x 3.9 and Vert.x 4, the way to go is:

class GatewayVerticle extends AbstractVerticle {
  DeliveryOptions HOP_OPTS = new DeliveryOptions(sendTimeout: 5000)

  @Override
  void start() throws Exception {
    vertx.eventBus().request('addr', [aa: 42] as JsonObject, HOP_OPTS) {
      if (it.succeeded()) {
        println(it.result())
      } else {
        it.cause().printStackTrace()
      }
    }
  }
}

from vertx-lang-groovy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.