Lucee Docker: I cant load bundled jars

Using Lucee 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
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")

But that throws:

Lucee 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" )

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 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 Error (java.lang.NoClassDefFoundError)
Message	org/apache/commons/pool2/impl/GenericObjectPool

The implementation is:

  Class 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?


you have to place the jar file to /lib/ folder and restart the lucee.

Also, you can use this.javaSettings in Application.cfc to load the jar files from the folders which contain the custom jar files

Thank you!

Re: The info on the Custom Jars doc page…

In the Docker Tomcat version it seems that
{local web context}/WEB-INF/lucee/lib/
translates into
so in the Dockerfile
COPY jedis-4.3.0-m1.jar /usr/local/tomcat/lib/jedis-4.3.0-m1.jar

{Lucee Installation Folder}/lucee-server/context/lib/
translates into
COPY jedis-4.3.0-m1.jar /opt/lucee/server/lucee-server/context/lib/jedis-4.3.0-m1.jar

depending on which context you want it in.

Now I understand. Thanks.

On a separate note, the other part of my question (which perhaps is not to do with Lucee?):

When I do this:

jedis = createObject( "java", "redis.clients.jedis.Jedis").init()

it throws:

Lucee Error (java.lang.NoClassDefFoundError)
Message	Could not initialize class redis.clients.jedis.CommandObjects

I am guessing the Jedis constructor is calling the redis.clients.jedis.CommandObjects class. Given redis.clients.jedis.Jedis is now being found and the constructor called, why wouldn’t Java find the redis.clients.jedis.CommandObjects class? The Jedis javadocs (and the pathname) show it as being part of the same redis.clients.jedis package.

No joy from Dr Google.

Thanks again,

why wouldn’t Java find the redis.clients.jedis.CommandObjects class

I think lucee found the redis.clients.jedis.CommandObjects class because Creating object didn’t throw an error.

variables.CommandObjects = createObject("java", "redis.clients.jedis.CommandObjects");

But the error thrown on creating constructor (init()) for this class

variables.CommandObjects = createObject("java", "redis.clients.jedis.CommandObjects").init();

Can you please create a ticket in Jira for this issue?



1 Like