我在Apache Storm中运行Geotools,并且在geotools依赖管理方面有一段时间。当我在本地运行风暴集群(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插件构建超级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>
答案 0 :(得分:12)
Geotools使用Java的服务基础架构来加载负责EPSG查找的类。原始gt-epsg-hsql.jar
在/META-INF/services/
中有条目,指定哪些接口由jar文件实现,哪些接口可以在运行时动态加载。
构建超级jar时,将多个jar文件合并为一个。最有可能的是,另一个jar文件也实现了相同的接口(例如gt-referencing.jar
),因此在/META-INF/services/
中具有相同名称的文件。将所有内容放入一个jar文件时,这些条目很可能会被覆盖(至少我找不到maven-shade-plugin合并这些服务文件的任何引用)。
您可以通过查看创建的uber-jar中的services-directory来验证,尤其是在条目/META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory
。 gt-epsg-hsql.jar
和gt-referencing.jar
都有这样的文件(以及其他来自GeoTools的jar文件),而且最有可能的是,只有一个文件的内容会出现在你的uber-jar中,导致所有在运行时没有找到/加载其他类。
我对maven-shade-plugin并不熟悉,但SO上的其他问题(如[1])建议使用额外的变换器:
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
[1] Maven shade + resteasy Could find writer for content-type
答案 1 :(得分:4)
我也遇到了这个问题。您可以使用从WKT创建CRS而不是使用for i in *.csv; do grep -Eo "S\/N\: [0-9]+" "$i" | cut -c 6- | head -1 | xargs mv "$i" ; done
的解决方法,而不是将您的头撞到墙上;
decode
一个提示是,如果使用此方法,生成的CRS将首先将经度存储在WKT中,然后是纬度。使用ServicesResourceTransformer为WKT提供纬度后跟经度。有关此问题的更多信息,请访问此链接http://docs.geotools.org/latest/userguide/library/referencing/order.html
答案 2 :(得分:3)
GeoTools使用基于工厂的插件系统来提供多个引用数据库,但您必须选择其中一个。 gt-referencing提供接口和工厂。实际权限在EPSG plugins(仅选择一个以防止冲突):
答案 3 :(得分:1)
对于hsql db的其他问题,您可以启用geotools的调试日志记录。
Geotools使用默认的Java日志记录。将以下条目添加到logging.properties
配置文件中。
org.geotools.level = FINEST
org.geotools.handlers = java.util.logging.ConsoleHandler
此文件通常位于%JAVA_HOME%或由显式设置
-Djava.util.logging.config.file=logging.properties
运行时参数
答案 4 :(得分:0)
当使用不使用geotools的Maven依赖项(Matsim)时,我遇到了这个问题,而我没有在项目中直接使用geotools。我正在使用maven-shade-plugin构建一个“胖”罐。
解决方案只是在阴影插件配置中添加一个转换器(如大提琴在其答案的底部所述)。
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />