17/04/20 17:27:10 FATAL conf.Configuration: error parsing conf file:/usr/local/apache-hive-1.2.2-bin/conf/hive-site.xml
org.xml.sax.SAXParseException; systemId: file:/usr/local/apache-hive-1.2.2-bin/conf/hive-site.xml; lineNumber: 501; columnNumber: 95; The reference to entity "characterEncoding" must end with the ';' delimiter.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2480)
at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2468)
at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2536)
at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2502)
at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2405)
at org.apache.hadoop.conf.Configuration.get(Configuration.java:1232)
at org.apache.hadoop.hive.conf.HiveConf.getVar(HiveConf.java:2615)
at org.apache.hadoop.hive.conf.HiveConf.getVar(HiveConf.java:2636)
at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:2707)
at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:2656)
at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:61)
at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:448)
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:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
发现是sax解析造成的问题。解决方案很简单,就是把配置项值中用到"&"的地方改成"&"。原因是sax解析的类库在读取文件的时候是根据转义后的格式进行读取的,遇到"&"就认为是一个转义字符串,开始找结束符";",找不到自然就报错了。