Error getting changeLogFile fullpath using EJB

Hello people!

I’m using Liquibase in the following way:

@PostConstruct
protected void updateDataBase() {       
        try {
            Liquibase liquibase = new Liquibase(getChangeLogFilePath(), new ClassLoaderFileOpener(), getDataSource().getConnection());
            liquibase.update("");
        } catch (Exception ex) {
            logger.error("Liquibase error: " + ex.getMessage(), ex);
            throw new RuntimeException(ex);
        }
    }

where getChangeLogFilePath() returns “com/joaosavio/dominio/liquibase/trimpaperChangeLog-master.xml”. But it’s returning FileNotFound!

Inside my application.ear

-META-INF 
-lib
-ejb-shared.jar
-ejb.jar

-com/joaosavio/ejb/…

-com/joaosavio/dominio/liquibase/trimpaperChangeLog-master.xml
-web.war


I’ve also tried get the file as a resource doing URL url = getClass().getResource("/com/joaosavio/dominio/liquibase/trimpaperChangeLog-master.xml") and works, but as far I’m concerned Liquibase works with the file fullpath and there is no guarantee that url will return a valid file path (in fact this problem is happenning).

Is there another way to run Liquibase? Does liquibase accepts an InputStream as input? Any other idea???


Hello,

I have the same problem. I’ve tried some relative and absolute paths, but nothing works.
In another stateless session bean I read a property file successfully . Here I use a absolute path like “/META-INF/file.properties”. So I think the problem is within the liquibase code.

Tomorrow I will try to find the file with the File-class from the classpath and get the absolute path that I want to use at the liquibase constructor.
Your idea to add a constructor with a InputStream is very good, too. Maybe the last chance.