I'm very likely going about this the wrong way but...
# lucee
b
I'm very likely going about this the wrong way but, I am trying to create a lucee extension to deploy the snowflake-provided JDBC jar file for creating Snowflake datasources. The extension is installing (I'm using commandbox) without error but it is only putting the .jar file in the server-context's lib directory. If I manually put the jar file in the lucee-web context lib folder, the datasources work fine but I cannot figure out how to make an extension do that automatically. Any ideas or better solutions than an extension?
I put the jar in the application's class paths and loaded it through this.javasettings. I can use the class in createObject() fine that way but it doesn't work as a datasource class when I load it that way... you just get the dreaded "cannot load class through its string name, because no definition for the class with the specified name could be found" That is why I started trying the lucee extension route
The extension is very basic. Just a META-INF/manifest.mf file and the .jar file placed inside a lib folder
d
b
ah ha!
Copy code
/webcontexts
That looks like the trick
I have made extensions for functions before. loading a jar like this is a first for an extension for me
I was going off of the SQL server extension for examples but there's a lot in there. this mysql one looks like a smaller, cleaner example too
b
@bhartsfield If you want to test a jar as a JDBC driver, I've always needed to specify it via the
app.libDirs
setting in server.json, which loads it in the bootstrap classloader.
The class loader the application.cfc's this.javaSettings uses is not "vislble" to the bits that load JDBC drivers
As far as where the jar is going, is there a reason you need it in the web context dir? I assume you installed the extension into the server context, which should make the jar accessible to all web contexts.
b
I just know that it works when I drop it (manually) into the web context lib dir. I have an extension that puts it in the server-context lib dir but, even with explicitly setting release-type: web or all, it never makes it into the web context dir
I will give app.libdirs a shot!
b
Cool- I don't have any experience using a "normal" jar for drivers. The Ortus cache extensions I wrote used an OSGI bundle which gets loaded a little differently than a traditional jar
And so far as I know, all the inbuilt Lucee JDBC drivers use OSGI bundles as well for the actual JDBC jar
b
yeah, it LOOKs simpler with an OSGI bundle
at least there are more examples of that
b
I don't know if I'd use the word "simple" and "OSGI" in the same sentence, but there is more prior art 😆
b
heh
app.libDirs appears to be working!
talk about the wrong direction with this... app.libDirs is sooooo much simpler too
b
Well, if you want to distribute it, you'll need to figure out the extension
But if this was just for you to use, then libDirs all the way 🙂
b
It was just for this one app and no one really responded to the previous snowflake question so I'm guessing it's not too popular with CFers
b
I saw the original question, but had never heard of it, lol
👍 1
b
for the record, little bobby two hands had to upgrade before libDirs worked 😛
technically I was upgraded but prod was not heh Thank you both for your help.
👍 1