当前位置: 首页 > 面试题库 >

Geotools找不到HSQL EPSG DB,引发错误:NoSuchAuthorityCodeException

岑和风
2023-03-14
问题内容

我在Apache Storm内运行Geotools,并经常使用geotools依赖项管理。当我在本地运行Storm群集(Windows
7便携式计算机)时,一切正常,但是当我部署到群集时,在日志中会收到此异常。

编辑:这是我使用的Java,它调用了此功能

      GridCoverage2D image = 
new GeoTiffReader(f).read(new GeneralParameterValue[]{policy, gridsize, useJaiRead});
        /**
         * reproject to WGS84
         */
        CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
        GridCoverage2D reprojectedImage = (GridCoverage2D) Operations.DEFAULT.resample(image, targetCRS);

这是我的环境

geotools 11.1
java 7
POM is below
running on windows 7 when in local mode (works perfectly here)
this problem happens on Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-63-virtual x86_64)

here's the exception from the log


[ERROR] Exception in Bolt org.geotools.data.DataSourceException: GEOTIFF Module Error Report
No code "EPSG:32637" from authority "EPSG" found for object of type "EngineeringCRS".
ModelPixelScaleTag: [2.0,2.0,0.0]
ModelTiePointTag: (1 tie points)
TP #0: [0.0,0.0,0.0] -> [337668.0,3837288.0,0.0]
ModelTransformationTag: NOT AVAILABLE
GeoKey #1: Key = 2049, Value = GCS_WGS_1984
GeoKey #2: Key = 2054, Value = 9102
GeoKey #3: Key = 3072, Value = 32637
GeoKey #4: Key = 1024, Value = 1
GeoKey #5: Key = 1025, Value = 1
GeoKey #6: Key = 1026, Value = PCS Name = WGS_1984_UTM_zone_37N
GeoKey #7: Key = 3076, Value = 9001
org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:32637" from authority "EPSG" found for object of type "EngineeringCRS".
        at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.noSuchAuthorityException(CartesianAuthorityFactory.java:136)
        at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createEngineeringCRS(CartesianAuthorityFactory.java:130)
        at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createCoordinateReferenceSystem(CartesianAuthorityFactory.java:121)
        at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:802)
        at org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffMetadata2CRSAdapter.createProjectedCoordinateReferenceSystem(GeoTiffMetadata2CRSAdapter.java:284)
        at org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffMetadata2CRSAdapter.createCoordinateSystem(GeoTiffMetadata2CRSAdapter.java:205)
        at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:299)
        at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:211)
        at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:156)
        at dgi.eii.utils.PixelExtractor.extract(PixelExtractor.java:80)
        at dgi.eii.storm.bolts.RasterPixelExtractorBolt.execute(RasterPixelExtractorBolt.java:59)
        at backtype.storm.daemon.executor$fn__5641$tuple_action_fn__5643.invoke(executor.clj:631)
        at backtype.storm.daemon.executor$mk_task_receiver$fn__5564.invoke(executor.clj:399)
        at backtype.storm.disruptor$clojure_handler$reify__745.onEvent(disruptor.clj:58)
        at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:125)
        at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:99)
        at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:80)
        at backtype.storm.daemon.executor$fn__5641$fn__5653$fn__5700.invoke(executor.clj:746)
        at backtype.storm.util$async_loop$fn__457.invoke(util.clj:431)
        at clojure.lang.AFn.run(AFn.java:24)
        at java.lang.Thread.run(Thread.java:745)

当遇到带有EPSQ:4326的图像时,我也得到相同的错误

 [ERROR] Exception in Bolt org.geotools.data.DataSourceException: GEOTIFF Module Error Report
No code "EPSG:4326" from authority "EPSG" found for object of type "EngineeringCRS".
ModelPixelScaleTag: [2.0230196490091333E-5,2.0230196490071028E-5,0.0]
ModelTiePointTag: (1 tie points)
TP #0: [0.0,0.0,0.0] -> [36.8167576323252,34.429979601192464,0.0]
ModelTransformationTag: NOT AVAILABLE
GeoKey #1: Key = 2048, Value = 4326
GeoKey #2: Key = 2049, Value = GCS_WGS_1984
GeoKey #3: Key = 2054, Value = 9102
GeoKey #4: Key = 1024, Value = 2
GeoKey #5: Key = 2057, Value = 6378137.0
GeoKey #6: Key = 1025, Value = 1
GeoKey #7: Key = 2059, Value = 298.257223563
org.opengis.referencing.NoSuchAuthorityCodeException: No code "EPSG:4326" from authority "EPSG" found for object of type "EngineeringCRS".
        at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.noSuchAuthorityException(CartesianAuthorityFactory.java:136)
        at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createEngineeringCRS(CartesianAuthorityFactory.java:130)
        at org.geotools.referencing.factory.epsg.CartesianAuthorityFactory.createCoordinateReferenceSystem(CartesianAuthorityFactory.java:121)
        at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:802)
        at org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffMetadata2CRSAdapter.createGeographicCoordinateReferenceSystem(GeoTiffMetadata2CRSAdapter.java:389)
        at org.geotools.coverage.grid.io.imageio.geotiff.GeoTiffMetadata2CRSAdapter.createCoordinateSystem(GeoTiffMetadata2CRSAdapter.java:208)
        at org.geotools.gce.geotiff.GeoTiffReader.getHRInfo(GeoTiffReader.java:299)
        at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:211)
        at org.geotools.gce.geotiff.GeoTiffReader.<init>(GeoTiffReader.java:156)
        at dgi.eii.utils.PixelExtractor.extract(PixelExtractor.java:80)
        at dgi.eii.storm.bolts.RasterPixelExtractorBolt.execute(RasterPixelExtractorBolt.java:59)
        at backtype.storm.daemon.executor$fn__5641$tuple_action_fn__5643.invoke(executor.clj:631)
        at backtype.storm.daemon.executor$mk_task_receiver$fn__5564.invoke(executor.clj:399)
        at backtype.storm.disruptor$clojure_handler$reify__745.onEvent(disruptor.clj:58)
        at backtype.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:125)
        at backtype.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:99)
        at backtype.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:80)
        at backtype.storm.daemon.executor$fn__5641$fn__5653$fn__5700.invoke(executor.clj:746)
        at backtype.storm.util$async_loop$fn__457.invoke(util.clj:431)
        at clojure.lang.AFn.run(AFn.java:24)
        at java.lang.Thread.run(Thread.java:745)

我已经看到了几个答案,表明我需要将gt-epsg-hsql放入pom中,但是我仍然找不到所需的内容。

这是我的geotools POM条目

 <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-swing</artifactId>
            <version>11.1</version>        
        </dependency>
         <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-opengis</artifactId>
            <version>11.1</version>        
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-epsg-hsql</artifactId>
            <version>11.1</version>                 
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-geotiff</artifactId>
            <version>11.1</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-image</artifactId>
            <version>11.1</version>
        </dependency>
        <dependency>
            <groupId>org.geotools</groupId>
            <artifactId>gt-wms</artifactId>
            <version>11.1</version>
        </dependency>

这是我如何使用Maven Shade插件构建uber-jar

 <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                    <!--  <minimizeJar>true</minimizeJar>-->
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <shadedClassifierName>stand-alone</shadedClassifierName>
                    <artifactSet>
                        <excludes>                 
                            <exclude>org.slf4j:slf4j-api:jar:</exclude>
                            <exclude>org.slf4j:slf4j-simple:jar:1.6.4:jar:</exclude>
                            <exclude>org.slf4j:slf4j-log4j12:jar:</exclude>
                            <exclude>org.slf4j:jcl-over-slf4j:jar:</exclude>
                            <exclude>org.slf4j:slf4j-api:jar:1.7.5:jar:</exclude>
                            <!-- <exclude>org.slf4j*:</exclude>-->
                            <exclude>commons-logging:commons-logging:jar:</exclude>
                            <exclude>commons-logging:commons-logging-api:jar:</exclude>
                        </excludes>
                    </artifactSet>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                    <finalName>storm-topos</finalName>
                    <transformers>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>dgi.eii.storm.base.StormTopologyRunner</mainClass>
                        </transformer>
                       <!-- <transformer
                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                            <resource>META-INF/spring.handlers</resource>
                        </transformer>
                        <transformer
                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                            <resource>META-INF/spring.schemas</resource>
                        </transformer>-->
                    </transformers>
                </configuration>
            </plugin>
        </plugins>
    </build>

编辑:所以我想通了一些东西,并进一步…现在得到此错误

[ERROR] Exception in Bolt org.geotools.data.DataSourceException: org.hsqldb.DatabaseURL.parseURL(Ljava/lang/String;ZZ)Lorg/hsqldb/persist/HsqlProperties;

导致上述新错误的轻微改进是由于使用了正确的转换器,并且使用了maven
jar插件将正确的条目注入MANIFEST.MF文件。这是我的POM的新构建部分,它可以帮助某人至少克服geotools的META-INF /
services文件的合并并注入正确的条目以克服旧的vendorname cannot be null!错误

<build>
    <resources>
        <resource>
            <directory>${basedir}/src/main/resources</directory>
            <filtering>false</filtering>
            <includes>
                <include>schema.xsd</include>
            </includes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>stand-alone</shadedClassifierName>
                <artifactSet>
                    <excludes>
                        <exclude>org.slf4j:slf4j-api:jar:</exclude>
                        <exclude>org.slf4j:slf4j-log4j12:jar:</exclude>
                        <exclude>org.slf4j:jcl-over-slf4j:jar:</exclude>

                        <exclude>commons-logging:commons-logging:jar:</exclude>
                        <exclude>commons-logging:commons-logging-api:jar:</exclude>
                    </excludes>
                </artifactSet>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
                <finalName>insightcloud-storm-topos</finalName>
                <transformers>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>dgi.eii.storm.base.StormTopologyRunner</mainClass>
                    </transformer>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.handlers</resource>
                    </transformer>
                    <transformer
                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                        <resource>META-INF/spring.schemas</resource>
                    </transformer>
                </transformers>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                </archive>
            </configuration>
        </plugin>
    </plugins>

</build>

问题答案:

Geotools使用Java的Service基础结构来加载负责EPSG查找的类。原始的gt-epsg-hsql.jar条目中/META- INF/services/指定了jar文件实现哪些接口,以及哪些接口可以在运行时动态加载。

构建uber-jar时,将多个jar文件合并为一个。最有可能的是,另一个jar文件也实现了相同的接口(例如gt- referencing.jar),因此文件中具有相同的名称/META- INF/services/。当将所有内容放入一个jar文件时,这些条目很可能会被覆盖(至少我找不到maven-shade-
plugin合并此类服务文件的任何引用)。

您可以通过查看创建的uber-jar中的services-directory来验证这一点,尤其是在entry处/META- INF/services/org.opengis.referencing.crs.CRSAuthorityFactory。双方gt-epsg- hsql.jargt- referencing.jar有(从GeoTools可能也和其他jar文件)这样的文件,以及最有可能的,只有一个的内容会在你的尤伯杯罐子,导致所有其他类没有被发现/在运行时加载。

我对maven-shade-plugin并不是很熟悉,但是关于SO的其他问题(例如[1])建议使用其他转换器:

<transformer
   implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />

编辑: 由于此答案会定期访问,并且我现在已经熟悉了阴影插件,因此这里是使用阴影插件的更详细的指南。

因此,我们可以使用maven-shade插件来创建一个多合一的jar,而不是使用maven-assembly插件。为此,请在室内配置maven-
shade插件pom.xml并将其绑定到包阶段(因此,每当您调用时mvn package,都会创建阴影罐子:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>3.1.0</version>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
          <configuration>
            <transformers>
              <!-- This bit sets the main class for the executable jar as you otherwise -->
              <!-- would with the assembly plugin                                       -->
              <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                <manifestEntries>
                  <Main-Class>com.example.YourMainClass</Main-Class>
                  <Implementation-Vendor>Your Company Name</Implementation-Vendor>
                  <Implementation-Version>${project.version}</Implementation-Version>
                </manifestEntries>
              </transformer>
              <!-- This bit merges the various GeoTools META-INF/services files         -->
              <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
            </transformers>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

并不一定在所有情况下都需要使用Implementation-VendorImplementation- Version,但是我观察到以下情况:缺少此信息时,某些代码(我认为是JAI-
Java高级映像)会抱怨并且行为不当,这可能是因为原始JAR包含了此类信息,而阴影部分并未默认值,因此最好将其包括在内。

运行时mvn package,它将原始jar文件重命名为original-myArtifact.jar,并将阴影(= all-in-one,fat-
jar,uber-
jar)放在myArtifact.jar。如果您不喜欢这种行为,并且想要保持原始的jar文件完整并保留阴影的jar文件,请在代码configuration块中添加以下行:

<shadedArtifactAttached>true</shadedArtifactAttached>

在这种情况下,构建过程将创建一个文件myArtifact-shaded.jar(类似于myArtifact-jar-with- dependencies.jar程序集插件创建的文件)。



 类似资料:
  • 问题内容: 我试图通过使用elastic4s API 索引一些数据以进行elasticsearch 但是我正在编译错误 这是代码,稍后我将js对象字段映射到elasticsearch字段, 但是现在我只想索引一个测试用例 这是SBT文件 这是完全错误 我在安装过程中错过了什么吗? 还是其他? 谢谢miki 问题答案: 您的问题是缺少导入。作为链接状态的文档, 您还需要以下内容: 该模块是elast

  • 我不能安装任何需要的包。错误消息如下所示 我还尝试了包,得到了完全相同的结果。 路径: Make:GNU Make 3.81安装在中(来自官方的Debian包) 分册:Debian 6.0.8 ARCH:AMD64 构建-基本包:已安装 节点:从源手工构建 安装非GYP软件包:正常工作

  • 我得到以下错误。有人帮我出去吗。 Axis2.AxisFault:未找到的操作的endpoint引用(EPR)是/services/echo,WSA操作=null。如果此EPR以前是可访问的,请与服务器管理员联系。在org.apache.axis2.engine.dispatchPhase.checkPostConditions(dispatchPhase.java:102),在org.apach

  • 问题内容: 我有一个由Eclipse生成的.jar,我无法在其他计算机(与Windows XP)上运行。出现“找不到主类。程序将退出”消息。那台计算机可以在Netbeans生成的另一个.jar上正常运行,所以我想JRE并不是问题。我更新了JRE,但没有改变。问题是什么? 更新:我忘了提,我做了一个可运行的jar文件。在另外两台计算机上,它可以正常工作(win 7和XP),但在特定计算机上则不能。

  • 问题内容: 所有, 我的类路径已设置为以下文件夹: 我所有的Java文件和类文件都在中列出的文件夹下。 但是在运行in 文件夹时出现以下错误: 谁能帮我理解这里的原因? 问题答案: 您在包装内。您应该坐在包根目录中。上一个文件夹。 然后使用重新执行它。 就是说,您不应该使用环境变量。您的当前也是无效的。未加引号的路径名中有空格。另外,该文件夹不应放在类路径中。只需使用like这样的参数(坐在包根文

  • 问题内容: 我试图安装Python软件包: 但是我收到了一个神秘的错误消息: 如果我尝试手动安装软件包,也会发生相同的情况: 问题答案: 对于Windows安装: 在运行进行软件包安装时,Python 2.7搜索已安装的Visual Studio2008。你可以通过在调用之前在环境变量中设置正确的路径来欺骗Python使用更新的。 根据安装的Visual Studio版本执行以下命令: Visua