I have a Service I’m trying to write tests for, but unable to instantiate it because Testbox uses a different setup than the Coldbox app. I need to get a JAR file available to it. How can I manage that correctly?
Well, I just figured out where the lucee-context folder was, and dropped it in there. For the Coldbox app, I used the /lib folder. This gets me through for now until someone shows me the right way.
I should have clarified that we’re running this app under Commandbox, locally. For runtime (not for Testbox), we have the jar loaded via the /lib folder. There is no such beast, that I can see, for Testbox. Can someone chime in to let me know how one should make a jar available for Testbox?
Which lib folder? Do you mean inside the web root? There is on behavior in CF to automatically load any jars from a lib folder. If your app is setup, I assume you’re using something like
this.javasettigns to tell CF to load it, or you’re using CommandBox and have the
app.libDirs setting pointed at that folder. Either way, however you['re doing it in your app, it’s up to you to do it the same way in your Testbox runner app context.
Ah, okay, I didn’t know that, I guess. I thought it was some Coldbox feature, to load .jars via some sort of JavaLoader feature, if found in the /lib folder. I didn’t realize, if I understand correctly, you’re saying that
That these just go together and work. (This is Lucee, via Commandbox.)
I don’t deal with .jar files too often.
Our ColdBox app templates do come with a
lib folder and a stubbed out
this.javaSettings in the
Application.cfc so I can see where that idea would come from!
We do use Javaloader in a lot of our modules, but only for loading the jars for that module. Unfortunately, javaloader doesn’t make it so a normal
createObject() will “find” the jars-- it requires you to create the classes via a specific javaloader helper method.
Lucee provides a way to add
this.javaSettings stuff on the fly via
cfapplication action="update" but Adobe still has no such beast, leaving us sitting here in 2022 with NO cross-engine compatible way for a framework or library to load jars on the fly without requiring manual edits to the
Application.cfc file in the root of the app. I’m not even angry any more, I’m just disappointed. So, so disappointed
Okay, excellent. I see it now. Like I said, not much java work here. You guys are still knocking it out of the park. Glad you take on the hard parts for us lowly developers!