MID Server won't start after new installation, password change or other config.xml edit because of SAXParseException due to using unencoded special characters that are invalid XMLDescriptionMID Server won' t start after new installation, password change or other config.xml edit because of SAXParseException due to using unencoded special characters that are invalid XML. The XML specification defines five "predefined entities" representing special characters, and requires that all XML processors honor them.http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references "&'<> If any parameter value in a MID Server config.xml file contains one of these characters un-escaped/encoded, the MID Server will fail to start with a SAXParseException shown in the agent log of the MID Server. It is also possible to see the same symptom by accidently loosing the closing text of the parameter tag /> when editing config.xml, as selecting text in Word often ends up with more selected than you expected. The ZIP installer would also have a similar issue with passwords.Steps to Reproduce Manually edit the config.xml file, adding a password that contains unencoded characters.Restart the MID Server An example of an ampersand, in this case the password included &JY on the end, and the parser thinks JY is an entity name. Wrapper log: 2018/10/26 12:06:28 | Launching a JVM...2018/10/26 12:06:28 | WrapperManager: Initializing...2018/10/26 12:06:29 | Logger for 'glide' has not been configured by the container, configuring now:2018/10/26 12:06:29 | Configuring log handler: java.util.logging.FileHandler2018/10/26 12:06:29 | Setting useParentHandlers=false for Logger 'glide'2018/10/26 12:06:29 | Overriding formatter to: com.glide.util.DefaultLogFormatter (for handler: java.util.logging.FileHandler)2018/10/26 12:06:29 | [Fatal Error] :32:78: The reference to entity "JY" must end with the ';' delimiter.2018/10/26 12:06:30 | ServiceNow MID Server Core service started.2018/10/26 12:06:31 | <-- Wrapper Stopped Agent Log: 10/26/18 12:06:28 (978) WrapperStartStopAppMain Running under Java version: 1.8.0_191, java PID: 3488, args: start10/26/18 12:06:28 (978) WrapperStartStopAppMain Initializing MID Server10/26/18 12:06:28 (994) MIDServer Creating injector...10/26/18 12:06:29 (244) MIDServer WARNING *** WARNING *** org.xml.sax.SAXParseException; lineNumber: 32; columnNumber: 78; The reference to entity "JY" must end with the ';' delimiter.10/26/18 12:06:29 (244) MIDServer Using configuration: C:\ServiceNow\MIDServers\Core_Production\agent\config.xml10/26/18 12:06:29 (244) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='refresh_rate']10/26/18 12:06:29 (244) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='instance.date.format']10/26/18 12:06:29 (244) MIDServer WARNING *** WARNING *** XPathUtil.selectNodes called with null using xpath: //parameter10/26/18 12:06:29 (244) MIDServer SEVERE *** ERROR *** Unexpected exception, terminating the MID server An older example of an ampersand in the password: 06/25/13 11:10:31 (394) MIDServer MID Server starting06/25/13 11:10:32 (828) MIDServer WARNING *** WARNING *** org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.06/25/13 11:10:32 (828) MIDServer Using configuration: C:\Users\ServiceNow\Desktop\agent\config.xml06/25/13 11:10:32 (875) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='auto_upgrade']06/25/13 11:10:32 (875) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='refresh_rate']06/25/13 11:10:32 (875) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='instance.date.format']06/25/13 11:10:32 (875) MIDServer WARNING *** WARNING *** XPathUtil.selectNodes called with null using xpath: //parameter06/25/13 11:10:32 (876) MIDServer SEVERE *** ERROR *** Unexpected exception terminating the MID serverjava.lang.NullPointerExceptionat com.service_now.mid.services.Config.getParameters(Config.java:168)at com.service_now.mid.services.Config.loadProperties(Config.java:339)at com.service_now.mid.services.Config.init(Config.java:140)at com.service_now.mid.services.StartupSequencer.start(StartupSequencer.java:53)at com.service_now.mid.MIDServerState.initForStart(MIDServerState.java:177)at com.service_now.mid.MIDServerState.onStart(MIDServerState.java:77)at com.service_now.mid.MIDServerState.poll(MIDServerState.java:40)at com.service_now.mid.MIDServer.run(MIDServer.java:49)at com.service_now.mid.Main.runMID(Main.java:69)at com.service_now.mid.Main.handleStart(Main.java:31)at com.service_now.mid.Main.main(Main.java:25)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.tanukisoftware.wrapper.WrapperStartStopApp.run(WrapperStartStopApp.java:238)at java.lang.Thread.run(Unknown Source)06/25/13 11:10:33 (266) Thread-1 Shutdown hook entered; shutting down MID server An older example where quotation mark was used unescaped: 01/11/19 13:24:47 (752) WrapperStartStopAppMain Running under Java version: 1.8.0_60, java PID: 4772, args: start01/11/19 13:24:47 (768) WrapperStartStopAppMain Initializing MID Server01/11/19 13:24:47 (799) MIDServer Creating injector...01/11/19 13:24:48 (580) MIDServer WARNING *** WARNING *** org.xml.sax.SAXParseException; lineNumber: 34; columnNumber: 3; The value of attribute "value" associated with an element type "parameter" must not contain the '<' character.01/11/19 13:24:48 (580) MIDServer Using configuration: C:\ServiceNow\Jakarta\agent\config.xml01/11/19 13:24:48 (596) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='refresh_rate']01/11/19 13:24:48 (596) MIDServer WARNING *** WARNING *** XPathUtil.selectSingleNode called with null using xpath: //parameter[@name='instance.date.format']01/11/19 13:24:48 (596) MIDServer WARNING *** WARNING *** XPathUtil.selectNodes called with null using xpath: //parameter01/11/19 13:24:48 (596) MIDServer SEVERE *** ERROR *** Unexpected exception, terminating the MID serverjava.lang.NullPointerExceptionat com.service_now.mid.services.Config.loadParameters(Config.java:217)at com.service_now.mid.services.Config.loadProperties(Config.java:346)at com.service_now.mid.services.Config.init(Config.java:189)at com.service_now.mid.MIDServer.createInjector(MIDServer.java:258)at com.service_now.mid.MIDServer.run(MIDServer.java:193)at com.service_now.mid.Main.runMID(Main.java:72)at com.service_now.mid.Main.handleStart(Main.java:33)at com.service_now.mid.Main.main(Main.java:27)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:497)at org.tanukisoftware.wrapper.WrapperStartStopApp.run(WrapperStartStopApp.java:264)at java.lang.Thread.run(Thread.java:745) Opening the config.xml file in a browser or an online parser will confirms it is bad XML: In this case it was a missing closing /> on the end of the line e.g.<parameter name="name" value="London MID Server 1"instead of<parameter name="name" value="London MID Server 1" />WorkaroundThis is by design. For workaround information, see MID Server documentation: MID Server configuration - Using special characters in an XML fileMID Server protected records and reserved characters In summary: replace " with "replace & with &replace ' with 'replace < with <replace > with > For example, to specify the password as test& in the MID Server config.xml file: <parameter encrypt="true" name="mid.instance.password" value="test&"/>Related Problem: PRB586201