Understanding the "XML object with name '<xml_obj_name>' already exists" Error

Occasionally users will run into the following error message, or something similar, when starting their Connext application and will have a hard time identifying the cause.

 

Error: Failed to create Connector:

RTIXMLObject_addChild: XML object with name '<xml_obj_name>' already exists

RTIXMLParser_onStartTag:Parse error at line 137: XML object could not be added to the DOM

RTIXMLParser_parseFromFile_ex:Parse error in file '/path/to/USER_QOS_PROFILES.xml'

DDS_XMLParser_parse_from_file:Error parsing file

DDS_QosProvider_load_profiles_from_urlI:ERROR: loading profiles file '/path/to/USER_QOS_PROFILES.xml'

DDS_QosProvider_load_profiles_from_url_groupI:ERROR: loading profiles

DDS_QosProvider_load_profiles_from_url_sequenceI:ERROR: loading profiles

DDS_QosProvider_load_profiles_from_policyI:ERROR: loading profiles

DDS_QosProvider_load_profilesI:ERROR: loading profiles

DDS_DomainParticipantFactory_load_profilesI:!load profiles

RTIDDSConnector_newI:!new set factory qos

RTIDDSConnector_EntitiesLookupList_delete:RTIDDSConnector

(Note: while this error message is from Connector, this same error can also be generated when using the core libraries or starting an infrastructure services instance)

This error message indicates that an XML object, such as a QoS profile, that is identified by a unique name and should be only defined once is being created for a second time. The intention of this is to warn the user when their XML configuration defines the same XML object multiple times. This could potentially lead to hard-to-identify problems if the user is unaware that one version of an object they have defined is being loaded twice.

This error can appear even when all user-defined XML objects are only defined once. In this case, the cause of this error is typically that the user is loading the same file twice. For example, a user may be naming their configuration file “USER_QOS_PROFILES.xml,” and also explicitly referencing this filename from within their application (or passing the filename through the -cfgFile flag for an infrastructure service instance).
Because “USER_QOS_PROFILES.xml” is a known filename that the middleware automatically discovers and reads when a Connext application is started, this file is being read twice. The file is read once due to being automatically discovered, and a second time because the user explicitly provides the file path through an API call, or infrastructure service command-line flag.

When the file is read a second time, any XML objects that are defined in this configuration file are created a second time, producing the “XML object with name '<xml_obj_name>' already exists” error. This error can be eliminated by simply renaming the file to something other than “USER_QOS_PROFILES.xml” so that the file is only read once.

Another possible scenario that would produce the same error is if a user has two files containing duplicated XML objects, one named “USER_QOS_PROFILES.xml,” and another named something else (let’s call the second file “MY_PROFILES.xml”). While the user may intend to only use “MY_PROFILES.xml” by providing its filename to the application, “USER_QOS_PROFILES.xml” will still be read automatically. In this case, a possible solution is to consolidate the entire configuration into the “MY_PROFILES.xml” file and delete “USER_QOS_PROFILES.xml.”