Using Lucee 5.3.9.160 in Docker in WSL:Ubuntu-20.04 under Windows 10
Hi. I must be missing something basic regarding loading jars.
I am playing with using the Jedis
jar in Lucee because I want to experiment with redisJson and Search, etc.
In my Dockerfile I copy the jedis-4.3.0-m1.jar
to
/opt/lucee/server/lucee-server/bundles/jedis-4.3.0-m1.jar
and in the Admin Server and Web contexts Bundles (jars) section, the jar is visible with a status of “loaded”.
Now, since it is “loaded” I thought I should be able to import it like this:
Jedis = createObject( "java", "redis.clients.jedis.Jedis")
writeDump(var=Jedis,label="Jedis");
But that throws:
Lucee 5.3.9.160 Error (lucee.commons.lang.ClassException)
Message cannot load class through its string name, because no definition for the class with the specified name [redis.clients.jedis.Jedis] could be found caused by (java.lang.ClassNotFoundException:redis.clients.jedis.Jedis not found by lucee.core [49];java.lang.ClassNotFoundException:redis.clients.jedis.Jedis;)
However, if I do this (give it the explicit path) it works:
Jedis = createObject( "java", "redis.clients.jedis.Jedis", "/opt/lucee/server/lucee-server/bundles/jedis-4.3.0-m1.jar" )
writeDump(var=Jedis,label="Jedis");
However, if I then create the class via .init()
as per:
Jedis = createObject( "java", "redis.clients.jedis.Jedis", "/opt/lucee/server/lucee-server/bundles/jedis-4.3.0-m1.jar" ).init()
it throws:
Lucee 5.3.9.160 Error (java.lang.NoClassDefFoundError)
Message Could not initialize class redis.clients.jedis.CommandObjects
Furthermore …
If I import this class:
variables.jedisPool = createObject("java", "redis.clients.jedis.JedisPool", "/opt/lucee/server/lucee-server/bundles/jedis-4.3.0-m1.jar")
it throws:
Lucee 5.3.9.160 Error (java.lang.NoClassDefFoundError)
Message org/apache/commons/pool2/impl/GenericObjectPool
The implementation is:
redis.clients.jedis
Class JedisPool
java.lang.Object
org.apache.commons.pool2.BaseObject
org.apache.commons.pool2.impl.BaseGenericObjectPool<T>
org.apache.commons.pool2.impl.GenericObjectPool<T>
redis.clients.jedis.util.Pool<Jedis>
redis.clients.jedis.JedisPool
all of which is why I was thinking that if the Jedis jar was being loaded from via Lucee bundles it would have everything it needed? Or maybe this is an entirely different error.
Maybe I also need to put the commons-pool2-2.11.1.jar
in the Lucee bundles folder too?
My lack of Java expertise is telling here…
Can anyone shed any light, please?
Thanks,
Murray