问题
I am working on a project which requires a geotools dependency. Before I was getting the following error:
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
which was solved by the following dependency:
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
And the project build successfully without any error. Now, I am trying to package my project into a jar using this command:
mvn assembly:assembly -DdescriptorId=jar-with-dependencies
But I am getting the same error message again. I don't know why it is running in intellij as a project, but not after running the package command.
Any help or hint would be appreciated.
回答1:
First, you need one of the EPSG factories (rather than xerces) to fix your first issue - see the GeoTools FAQ for more detail.
Secondly, when assembling a fat (or uber) jar you need to pay special attention to the spi control files as described in the GeoTools FAQ.
回答2:
You can check your geotools' version in maven repository. And you should ensure all geotools' version is suitable especially gt-epsg-hsql.
来源:https://stackoverflow.com/questions/50103830/maven-package-error