creating a csv file when running scriptella from a jar on Linux

291 views
Skip to first unread message

Matt S

unread,
May 9, 2013, 4:16:28 PM5/9/13
to scrip...@googlegroups.com
My application is bundled in a jar file, and run on Linux. It creates a CSV file, reads data from a database, and writes it into the CSV file. I cannot get it to actually create the CSV file, because it always appends the path name at the end of the end of the jar file, rather than going absolute.

The code works fine on Windows7, when the path is "C:/MyAppName/working/output/MyAppReport.csv". It was my understanding having a '/' at the beginning of the path on Linux was the same as 'C:/' on Windows. Any ideas?

JAVA CODE Calling Scriptella
HashMap<String,String> map = new HashMap<String,String>();
map.put("output", getPath() + outputFolder + outputFilename);

URL u = BatchReportGenerator.class.getResource("MyAppName.etl.xml");
EtlExecutor etl = EtlExecutor.newExecutor(u, map);
etl.execute();

OUTPUT PATH VALUE that is passed in as "output"
/mas/dev/app/MyAppName/working/output/MyAppReport.csv

ETL.XML line where it's trying to create the file.
   <connection id="out" driver="csv" url="$output">

ERROR:
CSV provider exception: Unable to open URL jar:file:/mas/dev/app/MyAppName/lib/MyAppName-1.0.0.0.jar!/mas/dev/app/MyAppName/working/output/MyAppReport.csv for output
Error codes: []
Driver exception: java.net.UnknownServiceException: protocol doesn't support output
scriptella.execution.EtlExecutorException: Location: /etl/script[1]
CSV provider exception: Unable to open URL jar:file:/mas/dev/app/MyAppName/lib/MyAppName-1.0.0.0.jar!/mas/dev/app/MyAppName/working/output/MyAppReport.csv for output
Error codes: []
Driver exception: java.net.UnknownServiceException: protocol doesn't support output
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:190)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:161)
at com.myapp.BatchReportGenerator.generateReport(BatchReportGenerator.java:57)
at com.myapp.BatchMain.runBatch(BatchMain.java:24)
at com.myapp.BatchMain.main(BatchMain.java:15)
Caused by: 
scriptella.core.ExceptionInterceptor$ExecutionException: /etl/script[1] failed: Unable to open URL jar:file:/mas/dev/app/MyAppName/lib/MyAppName-1.0.0.0.jar!/mas/dev/app/MyAppName/working/output/MyAppReport.csv for output
at scriptella.core.ExceptionInterceptor.execute(ExceptionInterceptor.java:44)
at scriptella.core.Session.execute(Session.java:103)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:227)
at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:183)
... 4 more

Fyodor Kupolov

unread,
May 10, 2013, 4:25:10 AM5/10/13
to scrip...@googlegroups.com
Hi Matt,

I think the reason for the problem is that the ETL file is loaded from the JAR. In this case a jar: protocol is used and all URIs are resolved relatively to it. So I advise you to try setting the protocol explicitly, e.g. 
   <connection id="out" driver="csv" url="file:/mas/dev/app/MyAppName/working/output/MyAppReport.csv">

Regards,
Fyodor

Matt S

unread,
May 10, 2013, 11:04:10 AM5/10/13
to scrip...@googlegroups.com
That worked! Both on Unix and Windows. Thank you so much Fyodor!
Reply all
Reply to author
Forward
0 new messages