question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reddis client not working with jbang

See original GitHub issue

Describe the bug use the following code (same as https://quarkus.io/guides/redis just with static public classes):

//usr/bin/env jbang "$0" "$@" ; exit $?
/**
 * Run this with `jbang -Dquarkus.container-image.build=true build quarkus.java`
 * and it builds a docker image.
 */
//DEPS io.quarkus:quarkus-redis-client:1.8.0.CR1
//DEPS io.quarkus:quarkus-resteasy-mutiny:1.8.0.CR1
//DEPS io.quarkus:quarkus-resteasy-jsonb:1.8.0.CR1
//DEPS org.testcontainers:testcontainers:1.14.3

//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
//Q:CONFIG quarkus.redis.hosts=localhost:6379

import io.quarkus.redis.client.RedisClient;
import io.quarkus.redis.client.reactive.ReactiveRedisClient;
import io.smallrye.mutiny.Uni;
import io.vertx.mutiny.redis.client.Response;
import org.testcontainers.containers.GenericContainer;

import javax.ws.rs.Produces;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class quarkusclireddis  {

    static public class Increment {
        public String key;
        public int value;

        public Increment(String key, int value) {
            this.key = key;
            this.value = value;
        }

        public Increment() {
        }
    }

    @Singleton
    static public class IncrementService {

        @Inject
        RedisClient redisClient;

        @Inject
        ReactiveRedisClient reactiveRedisClient;

        public IncrementService() {

        }

        Uni<Void> del(String key) {
            return reactiveRedisClient.del(Arrays.asList(key))
                    .map(response -> null);
        }

        String get(String key) {
            return redisClient.get(key).toString();
        }

        void set(String key, Integer value) {
            redisClient.set(Arrays.asList(key, value.toString()));
        }

        void increment(String key, Integer incrementBy) {
            redisClient.incrby(key, incrementBy.toString());
        }

        Uni<List<String>> keys() {
            return reactiveRedisClient
                    .keys("*")
                    .map(response -> {
                        List<String> result = new ArrayList<>();
                        for (Response r : response) {
                            result.add(r.toString());
                        }
                        return result;
                    });
        }
    }

    @Path("/increments")
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    static public class IncrementResource {

        @Inject
        IncrementService service;

        @GET
        public Uni<List<String>> keys() {
            return service.keys();
        }

        @POST
        public Increment create(Increment increment) {
            service.set(increment.key, increment.value);
            return increment;
        }

        @GET
        @Path("/{key}")
        public Increment get(@PathParam("key") String key) {
            return new Increment(key, Integer.valueOf(service.get(key)));
        }

        @PUT
        @Path("/{key}")
        public void increment(@PathParam("key") String key, Integer value) {
            service.increment(key, value);
        }

        @DELETE
        @Path("/{key}")
        public Uni<Void> delete(@PathParam("key") String key) {
            return service.del(key);
        }
    }

    public static void main(String... args) {
        GenericContainer redis = null;
        try {
            redis = new GenericContainer("redis:3-alpine")
                    .withExposedPorts(6379);
            redis.start();

            io.quarkus.runtime.Quarkus.run(args);
        } finally {
            redis.stop();
    }
    }
}

then run with: jbang quarkusclireddis.java and you get:

2020-09-05 01:52:16,364 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002020: Unhandled asynchronous exception, sending back 500: org.jboss.resteasy.spi.ApplicationException: java.lang.NoSuchMethodError: io.quarkus.redis.client.runtime.RedisAPIProducer: method 'void <init>()' not found
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:180)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:638)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:504)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:454)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:456)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:417)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:68)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:488)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:259)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:160)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:163)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:245)
	at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:131)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:37)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:94)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.NoSuchMethodError: io.quarkus.redis.client.runtime.RedisAPIProducer: method 'void <init>()' not found
	at io.quarkus.redis.client.runtime.RedisAPIProducer_ClientProxy.<init>(RedisAPIProducer_ClientProxy.zig:24)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_Bean.proxy(RedisAPIProducer_Bean.zig:43)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_Bean.get(RedisAPIProducer_Bean.zig:315)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_Bean.get(RedisAPIProducer_Bean.zig:331)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_ProducerField_reactiveClient_Bean.create(RedisAPIProducer_ProducerField_reactiveClient_Bean.zig:162)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_ProducerField_reactiveClient_Bean.create(RedisAPIProducer_ProducerField_reactiveClient_Bean.zig:203)
	at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:96)
	at io.quarkus.arc.impl.AbstractSharedContext.access$000(AbstractSharedContext.java:14)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:29)
	at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:26)
	at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
	at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
	at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:26)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_ProducerField_reactiveClient_ClientProxy.arc$delegate(RedisAPIProducer_ProducerField_reactiveClient_ClientProxy.zig:93)
	at io.quarkus.redis.client.runtime.RedisAPIProducer_ProducerField_reactiveClient_ClientProxy.keys(RedisAPIProducer_ProducerField_reactiveClient_ClientProxy.zig:6148)
	at quarkusclireddis$IncrementService.keys(quarkusclireddis.java:76)
	at quarkusclireddis$IncrementResource.keys(quarkusclireddis.java:97)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
	... 27 more

looks like another class loading issue on first glance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
stuartwdouglascommented, Sep 8, 2020

The actual issues is that transformation was not working in JBang, which I fixed in JBang. That PR would help it run with the latest release though. Either way it is no longer a problem.

1reaction
mkoubacommented, Sep 8, 2020

I saw #11958 earlier today. It should have fixed this issue I suppose?

This PR should fix this particular issue but the main problem is that jbang probably does not see the transformed classes…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Redis with Mutiny - Composing asynchronous actions
This client offers a few methods to help us with our problem: the RedisClient.keys(pattern) method returning Uni<JsonArray> . This array ...
Read more >
Home of Quarkus Cheat-Sheet - GitHub Pages
Quarkus is a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards....
Read more >
Could not get a resource from the pool ... - Stack Overflow
1 - Redis server is down or Redis application not responding. ... connections in the (Redis) pool are currently busy, new connection can...
Read more >
quarkusio/quarkus 2.0.0.Final on GitHub - NewReleases.io
#18109 - Fix Gradle repository URL; #18091 - Fix dev mode compile issues ... #17714 - Propagate Quarkus Redis Config to Vertx Redis...
Read more >
Introduction to Lettuce - the Java Redis Client - Baeldung
Opening a Redis Connection; Generating a set of RedisCommands. Let's see the implementation: RedisClient redisClient = RedisClient .create(" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found