Running Coldbox with lucee 5.3.7+47 CF Engine. It looks like the server.json datasource settings are being ignored during server startup. I have the following datasource in my server.json:
ERROR (5.2.0+00280)
You gave the location of the [to] server, but we couldn't figure out the format to use.
Please help us by adding [toFormat=...] to your command.
So now, I need to provide the toFormat= parameter but what do I put there I wonder? You see thatâs nowhere to be found in the docs at:
It would be good at this point to lay the groundwork.
Are you using CommandBox as your server? It you are not, please read about transferring your config to your server in the docs.
CommandBox and Coldbox doesnât so anything to mess with this.datasources in your Application.cfc. To help you debug that we would need more information, like a stack trace of the error you are seeing. One thing I do notice is while you are setting it as a datasource above, there is no default datasource set. That means youâd need to at least pass the datasource around to your cfquery or queryExecute calls.
So hold on right here⊠Why are you using this command at all? You already have the JSON definition of your datasource right? Just put it in a .cfconfig.json file in the web root and youâre done! Why are you even messing with the one-off command to create a datasource in the first place?
It completes succesfully but still getting the following error âŠ
What directory did you run the command in? Was it in the web root of the server. This is a CommandBox server, right? Do you see the datasource when you run
cfconfig datasource list
or
cfconfig show
Do you see the datasource when you log into the web admin for the server? Also, do you have an empty, or mostly empty .cfconfig.json file in the web root? if so, that will be imported and overwrite all your settings. If you start your server with the --verbose flag like so
server start --verbose
then look for a green line of log output that says âconfig transferredâ to confirm if CFConfig is performing an import from a JSON file.
to=/opt/Coldbox-App/
This doesnât seem like a server home. The rules for the server home are defined in the docs here along with examples
But to be clear, youâre already very far down the wrong path at this point. You shouldnât need a to set, nor even the server name. Just run the command in the web root and thatâs it. Thereâs like a 95% chance youâre blowing away your settings on every restart with another .cfconfig file. Note, our ColdBox app templates come with a .cfconfig.json file in the webroot that defines a datasource.
Some basic troubleshooting to see what datasources are defined after you restart the server should go a long way in figuring out what is happening.
You gave the location of the [to] server, but we couldnât figure out the format to use.
This is because you didnât provide a correct to location per the docs! Youâre way down the wrong road here. You donât need to be messing with a toFormat because you donât really need a to in the first place. The CLI really is just guessing at what you want at this point.
So now, I need to provide the toFormat= parameter but what do I put there I wonder?
Again, fully documented here:
You see thatâs nowhere to be found in the docs at:
Yes, of course. iâm not going to copy and paste the definition of what to/from and toFormat/fromFormat mean in every single page of the docs! Itâs covered once early on in one of the first pages under âusageâ. There is also a search feature in the docs you can use to help find it. The command help for a few of the most common commands also has the same information:
cfconfig import ?
toFormat=lucee@5.x
This is not valid per the docs. The format does not take a semantic version range, but the exact version that you want the config written for. But again, this is all barking up the wrong tree. Your very first command was fine so long as you ran it in he web root.
The cfconfig docs need some expansion in my humble opinion.
Feel free to submit some pull requests-- all the docs are stored in Github as markdown and there is an âedit on Gihubâ button on every page. But so far, everything youâve asked about is already documented. I just donât repeat the basics over again on every page.
If I try to Application.cfc route, it doesnât work at all.
This is a core feature of the CF engine, Lucee. I donât see anything wrong right off with the Application.cfc file you have there, but perhaps check to ensure youâre editing the right file and the code thatâs erroring isnât in another application.
The only thing that works
I assure you, CFConfig and Application.cfc datasources work. We just need to understand all the moving pieces you have in place. And in this case, Iâm pretty certain you need to edit or remove a stock .cfconfig.json file thatâs overwriting your datasource every time you auto-import it on server start!
To get up and running, all you need to do is likely add the datasource once via the admin and run
As I previously mentioned running the below command in the web root, completed succesfully but I still got the error that the datasource doesnât exist:
After that is when I started going down the âwrong pathâ but only because of the docs.
Iâm not sure what you mean here. What IS the correct to location if itâs not the /path/to/server/home.
Well, shouldnât it be covered in this particular instance since itâs relevant to the cfconfig command referenced? Idk maybe Iâm wrong. Not trying to criticize, certain pieces may need repeating if they are relevant to a specific command described.
So I tried that, it exported the config, I am clearly able to see the datasource in .cfconfig.json, but still getting the error that the datasource doesnât exist. Hereâs the relevant part out of the '.cfconfig.json` in my web root:
I agree, but even though the command was successful and when I listed the datasources with cfconfig datasource list the datasource appeared, it wasnât in cfadmin and I was still getting the error that the datasource didnât exist. So I tried the other cfconfig datasource commands to see if I can get it to work.
Yes, I see Eric did include a link to the docs for that command, but the JSON file is by far the most common way of doing this, and I think that was the expectation since you were already trying to use a JSON file-- just the wrong one.
When I run cfconfig datasource list I see the datasource:
Before or after you restarted the server? Iâm still not clear from your reply if the datasource is still there after youâve restarted, which will import any existing .cfconfig.json file in your web root.
Yes, there is a .cfconfig.json file in the web root
And does it define any datasoruces, even if itâs an empty struct? This is important since it determines whether or not the server start will replace any existing datasources with whatâs in the JSON file.
I donât see the âconfig transferredâ line as you suggest.
Thatâs interesting and a bit of a head scratcher. Unless you have an older version of CFConfig installed, it should output that. Previously, the --debug flag was the only way to trigger that text. So long as there is a file called exactly .cfconfig.json in your web root AND you havenât overridden the cfconfigfile path in your server.json to point elsewhere, AND you have the CFConfig module installed, it should be importing the settings of that file, no question.
Not sure what you mean this doesnât seem like a server home. Can you clarify?
The âserver homeâ as defined by CFConfig is covered in the docs. Did you read it?
Lucee 4/5 Web Context
The folder containing the lucee-web.xml.cfm file.
Lucee 4/5 Server Context
Path to the lucee-server folder containing the /context/lucee-server.xml file.
So the server home is where the actual ColdFusion or Lucee server itself is installed to, not the web root where your cfm files live. But again, you really donât need to use this since any CFConfig command run in the web root of a CommandBox server will automatically apply to that server without the need to specify a to or a from server home.
As I previously mentioned running the below command in the web root, completed succesfully but I still got the error that the datasource doesnât exist:
I get that. What Iâm trying to tell you is your time would have been better spent if you stopped to find out why the datasource wasnât there rather than trying 100 more commands. Just⊠log in to the admin and look if itâs there. This take about 20 seconds and will answer the question instantly of whether the saving of the datasource worked!
Iâm not sure what you mean here. What IS the correct to location if itâs not the /path/to/server/home.
Again, actually read the docs I linked to above. The server home is the actual installation directory of the server. The docs above have examples and everything.
Well, shouldnât it be covered in this particular instance since itâs relevant to the cfconfig command referenced?
No. Literally every single CFConfig command uses a to or a from parameter. Itâs global functionality that applies to every single part of the CLI. There are 36 separate commands in the CFConfig module and Iâm not going to paste the details of what to and from means on every single page of the docs. Which is why itâs covered once, at the top of the docs, under the usage section. And in your case, you donât even need to be using a to or a from parameter. In fact, most people who use CFGonfig donât need to use it based on their setup.
still getting the error that the datasource doesnât exist.
I would recommend backing up a little bit?
Are there other servers running that you donât realize (user server list --running )
Do you have another installation of ACF or Lucee on the same machine but on a different port?
Are you hitting the correct server in the URL when you test?
At the point you get the error that the datasource doesnât exist, what do you see when you log into the server context for Lucee and look at the list of datasources? Is the datasource listed there??
it wasnât in cfadmin
Before or after you restarted? Web or server context? Thereâs so many important details missing here.
I ended up deleting the application, re-creating, edited the .cfconfig.json with the datasource and it finally showed up in cfadmin. I donât know what happenned there.