Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase fails if computer is not connected to internet

Tags:

liquibase

When I am trying to start Liquibase (Karaf is used), I get the following error

'Failed to read schema document http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xml, bacause 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not '

If computer is connected to internet, this error is not reproduced.

like image 740
Albert Ashrafzyanov Avatar asked Sep 02 '15 09:09

Albert Ashrafzyanov


2 Answers

I stumbled across this myself recently.

You need to change this:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">

and remove the URL to the XSD:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog-3.0.xsd">

Note the space between http://www.liquibase.org/xml/ns/dbchangelog and dbchangelog-3.0.xsd. The first element is the URI for the namespace, the second element points to the actual XSD file. If that doesn't include a URL, the XML parser will try to use a local file.

Then put the actual XSD into the same directory where the changelog XML is located.

You need to download that from a computer with internet access of course, e.g. using:

wget http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd

or by simply opening the URL with the browser and then saving the file.

Note that you also need to specify a .xsd file for the schema location, not a .xml (as it is shown in the question).

like image 98
a_horse_with_no_name Avatar answered Oct 18 '22 14:10

a_horse_with_no_name


This problem was fixed. It turns Liquibase-osgi.jar contains own packages and also it contains liquibase.jar. When LiquibaseEntityResolver.java tries to find *.xsd, it finds two files *.xsd with same name. And after that liquibase throws Exception. I deleted duplicate files and everything was working

BTW Root element of changelog file looks like

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
like image 42
Albert Ashrafzyanov Avatar answered Oct 18 '22 15:10

Albert Ashrafzyanov