Search code examples
javaredislettucedenodo

correct way to establish a redis connection with lettuce in java 8


I am trying to build a Denodo java stored procedure that communicates with redis via lettuce.

I am using the Denodo 4e eclipse extension and oxygen as recommended by Denodo.

I am clearly missing something because all of the documentation indicates that both

int port = 6379;
String host = "127.0.0.1";
RedisURi uri = RedisURI.Builder.redis(host,port).withDatabase(1).build();
RedisClient client = RedisClient.create(uri);

and

RedisClient client = RedisClient.create("redis://localhost:6379");

are throwing errors that are obscured by the debugging method all i know is that in the first instance the builder fails and in the second the client fails.

When I invoke the redis-cli i see that redis is running at 127.0.0.1:6379> and am able to get the test keys I have set.

user@system:~$ redis-cli
127.0.0.1:6379> get datum1
"datum2"

I am using a default redis.conf and running eclipse, denodo, and redis on the same machine.

Bind in redis.conf is 127.0.0.1 ::1 timeout is disabled (0)

I don't normally develop in Java so I'm hoping I am clearly doing something wrong rather than having to actually do this in a non-denodo project and sort out proper builds and debugging.


Solution

  • So a few rookie mistakes here for anyone new to java or Denodo.

    The Java mistake was using catch exception which apparently doesn't catch everything. Moving to catch throwable allowed me to get a useful stack trace, though I understand this is not recommended out side of debugging as catch throwable will also catch underlying JVMerrors and stuff you have no business dealing with in code.

    The underlying issue was a Java.Lang.ClassNotFoundException for a dependency.

    The Denodo mistake was that Java Stored Procedures in Denodo either need to have dependency jars imported or should use an uber(?)/fat(?) jar.

    I used the maven assembly plugin to build with maven instead of using the denodo4e deploy tool, then copied the jar to a procs folder under denodo home and browsed to it when creating a new stored procedure in the VDP Admin.