I am having an issue with the MongoDb extension fo...
# lucee
s
I am having an issue with the MongoDb extension for Lucee (not the Ortus one). I install it and try to use it to create a MongoDb cache and I get the following error: cannot load class through its string name, because no definition for the class with the specified name [org.lucee.mongodb.cache.MongoDBCache] could be found caused by (java.lang.ClassNotFoundException:org.lucee.mongodb.cache.MongoDBCache not found by lucee.core [49];java.lang.ClassNotFoundException:org.lucee.mongodb.cache.MongoDBCache;) How could it possibly not be able to find the class specified since it's in the extension that was installed? My installation is running Lucee 5.3.10.120 under CommandBox 5.9 (but this was happening using CommandBox 5.8 as well). To throw a wrench into this, we have a version of Lucee running in a static web app on Azure that works perfectly! We install the MongoDb extension up there and I am able to create a cache using that MongoDb driver just fine, no errors what so ever. That installation is using a slightly different build of Lucee but still 5.3.10.x but I downgraded my local Lucee to the same version and it still failed locally. Does anyone have any ideas why this is happening?
Well, I figured out why its getting that error. I did a compare of the two instances of Lucee. There was one JAR file in the Azure instance that was NOT in my local instance called "org-mongodb-mongo-java-driver-3-12-8.jar". I don't know where that .jar file came from but after copying it into my local instance and restarting the instance I can now create a MongoDb Cache in the Lucee administrator. Can anyone tell me where that JAR file comes from? It appears to be a merging of the 3 MongoDb driver jar files that come with the MongoDb Lucee extension and appears to be the exact same version (3.12.8).
s
where did you find the
org-mongodb-mongo-java-driver-3-12-8.jar
on the Azure instance? I am running a commandbox 5.9 instance with Lucee 5.3.10.120 and the MongoDB extension installed via
server.json
(not manually via admin). I use the cache extensively for session scope although again, I define the cache programmatically in Application.cfc, not via the admin. But can check my instance to see if that jar is there or not.
s
It is in the WEB-INF/lucee-server/bundles folder. The circled jars are the ones added by the extension. The one the arrow is pointing at is the extra one that made the extension work.
image.png
Sean, BTW, how do you install extensions via the server.json file? I did learn how to define the caches in the applcation.cfc.
s
in your server.json, add an
env
key with a subkey
LUCEE_EXTENSIONS
. That key can have a value like
E6634E1A-4CC5-4839-A83C67549ECA8D5B;name=MongoDB;version=3.12.8.133
s
Can you concatenate more than one extension?
or create an array?
s
Yes, mine looks like so:
Copy code
{
    "app":{
        "libDirs":"lib",
        "cfengine":"lucee-light"
    },
    "openbrowser":false,
    "env":{
        "APPMODE":"${APP_ENV}",
        "APPNAME":"DealStream",
        "LUCEE_EXTENSIONS":"E6634E1A-4CC5-4839-A83C67549ECA8D5B;name=MongoDB;version=3.12.8.133,CED6227E-0F49-6367-A68D21AACA6B07E8,37C61C0A-5D7E-4256-8572639BE0CF5838,B737ABC4-D43F-4D91-8E8E973E37C40D1B;version=1.0.0.46-SNAPSHOT,D46B46A9-A0E3-44E1-D972A04AC3A8DC10;version=1.0.19.24,66E312DD-D083-27C0-64189D16753FD6F0;version=1.1.0.19"
    }
s
ah! 🙂
s
i'm looking to see if my instance has that extra jar. hang tight
No it doesn't
Screenshot 2023-05-11 at 3.19.00 PM.png
s
weird.
s
I think that extra one you copied in is redundant to the three bundled in the extension. Not sure why it started working after you put it in there, but I do wonder if it would continue working if you removed it. Maybe is was a server restart that made it work.
s
I agree! I did a compare and the classes in that one are all in the other three combined.
my server was restarted numerous times. Nothing got it working until I put that additional jar file in there.
And mysteriously, I don't know where it came from in our Azure static web app instance! We didn't put it there manually, I know that for sure. Will the extension installer go out and download jar files from maven if a required jar file is not in the .lex file?
s
I don't think so, but I don't know for sure. Is it possible you installed another extension that had that jar?
like the Ortus one maybe?
s
you know, I may have installed the ortus extension and then deleted it.
s
My money's on that 😁
s
The Ortus extension incorporates all the mongo driver classes directly within their extension jar file. So not Ortus. I then went and installed Lucee using commandbox on my personal laptop and installed the MongoDb 131 version driver. It worked! I checked the bundles folder and the extra jar file was there (it wasn't before I installed the extension)! I rechecked the 131 extension lex file and that jar file is NOT in the lex file. The only conclusion I can make is that something in the configuration of the extension is wrong (bad classpath maybe and since it couldn't find the jar it was expecting it went out to maven and downloaded it from there).
s
131? I don't see that tag
s
I just found this in the MANIFEST.MF of the mongodb.extension-3.12.144.jar file: Require-Bundle: org.mongodb.mongo-java-driver;bundle-version=3.12.8
That bundle name matches the extra jar file that is showing up.
image.png
s
huh, ok. There is no matching tag for that release in the repo
but I see what you mean.
s
BTW, I didn't see your 144 tag in your fork either.
s
no, I never tagged that. I literally just built the for you
s
ok.
s
144 just happened to be the build number for that ant build
s
Any idea where the Require-bundle in the MANIFEST.MF file gets built from?
that what you are asking?
s
yes
s
keep in mind - I think I am the only one left maintaining this extension, but I did NOT write it. I have made small changes over the years, that's all.
s
ok
s
and I am by no means a java developer. so yeah
s
which seems silly since MongoDb is getting popular as a no-sql database and cache.
We are trying to use it to connect to a CosmosDb instance on Azure using their MongoDb for CosmosDb API.
s
I would love to update it with the latest driver, but it's beyond my ability to tackle right now. // agreed
s
Since there is no CosmosDb driver for lucee
If you don't mind, I will fork your fork and take a look at it. We should be able to upgrade it to the latest 3.8 build of the driver at the very least easily.
How do you compile it? Do you use eclipse for doing the java build?
I am not a Java developer either but I have dabbled in the past.
Sorry, I meant the 3.12.x build (currently at 8 but there is a 13 available).
s
Yeah upgrading it to 3.12.13 should be a breeze. I was not aware of that update. I can work on that. If you want to work on it fork the lucee one directly. Then you can submit a PR there and I can approve it (I have write privs on that repo)
you compile it with any
*ant
s
ok. Thanks. I will do that then. Was there anything specific that you did to get the driver to show up in the Cache dropdown? (my original problem)
s
ant build-modern.xml
from the project root
s
thanks.
s
nope! it just magically did 🤣
🤣 1
i have no idea why the 133 one does not. Like I said, I changed nothing between compiles
unless there is something that happens when @zackster builds it for the official update
s
I found documentation on the Require-Bundle in the manifest file. I am going to try fixing that and recompile and see if I can get it working without that extra jar file.
👍 1
z
The GitHub Action should be a good smoke test?
s
I saw that. I haven't used github actions. Does it run automatically when I commit and push?
b
IF that bundle isn't in the extension (like it should), then Lucee is likely auto-downloading it from the update provider.
Check your deploy log for proof (you may need to bump the level)
If your local machine didn't have tha bundle, the extension didn't install correctly. Perhaps your machine doesn't have external internet access to download bundles on the fly?
l
Why not use ours and support open source as well 🙂
s
@lmajano I'd love to try yours but the interface is totally different I believe? Isn't yours just a cache interface? I use MongoDB as my full backend, not just cache, so I need support for find(), aggregate(), etc etc. I'll look into yours again. Also, this one's open source too? 😉
l
@jclausen
can you expand
for @seandaniels
s
I confirmed that for some reason the cache class didn't like the three separate jar files for the mongoDb driver. I replaced it with the single jar file distribution that it was automatically downloading so it is now in the lex file. @seandaniels I created a PR for my update which I have tested locally (version 3.12.13.2). I also updated the mongoDb driver version from 3.12.8 to 3.12.13 (that last release of 3.x).
s
Reviewing it now, thanks!
z
the class should come from the properties / manifest
s
@zackster I've merged @Stewart McGuire changes, can you create a new version?
z
wanan try it first?
👍 1
s
@zackster I just created a new PR that reverts the {class} replacements in the cfc file and fixes the modern build scripts to actually do the replacements that the classic build scripts did.
z
cool, just was replying on the PR, saved me pressing return!
welcome to the joys of java build files
👍 1
(says nobody)
s
The .lex is effectively the same as the previous build.
Yeah. Ant build scripts and building JAR files are new to me! Fun Fun! 😉
z
i spent ages getting this stupid update working https://github.com/lucee/Lucee/pull/2020/files
even tho works on my machine (coz i have an existing maven cache)
s
I have fun on my laptop because my company has a web proxy that we can't bypass.
It messes with the SSL cert chain on secure sites.
z
erghhh
s
So, the extension loader in lucee doesn't work for external providers.
z
so u just use the /deploy folder?
s
I've tried to get the Root certs installed into my Java environment but have not gotten it to work yet.
yup!
or the manual loader on the extension/applications page.
z
did you try importing into the lucee/security/cacerts file?
s
I download the .lex files from the lucee.org or forgebox.io sites manually (because the browser works fine).
yes, but I may have multiple copies of Java on my laptop.
I'm not sure I imported them into the right one.
z
lucee 5 uses it's own bundled cacerts file, 6 defaults to your java's
s
interesting.
that would explain why it didn't work in my lucee 5.
Are the .lex files compatible between 5 and 6?
z
toally
👍 1
just publishing the updated extension now
👍 2
s
Thanks! I just finally got test suite run
👍 1
z
image.png
🎉 1