ARTIFACTORY: How to validate invalid properties from config descriptor
Artifactory config descriptor is the file artifactory.config.latest.xml located under $JFROG_HOME/etc/artifactory.
This xml file follows the xsd schema file defined at the top of it. Having a corrupted config descriptor will cause artifactory to fail to come up. You might be having a corrupted config descriptor for many reasons, but it usually happens after a failed upgrade, rollback, import, or config descriptor bootstrap.
A working config descriptor file needs to have the correct xsd version that matches the running artifactory version, but it also need all the properties in it to be valid according to the xsd schema.
Validate the config descriptor file against xsd and find out what’s wrong
You can follow the following steps to validate your config descriptor files to find out if there are extra/corrupted properties in it:
1. Download the xsd file. At the top of the config descriptor, you will see the url to download xsd.
2. Run the following script against it
3. If you have an extra property (or misspell) that doesn’t belong to the current xsd schema, you will see
artifactory.config.xml:2: element repositoriesGeneralConfig: Schemas validity error : Element '{http://artifactory.jfrog.org/xsd/3.3.0}repositoriesGeneralConfig': This element is not expected. Expected is one of ( {http://artifactory.jfrog.org/xsd/3.3.0}forceNativeDbLocksMechanismInAutoMode, {http://artifactory.jfrog.org/xsd/3.3.0}serverName, {http://artifactory.jfrog.org/xsd/3.3.0}offlineMode, {http://artifactory.jfrog.org/xsd/3.3.0}archiveIndexEnabled, {http://artifactory.jfrog.org/xsd/3.3.0}fileUploadMaxSizeMb, {http://artifactory.jfrog.org/xsd/3.3.0}revision, {http://artifactory.jfrog.org/xsd/3.3.0}addons, {http://artifactory.jfrog.org/xsd/3.3.0}mailServer, {http://artifactory.jfrog.org/xsd/3.3.0}xrayConfig, {http://artifactory.jfrog.org/xsd/3.3.0}security ).
artifactory.config.xml fails to validate
It will show you the line number ( 2 ) and the corrupted elements (repositoriesGeneralConfig)
In this case, repositoriesGeneralConfig doesn’t belong to http://artifactory.jfrog.org/xsd/3.3.0.
We will need to remove it.
You will need to repeat the steps until you see:
artifactory.config.xml validates
Note:
- In case of an upgrade, you should always have a backup of the DB and filesystem to fall back. Try moving forward with the upgrade instead of falling back. The artifactory aims to cover situations where you have to fall back and facings issues after restoring to backup.
- Make sure you are backing up the config descriptor that you modified so that you can always go back to the initial failing state if needed.