ryan
04/06/2022, 4:17 PMserver forget
to delete some servers, I forgot that there were jars that I needed to put back after creating the new server. Then I thought how it would be nice to be able to delete a server and spin up a new server at whim without having to manually add jar files back into the lib folder within Lucee. I read this and used server set app.libDirs=lib
I verified it is within the server.json. Also, I confirmed the jars are in the new custom lib folder. I restarted the server, but the website errors because it cannot find the jar file. I moved the lib folder around to see what, if any, different errors may occur and it does throw an error in commandbox when it cannot find the lib folder, so I am pretty sure that the lib folder is getting recognized during the spin up.
The following is the line that errors:
<cfset flyway = createObject("java", "org.flywaydb.core.Flyway").init()>
Maybe I cannot do this or this is not pointed in the cfset correctly now that the flyway jar is in a custom lib?thisOldDave
04/06/2022, 4:20 PMserver set app.libDirs=lib
implies that lib is in the same directory as server.jsonryan
04/06/2022, 4:21 PMthisOldDave
04/06/2022, 4:24 PMflyway = createObject("java", "org.flywaydb.core.Flyway").configure().dataSource(url, user, password).load();
ryan
04/06/2022, 4:24 PMryan
04/06/2022, 4:25 PMryan
04/06/2022, 4:25 PMbdw429s
04/06/2022, 4:26 PM--trace --console
start and you'll see a list of every jar that CommandBox class loads from your lib dirs šryan
04/06/2022, 4:26 PMryan
04/06/2022, 4:26 PMbdw429s
04/06/2022, 4:26 PMbdw429s
04/06/2022, 4:26 PMlib
then that's going to be a path relative to the location of the server.json
filebdw429s
04/06/2022, 4:27 PMbdw429s
04/06/2022, 4:27 PMbdw429s
04/06/2022, 4:28 PMbdw429s
04/06/2022, 4:29 PMWhen you configure libDirs for a server, CommandBox used to only load jar files found in the root. Now it will include sub directories which gives you more flexibility around how to install your jars.notice it says "_*used to* only load jar files found in the root_". key word "used to". Meaning, now it is different.
bdw429s
04/06/2022, 4:30 PMryan
04/06/2022, 4:30 PMryan
04/06/2022, 4:31 PMbdw429s
04/06/2022, 4:31 PMbdw429s
04/06/2022, 4:31 PMbdw429s
04/06/2022, 4:31 PMbox.json
so box install
pulls them in.bdw429s
04/06/2022, 4:32 PMthis.javaSettings
in your Application.cfc
is also a valid way to load these. it's sort of 6 of one, half a dozen of the other.bdw429s
04/06/2022, 4:32 PMmentions subdirectoriesNo, it just means sub directories of the folders you pointed it to
ryan
04/06/2022, 4:35 PMryan
04/06/2022, 4:36 PMserver set app.libDirs=lib
bdw429s
04/06/2022, 4:36 PMbdw429s
04/06/2022, 4:37 PMI did originally useWhich is fine, so long as your lib folder is in the same directory as theserver set app.libDirs=lib
server.json
ryan
04/06/2022, 4:37 PMbdw429s
04/06/2022, 4:38 PMryan
04/06/2022, 4:39 PMbdw429s
04/06/2022, 4:39 PMprofile
is set to production
so it's secure by default and set it up as a Windows service (which we have a module for)ryan
04/06/2022, 4:39 PMryan
04/06/2022, 4:39 PMryan
04/06/2022, 4:39 PMbdw429s
04/06/2022, 4:39 PMbdw429s
04/06/2022, 4:39 PMryan
04/06/2022, 4:40 PMryan
04/06/2022, 4:40 PMbdw429s
04/06/2022, 4:40 PMryan
04/06/2022, 4:40 PMbdw429s
04/06/2022, 4:40 PMryan
04/06/2022, 4:41 PMryan
04/06/2022, 4:43 PMryan
04/06/2022, 4:44 PMryan
04/06/2022, 4:45 PMryan
04/06/2022, 4:46 PM[TRACE] Runwar: lib: adding to classpath: F:\code\web\sites\test\lib\flyway-core-5.2.4.jar
thisOldDave
04/06/2022, 4:49 PMflyway = createObject("java", "org.flywaydb.core.Flyway").configure().dataSource(url, user, password).load();
ryan
04/06/2022, 4:50 PMthisOldDave
04/06/2022, 4:51 PMryan
04/06/2022, 4:52 PMryan
04/06/2022, 4:54 PMryan
04/06/2022, 4:56 PM[WARN ] org.flywaydb.core.Flyway: Direct configuration of the Flyway object has been deprecated and will be removed in Flyway 6.0. Use Flyway.configure() instead.
ryan
04/08/2022, 6:31 PMcom.mysql.cj-8.0.19.jar
, a dependency for the flyway jar, from '\lucee-server\bundles\' and pasted it into the custom lib folder. Everything works beautifully this way now! Thank you all for your help in this!ryan
04/08/2022, 6:44 PMapp.libDirs
would work, but I think I would have to make it a hard path rather than a relative path since the jar is located in a completely different place. Well, it seems like it is 6 of one, half a dozen of another when either copying/pasting it to the custom lib folder with the other jars or hard pathing it in the server.json. It is probably better to copy/paste because at least it will work with portability compared to an hard path possibly breaking if the server moved elsewhere. Going to see if I can make this work if the mysql jar is available online and point it that way for fun.ryan
04/11/2022, 7:29 PM$ init
in commandbox to create the box.json and then added the following to the box.json file.
{...
"dependencies":{
"flyway-core-5.2.4":"jar:<https://search.maven.org/remotecontent?filepath=com/github/spt-oss/flyway-core/5.2.4.0/flyway-core-5.2.4.0.jar>"
}
...}
bdw429s
04/11/2022, 8:12 PMbox install
or just add the dependencybdw429s
04/11/2022, 8:13 PMryan
04/11/2022, 8:13 PMryan
04/11/2022, 8:13 PMbox install
never even crossed my mind to try Lolryan
04/11/2022, 8:14 PMbdw429s
04/11/2022, 8:15 PMinstall "jar:<https://search.maven.org/remotecontent?filepath=com/github/spt-oss/flyway-core/5.2.4.0/flyway-core-5.2.4.0.jar>"
and it will
⢠download/install the jar
⢠add it to the box.json
for youryan
04/11/2022, 8:15 PMryan
04/11/2022, 8:27 PMinstall
then start
. I noticed that a folder is automatically created within the lib folder named flyway-core-5.2.4.0
. However, the page errors because it cannot find the file in that auto-created subdirectory. Is there possibly a setting that forces the jar to be placed within the lib directory and not a subdirectory or maybe there is something else I didn't do, like maybe the only option is to manually move the jar file into the lib folder?ryan
04/11/2022, 8:28 PMbdw429s
04/11/2022, 8:29 PMbdw429s
04/11/2022, 8:29 PMapp.libDirs
pointing at the lib
folder in your server.json
then it should be loadedbdw429s
04/11/2022, 8:29 PMryan
04/11/2022, 8:30 PMbdw429s
04/11/2022, 8:30 PMintsall
command just piuts the jar on disk. A CommandBox isn't going to load it unless you tell it tobdw429s
04/11/2022, 8:30 PM--trace
start and see if the jar shows up as being loaded.ryan
04/11/2022, 8:39 PM--trace
ryan
04/11/2022, 8:41 PMinstallPaths
was inserted into box.json as
"installPaths":{
"flyway-core-5.2.4":"lib/flyway-core-5.2.4/"
}
The jar is not able to be found and errors when starting the web application. Being that this is a Lucee server, do I possibly need to add a mapping to this install path in lucee's server admin?bdw429s
04/11/2022, 8:55 PMbdw429s
04/11/2022, 8:56 PMbdw429s
04/11/2022, 8:56 PMbdw429s
04/11/2022, 8:56 PMryan
04/11/2022, 10:32 PMcannot load class through its string name, because no definition for the class with the specified name [org.flywaydb.core.Flyway] could be found caused by (java.lang.ClassNotFoundException:org.flywaydb.core.Flyway not found by lucee.core [48];java.lang.ClassNotFoundException:org.flywaydb.core.Flyway;)
The Error Occurred in
\htdocs\db_migrate.cfm: line 56
55:
56: <cfset flyway = createObject("java", "org.flywaydb.core.Flyway").configure().dataSource(jdbcUrl, user, password, initSqls).load()>
57:
This indicates to me that everything is working in terms of Commandbox and all, it is just the file itself is not exactly the same as was expected.ryan
04/11/2022, 10:35 PM