imageio-ext
  1. imageio-ext
  2. IMAGEIO_EXT-40

UnsatisfiedLinkError thrown by GDALUtilities.isDriverAvailable

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1.3
    • Fix Version/s: 1.2-M0, 1.1.4
    • Component/s: gdal-framework
    • Labels:
      None
    • Environment:

      Description

      GDALUtilities.isDriverAvailable calls isGDALAvailable whose implementation safely catches UnsatisfiedLinkError, allowing clients to detect the absence of a working GDAL. However, isDriverAvailable then calls gdal.GetDriverByName, which does not catch UnsatisfiedLinkError. One platform where this can occur is Fedora 15 x86_64:

      $ rpm -qa | grep gdal
      gdal-1.7.3-14.fc15.x86_64
      gdal-java-1.7.3-14.fc15.x86_64
      gdal-devel-1.7.3-14.fc15.x86_64
      

      These libraries work just well enough to trick isGDALAvailable into passing before failing with UnsatisfiedLinkError in gdal.GetDriverByName. This is manifested by the GeoTools trunk build failing with:

      {format}
      java.lang.UnsatisfiedLinkError: org.gdal.gdal.gdalJNI.SWIGDriverUpcast(J)J
      at org.gdal.gdal.gdalJNI.SWIGDriverUpcast(Native Method)
      at org.gdal.gdal.Driver.<init>(Driver.java:18)
      at org.gdal.gdal.gdal.GetDriverByName(gdal.java:521)
      at it.geosolutions.imageio.gdalframework.GDALUtilities.isDriverAvailable(GDALUtilities.java:355)
      at it.geosolutions.imageio.gdalframework.GDALImageReaderSpi.isAvailable(GDALImageReaderSpi.java:257)
      at org.geotools.coverageio.gdal.aig.AIGFormatFactory.isAvailable(AIGFormatFactory.java:61)
      at org.geotools.coverageio.gdal.GDALTestCase.testingEnabled(GDALTestCase.java:105)
      at org.geotools.coverageio.gdal.GDALTestCase.setUp(GDALTestCase.java:88){format}

      See: https://jira.codehaus.org/browse/GEOT-4104

      Proposed fix:

      GDALUtilities.isDriverAvailable should catch UnsatisfiedLinkError thrown by gdal.GetDriverByName and return false in this case. It might be useful to log a warning like those in isGDALAvailable to aid debugging.

      See also this discussion: http://java.net/projects/imageio-ext/lists/dev/archive/2010-08/message/0

        Activity

        Hide
        bencaradocdavies added a comment -

        -------- Original Message --------
        Subject: Re: Updated Jars to be tested
        Date: Tue, 17 Apr 2012 17:29:14 +0800
        From: Ben Caradoc-Davies
        To: Daniele Romagnoli

        Thanks, Daniele. I can confirm that this jar resolved my issue.

        I replaced my local maven repo imageio-ext-gdalframework-1.1.3.jar with
        the JAR file you provided. I then ran the GeoTools imageio-ext-gdal
        tests with "mvn -o test" and they passed.

        Log messages make sense and look like this example:

        17-Apr-2012 17:16:54 it.geosolutions.imageio.gdalframework.GDALUtilities
        isDriverAvailable
        WARNING: Failed to get the specified GDAL Driver:
        EHdrjava.lang.UnsatisfiedLinkError:
        org.gdal.gdal.gdalJNI.SWIGDriverUpcast(J)J
        This is not a problem unless you need to use the specified GDAL plugin.
        It won't be enabled

        My only suggestion would be to insert a separator ": Cause: " so

        "EHdrjava.lang.UnsatisfiedLinkError"

        becomes something like

        "EHdr: Cause: java.lang.UnsatisfiedLinkError"

        to aid googling and to make clearer which driver was requested.

        Kind regards,
        Ben.

        On 17/04/12 16:59, Daniele Romagnoli wrote:
        > Hi Ben,
        > I'm working on the ISSUE à#40 you have created.
        > Could you try whether the provided jar works properly for the issue you have reported.
        > In case it sounds good (and the logged message is clear) I will commit the changes on SVN.
        >
        > Please, let me know.
        > Regards,
        > Daniele
        >
        > –
        > -------------------------------------------------------
        > Ing. Daniele Romagnoli
        > GeoSolutions S.A.S.
        > Software Engineer

        Show
        bencaradocdavies added a comment - -------- Original Message -------- Subject: Re: Updated Jars to be tested Date: Tue, 17 Apr 2012 17:29:14 +0800 From: Ben Caradoc-Davies To: Daniele Romagnoli Thanks, Daniele. I can confirm that this jar resolved my issue. I replaced my local maven repo imageio-ext-gdalframework-1.1.3.jar with the JAR file you provided. I then ran the GeoTools imageio-ext-gdal tests with "mvn -o test" and they passed. Log messages make sense and look like this example: 17-Apr-2012 17:16:54 it.geosolutions.imageio.gdalframework.GDALUtilities isDriverAvailable WARNING: Failed to get the specified GDAL Driver: EHdrjava.lang.UnsatisfiedLinkError: org.gdal.gdal.gdalJNI.SWIGDriverUpcast(J)J This is not a problem unless you need to use the specified GDAL plugin. It won't be enabled My only suggestion would be to insert a separator ": Cause: " so "EHdrjava.lang.UnsatisfiedLinkError" becomes something like "EHdr: Cause: java.lang.UnsatisfiedLinkError" to aid googling and to make clearer which driver was requested. Kind regards, Ben. On 17/04/12 16:59, Daniele Romagnoli wrote: > Hi Ben, > I'm working on the ISSUE à#40 you have created. > Could you try whether the provided jar works properly for the issue you have reported. > In case it sounds good (and the logged message is clear) I will commit the changes on SVN. > > Please, let me know. > Regards, > Daniele > > – > ------------------------------------------------------- > Ing. Daniele Romagnoli > GeoSolutions S.A.S. > Software Engineer
        Hide
        dany111 added a comment -

        Hi Ben,
        thanks for the feedback.

        I'll reformat a bit the warning message as per your suggestion adding the separator (and probably a \n too.
        (I was unable to test it so I didn't notice the "merged" text DriverError)

        Thanks,
        Daniele

        Show
        dany111 added a comment - Hi Ben, thanks for the feedback. I'll reformat a bit the warning message as per your suggestion adding the separator (and probably a \n too. (I was unable to test it so I didn't notice the "merged" text DriverError) Thanks, Daniele
        Hide
        bencaradocdavies added a comment -

        Thanks, it is hard to replicate a broken environment quite like mine.

        Show
        bencaradocdavies added a comment - Thanks, it is hard to replicate a broken environment quite like mine.
        Hide
        bencaradocdavies added a comment -

        Attached imageio-ext-gdalframework-1.1-SNAPSHOT.jar supplied by Daniele. This jar fixed my GeoTools build failure when I used it to replace imageio-ext-gdalframework-1.1.3.jar in my local maven repo. I have attached it here in case anyone else needs it before 1.1.4 is released.

        Show
        bencaradocdavies added a comment - Attached imageio-ext-gdalframework-1.1-SNAPSHOT.jar supplied by Daniele. This jar fixed my GeoTools build failure when I used it to replace imageio-ext-gdalframework-1.1.3.jar in my local maven repo. I have attached it here in case anyone else needs it before 1.1.4 is released.

          People

          • Assignee:
            dany111
            Reporter:
            bencaradocdavies
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: