Autobase Plugin

The includeAll(...) migration command breaks due to malformed URLs on windows

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: Grails-Autobase-0.8.2.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Autobase 0.8.2.5, grails 1.1, Windows, sun JDK 1.6.0_12

Description

Steps to reproduce

  1. 'grails create-app test-app' to create empty sample app
  2. 'cd test-app'
  3. 'grails install-plugin autobase' to install the latest autobase plugin
  4. 'grails create-migration ThisWillBreak' to create an empty autobase migration
  5. 'grails run-app' to run the app

This results in the stack trace at the bottom of this post. Note that my project at the time lived on an "Y:" drive on windows which is why the stack trace is referring to "Y". I have a potential fix for this and I'm working with Robert to verify and merge the fix in the next day or two.

The details

The root cause of the problem is that the liquibase FileOpener object passes out resource URLs which have the format "file://c:/mydir/myfile". The URLs in question do not conform to the RFC for URLs which states that a file url should have the form:

   file://<host>/<path>

where the <host> part can be left empty which leaves us with "file:///C:/mydir/myfile" (note the three slashes). Now it seems that URLs with either one slash "file:/C:/foo/bar" or three slashes "file:///C:/foo/bar" work on windows even though the first form is strictly speaking incorrect. Two slashes however confuse the crap out of the JDK and operations such as the url.openStream() in our case will throw a tantrum and go home crying when pushed.

Suggested fix

An interim fix will be to use org.apache.commons.io.FileUtils.toFile(<URL>) and call file.toURI().toURL() to get URLs which work. We only do this for URLs with protocol == 'file' so that other formats will keep working as before. This fix is not pretty, so if anyone has a more beautiful solution it would be much appreciated.

Resulting stack trace

y:\projects\autobase\test-app>grails run-app
Welcome to Grails 1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: y:\grails-1.1

Base Directory: Y:\projects\autobase\test-app
Running script y:\grails-1.1\scripts\RunApp.groovy
Environment set to development
    [mkdir] Created dir: Y:\projects\autobase\test-app\web-app\plugins\autobase-0.8.2.5
     [copy] Copying 28 files to Y:\projects\autobase\test-app\web-app\plugins\autobase-0.8.2.5
    [mkdir] Created dir: C:\Users\mbjarland\.grails\1.1\projects\test-app\classes
  [groovyc] Compiling 7 source files to C:\Users\mbjarland\.grails\1.1\projects\test-app\classes
  [groovyc] Compiling 6 source files to C:\Users\mbjarland\.grails\1.1\projects\test-app\classes
    [mkdir] Created dir: C:\Users\mbjarland\.grails\1.1\projects\test-app\resources\grails-app\i18n
[native2ascii] Converting 11 files from Y:\projects\autobase\test-app\grails-app\i18n to C:\Users\mbjarland\.grails\1.1\projects\test-app\resources\grails-app\i18n
     [copy] Copying 1 file to C:\Users\mbjarland\.grails\1.1\projects\test-app\classes
     [copy] Copied 2 empty directories to 2 empty directories under C:\Users\mbjarland\.grails\1.1\projects\test-app\resources
Running Grails application..
Starting migration
Mar 23, 2009 1:43:37 PM liquibase.database.template.JdbcTemplate comment
INFO: Create Database Lock Table
Mar 23, 2009 1:43:37 PM liquibase.database.template.JdbcTemplate comment
INFO: Lock Database
Mar 23, 2009 1:43:37 PM liquibase.lock.LockHandler acquireLock
INFO: Successfully acquired change log lock
Mar 23, 2009 1:43:37 PM liquibase.database.template.JdbcTemplate comment
INFO: Create Database Change Log Table
Mar 23, 2009 1:43:37 PM liquibase.database.AbstractDatabase checkDatabaseChangeLogTable
INFO: Creating database history table with name: DATABASECHANGELOG
Mar 23, 2009 1:43:37 PM sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Including directory file://Y:/projects/autobase/test-app/migrations/Mbjarland
Mar 23, 2009 1:43:37 PM sun.reflect.NativeMethodAccessorImpl invoke0
INFO: Including file file://Y:/projects/autobase/test-app/migrations/Mbjarland/BrokenIncludeAllMigration.groovy
Mar 23, 2009 1:43:56 PM liquibase.database.template.JdbcTemplate comment
INFO: Release Database Lock
Mar 23, 2009 1:43:56 PM liquibase.lock.LockHandler releaseLock
INFO: Successfully released change log lock
2009-03-23 13:43:56,556 [main] ERROR AutobaseGrailsPlugin  - Error during Autobase migration
liquibase.exception.ChangeLogParseException: Unknown error while executing file at ./migrations/changelog.groovy
        at liquibase.parser.groovy.GroovyChangeLogParser.parse(GroovyChangeLogParser.groovy:46)
        at liquibase.parser.ChangeLogParserImpl$parse.call(Unknown Source)
        at liquibase.LiquibaseDsl.update(LiquibaseDsl.groovy:83)
        at liquibase.LiquibaseDsl$update.call(Unknown Source)
        at Autobase.migrate(Autobase.groovy:41)
        at Autobase$migrate.call(Unknown Source)
        at AutobaseGrailsPlugin$__clinit__closure7.doCall(AutobaseGrailsPlugin.groovy:56)
        at AutobaseGrailsPlugin.invokeMethod(AutobaseGrailsPlugin.groovy)
        at AutobaseGrailsPlugin$_closure2.doCall(AutobaseGrailsPlugin.groovy:69)
        at grails.web.container.EmbeddableServer$start.call(Unknown Source)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy:145)
        at _GrailsRun_groovy$_run_closure5_closure11.doCall(_GrailsRun_groovy)
        at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:269)
        at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:137)
        at _GrailsRun_groovy.runInline(_GrailsRun_groovy:104)
        at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
        at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:58)
        at RunApp$_run_closure1.doCall(RunApp.groovy:33)
        at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334)
        at gant.Gant$_dispatch_closure6.doCall(Gant.groovy)
        at gant.Gant.withBuildListeners(Gant.groovy:344)
        at gant.Gant.this$2$withBuildListeners(Gant.groovy)
        at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
        at gant.Gant.dispatch(Gant.groovy:334)
        at gant.Gant.this$2$dispatch(Gant.groovy)
        at gant.Gant.invokeMethod(Gant.groovy)
        at gant.Gant.processTargets(Gant.groovy:495)
        at gant.Gant.processTargets(Gant.groovy:480)
Caused by: liquibase.exception.ChangeLogParseException: Groovy includeAll at ./migrations failed
        at liquibase.parser.groovy.GroovyDatabaseChangeLog.includeAll(GroovyDatabaseChangeLog.groovy:113)
        at Script1$_run_closure1.doCall(Script1.groovy:3)
        at Script1$_run_closure1.doCall(Script1.groovy)
        at liquibase.parser.groovy.GroovyChangeLogParser$_parse_closure1.doCall(GroovyChangeLogParser.groovy:41)
        at Script1.run(Script1.groovy:2)
        at liquibase.parser.groovy.GroovyChangeLogParser.parse(GroovyChangeLogParser.groovy:37)
        ... 28 more
Caused by: liquibase.exception.ChangeLogParseException: Groovy includeAll at /projects/autobase/test-app/migrations/Mbjarland failed
        at liquibase.parser.groovy.GroovyDatabaseChangeLog.includeAll(GroovyDatabaseChangeLog.groovy:113)
        at liquibase.parser.groovy.GroovyDatabaseChangeLog$_includeAll_closure1.doCall(GroovyDatabaseChangeLog.groovy:109)
        at liquibase.parser.groovy.GroovyDatabaseChangeLog.includeAll(GroovyDatabaseChangeLog.groovy:97)
        ... 33 more
Caused by: java.net.UnknownHostException: Y
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:519)
        at java.net.Socket.connect(Socket.java:469)
        at java.net.URL.openStream(URL.java:1009)
        at liquibase.parser.groovy.GroovyDatabaseChangeLog.include(GroovyDatabaseChangeLog.groovy:121)
        at liquibase.parser.groovy.GroovyDatabaseChangeLog$_includeAll_closure1.doCall(GroovyDatabaseChangeLog.groovy:103)
        at liquibase.parser.groovy.GroovyDatabaseChangeLog.includeAll(GroovyDatabaseChangeLog.groovy:97)
        ... 35 more
Ended migration
Server running. Browse to http://localhost:8080/test-app

Activity

Hide
Dan Tanner added a comment -

A little extra info on the windows URI issue from Sun's perspective:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5018803

Their recommendation is to use java.net.URI.

I don't have the libdsl source though, and this is my first time perusing the source. Is the root of the problem in liquibase's FileSystemFileOpener?

public ClassLoader toClassLoader() {
try {
return new URLClassLoader(new URL[]{new URL("file://" + baseDirectory)});
} catch (MalformedURLException e) { throw new RuntimeException(e); }
}
}

At the moment this issue hoses all of us poor souls that are forced to use windows machines at work, so let me know how I can help.

Show
Dan Tanner added a comment - A little extra info on the windows URI issue from Sun's perspective: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5018803 Their recommendation is to use java.net.URI. I don't have the libdsl source though, and this is my first time perusing the source. Is the root of the problem in liquibase's FileSystemFileOpener? public ClassLoader toClassLoader() { try { return new URLClassLoader(new URL[]{new URL("file://" + baseDirectory)}); } catch (MalformedURLException e) { throw new RuntimeException(e); } } } At the moment this issue hoses all of us poor souls that are forced to use windows machines at work, so let me know how I can help.
Hide
Robert Fischer added a comment -

Release is forthcoming to fix this issue. I'd appreciate help vetting it once that release has gone out – not being on a Windows box myself, I can only do what I think helps.

Show
Robert Fischer added a comment - Release is forthcoming to fix this issue. I'd appreciate help vetting it once that release has gone out – not being on a Windows box myself, I can only do what I think helps.
Hide
Burt Beckwith added a comment -

Project is abandoned

Show
Burt Beckwith added a comment - Project is abandoned

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1w 1d
Original Estimate - 1 week, 1 day
Remaining:
1w 1d
Remaining Estimate - 1 week, 1 day
Logged:
Not Specified
Time Spent - Not Specified