【问题标题】:Maven package errorMaven包错误
【发布时间】:2018-04-30 15:40:24
【问题描述】:

我正在开发一个需要 geotools 依赖项的项目。在我收到以下错误之前:

Exception in thread "main" java.lang.IllegalStateException: cannot initilize transformation: Authority "EPSG" is unknown or doesn't match the supplied hints. Maybe it is defined in an unreachable JAR file?
        at com.test.geometricutils.TransformProjection.initializeTransformer(TransformProjection.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:879)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:197)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:227)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:136)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: org.opengis.referencing.NoSuchAuthorityCodeException: Authority "EPSG" is unknown or doesn't match the supplied hints. Maybe it is defined in an unreachable JAR file?
        at org.geotools.referencing.factory.ManyAuthoritiesFactory.noSuchAuthority(ManyAuthoritiesFactory.java:488)
        at org.geotools.referencing.factory.ManyAuthoritiesFactory.getAuthorityFactory(ManyAuthoritiesFactory.java:466)
        at org.geotools.referencing.factory.ManyAuthoritiesFactory.getCRSAuthorityFactory(ManyAuthoritiesFactory.java:547)
        at org.geotools.referencing.factory.AuthorityFactoryAdapter.createCoordinateReferenceSystem(AuthorityFactoryAdapter.java:799)
        at org.geotools.referencing.factory.ThreadedAuthorityFactory.createCoordinateReferenceSystem(ThreadedAuthorityFactory.java:730)
        at org.geotools.referencing.DefaultAuthorityFactory.createCoordinateReferenceSystem(DefaultAuthorityFactory.java:179)
        at org.geotools.referencing.CRS.decode(CRS.java:488)
        at org.geotools.referencing.CRS.decode(CRS.java:416)
        at 

通过以下依赖解决:

 <dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>2.11.0</version>
 </dependency>

项目构建成功,没有任何错误。现在,我正在尝试使用以下命令将我的项目打包到一个 jar 中:

mvn 组装:组装 -DdescriptorId=jar-with-dependencies

但我再次收到相同的错误消息。我不知道为什么它在 intellij 作为项目运行,但在运行 package 命令之后却没有。

任何帮助或提示将不胜感激。

【问题讨论】:

  • 你在 mvn assembly:assembly -DdescriptorId=jar-with-dependencies 之前尝试过 mvn clean 吗?为什么你使用这个特定的目标而不是 mvn 包?
  • 是的,我在这个命令之前使用 mvn clean。我想要用于 spark-submit 的 scala 项目的可执行 jar,这就是我使用这个命令的原因。

标签: java scala maven apache-spark geotools


【解决方案1】:

首先,您需要一个 EPSG 工厂(而不是 xerces)来解决您的第一个问题 - 请参阅 GeoTools FAQ 了解更多详细信息。

其次,在组装fat(或uber)jar时,需要特别注意GeoTools FAQ中描述的spi控制文件。

【讨论】:

    【解决方案2】:

    您可以在 maven 存储库中查看您的 geotools 版本。并且您应该确保所有 geotools 的版本都适用,尤其是 gt-epsg-hsql。

    【讨论】:

      猜你喜欢
      • 2013-02-19
      • 1970-01-01
      • 2012-09-06
      • 2016-10-24
      • 2012-09-10
      • 1970-01-01
      • 2018-09-27
      • 2017-08-30
      • 2019-01-21
      相关资源
      最近更新 更多