user3597555
user3597555

Reputation: 73

Maven package error

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.

Upvotes: 4

Views: 718

Answers (2)

physlaite
physlaite

Reputation: 11

You can check your geotools' version in maven repository. And you should ensure all geotools' version is suitable especially gt-epsg-hsql.

Upvotes: 1

Ian Turton
Ian Turton

Reputation: 10976

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.

Upvotes: 2

Related Questions