I wanted to execute an ant build file from java code using the org.apache.tools.ant.Project APIs.. Even though I was able to run the ant script successfully through the ant perspective of the IDE, I am getting error calling the script from java.. Not much information is available in using Project project = new Project(); project.init();..
Could anyone help me find more information in calling an ant build file from java code?
BUILD FAILED
D:\Workspaces\SSDownload\SS Download\src\ddlutils-ant-build.xml:27: Could not parse or write data file D:\Workspaces\SSDownload\SS Download\src\db-data.xml
due to
org.apache.ddlutils.DdlUtilsException: java.net.MalformedURLException: unknown protocol: d
at org.apache.ddlutils.io.DatabaseDataIO.writeDataToDatabase(DatabaseDataIO.java:730)
This error I do not get running the build file directly!!! I am trying to migrate a database using the DDLUtils API inside the ant build file. Any tips?
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35222
7
posted
0
That sounds like the path you're providing ("D:\...") can't be processed; at least that's what I think the "unknown protocol: d" might mean. Try prefixing it by "file:///" so that it becomes an actual URL (instead of a file name).
Yes, the key is that it's a MalformedURLException. Meaning that they support getting the data from not only files, but via any other supported protocol (such as http or ftp).
It's [/i]possible[/i] that the normalized filename syntax might have worked:
Assuming that capitalization is accurate and that whatever mechanism is feeding the filename is handling the space in the path correctly. However to be totally safe, try this:
Martijn Verburg wrote:You need to take a look at how the writeDataToFile target operates, what's the pass directory it uses? That's where the D:\ will be coming from.
Definitely. Are the db-schema and db-data files on the D: drive?
It's possible that this particular task wasn't designed Windows-friendly.
Tiju Thomas
Greenhorn
Joined: May 25, 2008
Posts: 22
posted
0
Exactly Tim. Both the files are on the D drive. But I am able to read the db-schema but not the db-data alone.
database-write:
Jan 13, 2010 11:41:08 AM org.apache.ddlutils.task.DdlToDatabaseTask readSingleSchemaFile
INFO: Read schema file D:\Workspaces\SLDownload\SS Download\src\db-schema.xml
.
.
.
INFO: Executed 81 SQL command(s) with 0 error(s)
Jan 13, 2010 12:01:07 PM org.apache.ddlutils.task.WriteSchemaToDatabaseCommand execute
INFO: Written schema to database
BUILD FAILED
D:\Workspaces\SLDownload\SL Download\src\ddlutils-ant-build.xml:27: Could not parse or write data file D:\Workspaces\SLDownload\SL Download\src\db-data.xml
I tried deleting the contents of the db-data.xml and then running the script, but still !