RMLio / rmlmapper-java

The RMLMapper executes RML rules to generate high quality Linked Data from multiple originally (semi-)structured data sources
http://rml.io
MIT License
146 stars 61 forks source link

Problem with LocalFileAccess:getInputStream when file is not absolute #156

Open shawnhind opened 2 years ago

shawnhind commented 2 years ago

My mapping file just had the logical source someFile.csv. I pointed the RecordsFactory class to the path where I had this file on my system. In my case it was in /tmp/ directory.

When the process would get to LocalFileAccess:getInputStream it would fail on line 40 calling org.apache.commons.io.FileUtils.getFile with a MethodNotFound exception for String[]. In this case it was trying to pass it the base path and the path. This however failed.

If I instead changed my mapping file to have the full path /tmp/someFile.csv it then worked, however I was not able to get it to work using a relative path.

When this method was being called:

this.path on the LocalFileAccess object was: "someFile.csv" this.basePath on the LocalFileAccess object was "/tmp/"

java.io.File org.apache.commons.io.FileUtils.getFile(java.lang.String[])': java.lang.NoSuchMethodError
java.lang.NoSuchMethodError: 'java.io.File org.apache.commons.io.FileUtils.getFile(java.lang.String[])'
    at be.ugent.rml.access.LocalFileAccess.getInputStream(LocalFileAccess.java:40)
    at be.ugent.rml.records.CSVRecordFactory.getRecordsForCSV(CSVRecordFactory.java:144)
    at be.ugent.rml.records.CSVRecordFactory.getRecords(CSVRecordFactory.java:63)
    at be.ugent.rml.records.RecordsFactory.getRecords(RecordsFactory.java:137)
    at be.ugent.rml.records.RecordsFactory.createRecords(RecordsFactory.java:71)
    at be.ugent.rml.Executor.getRecords(Executor.java:429)
    at be.ugent.rml.Executor.executeWithFunctionV5(Executor.java:165)
    at be.ugent.rml.Executor.executeV5(Executor.java:152)
    at be.ugent.rml.Executor.executeV5(Executor.java:250)
    at rml.RmlMappingUtils.rmlProcess(RmlMappingUtils.java:126)
    at rml.RmlMappingUtils.handleRequest(RmlMappingUtils.java:56)
DylanVanAssche commented 2 years ago

Hi @shawnhind !

Thanks for your issue! This seems like an issue with how the paths to files are resolved when using relative paths. Do you have the mapping file and CSV file still?

jheus commented 2 years ago

We have the same issue. When setting -mappingfile to a subdirectory and place the data files in that same subdirectory we have the same error. The mappingfile is found and being parsed, but the files are not found there (the csvw:url is not having relative paths):

<#Arbeidsovereenkomst>
    a rr:TriplesMap;
    rml:logicalSource [
        rml:source [
            a csvw:Table;
            csvw:url "Dienstverband.txt" ;
            csvw:dialect [ 
                a csvw:Dialect;
                csvw:delimiter ";"
            ]
        ];
        rml:referenceFormulation ql:CSV;
    ];