You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Geoserver 2.22.0编译报错:图像像素差异超出阈值

解决GeoServer 2.22.0编译时GetMapIntegrationTest像素差异测试失败问题

在Fedora系统执行mvn clean install编译GeoServer 2.22.0时,org.geoserver.wms.wms_1_1_1.GetMapIntegrationTest中的testNamedPlacesRenderingSelection测试失败,具体错误为图像像素差异(1469个)超出阈值(1300个),导致maven-surefire-plugin终止构建。完整错误信息如下:

Test set: org.geoserver.wms.wms_1_1_1.GetMapIntegrationTest
-------------------------------------------------------------------------------
Tests run: 87, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 3.72 s <<< FAILURE! - in org.geoserver.wms.wms_1_1_1.GetMapIntegrationTest
testNamedPlacesRenderingSelection(org.geoserver.wms.wms_1_1_1.GetMapIntegrationTest)  Time elapsed: 0.102 s  <<< FAILURE!
java.lang.AssertionError:
Images are visibly different, found 1469 different pixels, against a threshold of 1300
You can add -Dorg.geotools.image.test.interactive=true to show a dialog comparing them (requires GUI support)
        at org.geoserver.wms.wms_1_1_1.GetMapIntegrationTest.testNamedPlacesRenderingSelection(GetMapIntegrationTest.java:2333)



[ERROR] Failures:
[ERROR]   GetMapIntegrationTest.testNamedPlacesRenderingSelection:2333 Images are visibly different, found 1469 different pixels, against a threshold of 1300
You can add -Dorg.geotools.image.test.interactive=true to show a dialog comparing them (requires GUI support)
[INFO]
[ERROR] Tests run: 1392, Failures: 1, Errors: 0, Skipped: 6


[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project gs-wms: There are test failures.
[ERROR]
[ERROR] Please refer to /home/andlis/geoserver-2.22.0/src/wms/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :gs-wms

解决方法

  • 临时跳过该测试
    如果优先完成编译,可跳过单个失败测试:

    mvn clean install -Dtest=!GetMapIntegrationTest#testNamedPlacesRenderingSelection
    

    若需跳过所有测试(不推荐,可能遗漏其他问题):

    mvn clean install -DskipTests
    
  • 调整像素差异阈值
    定位到GetMapIntegrationTest.java第2333行附近的断言代码,将阈值从1300调高至能覆盖当前差异的数值(比如1500):

    // 原代码示例
    assertImageEquals(expectedImage, actualImage, 1300);
    // 修改后
    assertImageEquals(expectedImage, actualImage, 1500);
    

    修改后重新执行编译。

  • 可视化查看图像差异(需GUI环境)
    添加参数运行单个测试,打开图形对比界面查看具体差异:

    mvn test -Dtest=GetMapIntegrationTest#testNamedPlacesRenderingSelection -Dorg.geotools.image.test.interactive=true
    

    通过对比可判断差异是环境渲染差异还是代码问题导致。

  • 调整系统渲染配置
    Fedora的图形渲染库可能与测试预期环境不一致,尝试添加JVM参数强制软件渲染:

    mvn clean install -Djava.awt.headless=false -Dsun.java2d.opengl=false
    

    或检查并安装缺失的图形依赖包。

  • 确认JDK版本兼容性
    GeoServer 2.22.0推荐使用OpenJDK 11,确保Fedora系统使用的JDK版本符合要求,可通过update-alternatives切换到OpenJDK 11后重新编译。

内容的提问来源于stack exchange,提问作者Andrey Lissovsky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 21:45:31