最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Geotools OGR plugin - UnsatisfiedLinkError (ogrjni or gdalalljni) - Stack Overflow

programmeradmin1浏览0评论

I'm working with Geotools but I am unable to correctly setup gdal for the OGR plugin. According to the vague documentation for the OGR Plugin, I need to use GDAL 3.2 or older.

I am using binaries from Gisinternals and when using version 2.2.3, I get a an UnsatisfiedLinkError for 'gdalalljni'. And it is missing from version 2.2.3. However, when I instead use version 3.1.4, I get an UnsatisfiedLinkError for 'ogrjni', which correctly is missing from that version. It seems like version 2.2.3 is missing the 'gdalalljni.dll', which in later versions was added but then removed the 'ogrjni.dll' instead.

Here's an example of a stacktrace from using 3.1.4:

Native library load failed.
java.lang.UnsatisfiedLinkError: no ogrjni in java.library.path: [C:\Program Files\Java\jdk-11\bin, C:\WINDOWS\Sun\Java\bin, C:\WINDOWS\system32, C:\WINDOWS, C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin, C:\Program Files (x86)\Common Files\Oracle\Java\javapath, C:\WINDOWS\system32, C:\WINDOWS, C:\WINDOWS\System32\Wbem, C:\WINDOWS\System32\WindowsPowerShell\v1.0\, C:\WINDOWS\System32\OpenSSH\, C:\Program Files\dotnet\, C:\Program Files\nodejs\, C:\Program Files\Microsoft SQL Server\150\Tools\Binn\, C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\, C:\Program Files\PowerShell\7\, C:\Program Files\PuTTY\, C:\Program Files\RedHat\Podman\, C:\gdal-314\bin\gdal\java, C:\gdal-314\bin, C:\gdal-314\bin\gdal\apps, C:\aliases, C:\Users\sehe\AppData\Local\Programs\Git\cmd, C:\Users\sehe\AppData\Local\Programs\oh-my-posh\bin, C:\Users\sehe\AppData\Roaming\pypoetry\venv\Scripts, C:\Users\sehe\AppData\Local\Programs\Microsoft VS Code\bin, C:\Users\sehe\AppData\Roaming\npm, C:\Program Files\Azure Data Studio\bin, C:\Users\sehe\AppData\Local\Microsoft\WindowsApps, C:\Users\sehe\AppData\Local\Programs\EmEditor, C:\Users\sehe\AppData\Local\Pandoc\, C:\Users\sehe\AppData\Local\Programs\Gpg4win\..\GnuPG\bin, C:\Users\sehe\AppData\Roaming\Programs\Zero Install, C:\Users\sehe\.dotnet\tools, C:\grails-4.1.4\bin, ., .]
Caught: java.lang.UnsatisfiedLinkError: .gdal.ogr.ogrJNI.GetDriverCount()I
java.lang.UnsatisfiedLinkError: .gdal.ogr.ogrJNI.GetDriverCount()I
    at .gdal.ogr.ogrJNI.GetDriverCount(Native Method)
    at .gdal.ogr.ogr.GetDriverCount(ogr.java:114)
    at .geotools.data.ogr.jni.JniOGR.<clinit>(JniOGR.java:88)
    at .geotools.data.ogr.jni.JniOGRDataStoreFactory.createOGR(JniOGRDataStoreFactory.java:32)
    at .geotools.data.ogr.OGRDataStoreFactory.getAvailableDrivers(OGRDataStoreFactory.java:285)
    at GeotoolsTest.run(GeotoolsTest.groovy:12)

This is the sample code that is failing (Groovy):

import .geotools.data.ogr.OGRDataStoreFactory
import .geotools.data.ogr.jni.JniOGRDataStoreFactory

OGRDataStoreFactory factory = new JniOGRDataStoreFactory()
for (String driver : factory.getAvailableDrivers()) {
    System.out.println(driver);
}

And here is my buildfile:

plugins {
    id 'groovy'
}

group '.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
    maven { url "/" }
    maven { url "/" }
}

dependencies {
    implementation '.apache.groovy:groovy-all:4.0.14'

    implementation group: '.geotools', name: 'gt-main', version: '32.1'
    implementation group: '.geotools', name: 'gt-ogr-core', version: '32.1'
    implementation group: '.geotools', name: 'gt-ogr-jni', version: '32.1'
}

test {
    useJUnitPlatform()
}

configurations.all {

    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'javax.media') {
            if (details.requested.name == 'jai_core') {
                details.useTarget group: 'javax.media', name: 'jai-core', version: details.requested.version
            }
        }
    }
}

I have googled this error for hours, and all sources keep telling me to check my PATH, which I am quite sure is setup correctly. And either way, the problem is the missing DLLs from the binaries. But just to be sure, here are my environment variables:

GDAL_SDK_ROOT = C:\gdal-314 GDAL_DATA = %GDAL_SDK_ROOT%\bin\gdal-data

PATH = %GDAL_SDK_ROOT%\bin\gdal\java;%GDAL_SDK_ROOT%\bin;%GDAL_SDK_ROOT%\bin\gdal\apps

Thankful for any help!

发布评论

评论列表(0)

  1. 暂无评论
ok 不同模板 switch ($forum['model']) { /*case '0': include _include(APP_PATH . 'view/htm/read.htm'); break;*/ default: include _include(theme_load('read', $fid)); break; } } break; case '10': // 主题外链 / thread external link http_location(htmlspecialchars_decode(trim($thread['description']))); break; case '11': // 单页 / single page $attachlist = array(); $imagelist = array(); $thread['filelist'] = array(); $threadlist = NULL; $thread['files'] > 0 and list($attachlist, $imagelist, $thread['filelist']) = well_attach_find_by_tid($tid); $data = data_read_cache($tid); empty($data) and message(-1, lang('data_malformation')); $tidlist = $forum['threads'] ? page_find_by_fid($fid, $page, $pagesize) : NULL; if ($tidlist) { $tidarr = arrlist_values($tidlist, 'tid'); $threadlist = well_thread_find($tidarr, $pagesize); // 按之前tidlist排序 $threadlist = array2_sort_key($threadlist, $tidlist, 'tid'); } $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); $access = array('allowpost' => $allowpost, 'allowupdate' => $allowupdate, 'allowdelete' => $allowdelete); $header['title'] = $thread['subject']; $header['mobile_link'] = $thread['url']; $header['keywords'] = $thread['keyword'] ? $thread['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>