まず第一に、私はネイティブ スピーカーではありません。
GeoTools のヘルプを探しています。学校のプロジェクトで使用していますが、今までほとんど問題はありませんでした。
しかし、プロジェクトが完了したので、GeoTools の FAQ に示されているように、Maven のシェード プラグインを使用して実行可能な jar を構築しようとしました。
「mvn package」と入力したときに作成されたjarを使用しようとすると、次のエラーが発生します。
java.lang.UnsupportedOperationException: Trying to get a reader from an unknown format. at org.geotools.coverage.grid.io.UnknownFormat.getReader(UnknownFormat.j ava:62) at coeurDLL.SMap.<init>(SMap.java:44) at coeurDLL.CoeurController.initialize(CoeurController.java:103) at coeur.Interface.getMapsAndDisplay(Interface.java:152) at coeur.Interface.<init>(Interface.java:948) at coeur.Interface.main(Interface.java:957) java.lang.NullPointerException at coeurDLL.CoeurController.getColumnsFields(CoeurController.java:225) at coeur.Interface.setControlPanel(Interface.java:327) at coeur.Interface.displayMainWindow(Interface.java:185) at coeur.Interface.getMapsAndDisplay(Interface.java:162) at coeur.Interface.<init>(Interface.java:948) at coeur.Interface.main(Interface.java:957)
「reader.read(null)」メソッドで GeoTif ファイルを読み込もうとすると発生します。もちろん、Eclipse でプロジェクトを実行する場合、この問題はありません。
依存関係の問題である可能性があることをどこかで読みましたが、見逃した可能性があるものはわかりません。
役立つ詳細情報: - GeoTools バージョン 12-RC1 を使用しています - JAI ライブラリは使用していません。Java Pure モードで作業しています。これにより、64 ビットの jdk で作業できます。32ビットのjdkで好奇心から試してみましたが、とにかく同じ問題があります。- Windows 7 で作業していますが、違いはありません。
これが私の pom.xml の内容です:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pfe.coeur</groupId>
<artifactId>coeur</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tuto</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>12-RC1</geotools.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<target>1.8</target>
<source>1.8</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</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>coeur.Interface</Main-Class>
</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>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-coverage</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-render</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geotiff</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-image</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-wms</artifactId>
<version>${geotools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>osgeo</id>
<name>Open Source Geospatial Foundation Repository</name>
<url>http://download.osgeo.org/webdav/geotools/</url>
</repository>
</repositories>
</project>
依存関係から gt:geotiff を削除すると、Eclipse でも同じエラーが発生します。しかし、jar にはこの依存関係が含まれています。
誰かがこの問題を解決するのを手伝ってくれたら、とても感謝しています。プロジェクトを完了するには、この実行可能 jar が必要ですが、取得する時間があまりありません。
よろしく、