Support Questions

Find answers, ask questions, and share your expertise

Syntax error in hive-site.xml file

avatar

I am not sure what exactly is missing or extra character in this configuration file, but I am getting this error while loading file.

bash: /hive/conf/hive-site.xml: line 1: syntax error near unexpected token newline' bash: /hive/conf/hive-site.xml: line 1:'

My configuration file is :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby:;databaseName=/hdfs/hive/metastore_db;create=true</value>
<description>
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/hdfs/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value/>
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>org.apache.derby.jdbc.EmbeddedDriver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.PersistenceManagerFactoryClass</name>
<value>org.datanucleus.api.jdo.JDOPersistenceManagerFactory</value>
<description>class implementing the jdo persistence</description>
</property>
</configuration>
9 REPLIES 9

avatar
Master Mentor

@Chandan Kumar

You should not leave any space before the "<?xml version="1.0" .......?>" line in your XML.

Means you should not have " <?xml version="1.0" .......?>" (this is incorrect because it has leading space)

Means there should be no leading space in that first line. Please remove that space which is present at the beginning of the mentioned line.

Example of incorrect first line:

	<?xml version="1.0" encoding="UTF-8" standalone="no"?>

.

Example of correct first line as following:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

.

avatar

I validated XML content with

http://codebeautify.org/xmlvalidator

It's a valid XML.

Also there are no leading space in the first line.

avatar
Master Mentor

@Chandan Kumar

Instead of pasting the XML here please attach the file itself so that we can find what is wrong. Based on the content you pasted in your earlier post.... i see it is invalid ... Please see:

Error on->  Line :1 Column :10
Message :XML declaration allowed only at the start of the documen

.

15974-error-hivesite-xml.png

You can open the file in "vi" editor to see if the First line has a leading space or hidden character.

avatar
Master Mentor

@Chandan Kumar

The easiest option for you will be to Delete the first line and then type it manually instead of copy pasting from some where, this will avoid the issue of invisible hidden characters.

avatar
hive-site.xml

Here you go, attached is the xml configuration file, please validate the content, at my end its a valid content.

avatar

hive-site.xml

Please find the attachment..

avatar
Master Mentor

You can also use some online XML validators to validate your XML and to know what is wrong.

avatar
New Contributor

I think the error is a bash error rather than an XML error. Check the command line you are using to load the file for syntax errors, particularly misplaced <, >, or | characters.

If you still think it is an XML problem and you are sure the first five characters in the file are '<?xml', then you can consider these XML oddities:

  • You have standalone="yes", which is incorrect, but should be ignored by the parser. The standalone document declaration is only considered if you have a <!DOCTYPE... defined (which you don't) and it should only be standalone="yes" if the DTD has information that could change your document such as entity declarations or required attributes.
  • You have an empty value (<value/>) for the property with a name of "hive.metastore.uris"

avatar

Hi @Chandan Kumar

Can you elaborate when you say loading file.

What exactly are you doing?