栅格图层-Geotools:java.lang.NoClassDefFoundError:无法初始化类javax.imageio.ImageIO

时间:2019-04-03 11:59:51

标签: maven geotools

这是我在运行有关依赖项的mvn命令时返回的内容。正如我之前解释的主要问题是,当我尝试在IDE外部运行jar文件时,imageIO库无法正常工作。我想指出,所有其他功能均正常运行。您是否有解决此问题的想法?我也尝试按照此链接中的步骤操作:http://docs.geotools.org/latest/userguide/build/install/jdk.html,但我又遇到了相同的错误。

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gisLaraMaven gis
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.geotools:gt-wfs:jar:20.1 is missing, no dependency information available
[INFO]
[INFO] --- maven-dependency-plugin:2.1:list (default-cli) @ gis ---
[INFO]
[INFO] The following files have been resolved:
[INFO]    com.conversantmedia:disruptor:jar:1.2.13:compile
[INFO]    com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO]    com.google.errorprone:error_prone_annotations:jar:2.2.0:compile
[INFO]    com.google.guava:failureaccess:jar:1.0:compile
[INFO]    com.google.guava:guava:jar:27.0-jre:compile
[INFO]    com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO]    com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO]    com.miglayout:miglayout:jar:swing:3.7:compile
[INFO]    com.vividsolutions:jts:jar:1.13:compile
[INFO]    commons-codec:commons-codec:jar:1.2:compile
[INFO]    commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO]    commons-io:commons-io:jar:2.6:compile
[INFO]    commons-logging:commons-logging:jar:1.0.4:compile
[INFO]    commons-pool:commons-pool:jar:1.5.4:compile
[INFO]    hsqldb:hsqldb:jar:1.8.0.7:compile
[INFO]    it.geosolutions.imageio-ext:imageio-ext-geocore:jar:1.1.27:compile
[INFO]    it.geosolutions.imageio-ext:imageio-ext-streams:jar:1.1.27:compile
[INFO]    it.geosolutions.imageio-ext:imageio-ext-tiff:jar:1.1.27:compile
[INFO]    it.geosolutions.imageio-ext:imageio-ext-utilities:jar:1.1.27:compile
[INFO]    it.geosolutions.jaiext.affine:jt-affine:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.algebra:jt-algebra:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.bandcombine:jt-bandcombine:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.bandmerge:jt-bandmerge:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.bandselect:jt-bandselect:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.binarize:jt-binarize:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.border:jt-border:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.buffer:jt-buffer:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.classifier:jt-classifier:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.colorconvert:jt-colorconvert:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.colorindexer:jt-colorindexer:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.crop:jt-crop:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.errordiffusion:jt-errordiffusion:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.format:jt-format:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.imagefunction:jt-imagefunction:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.iterators:jt-iterators:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.lookup:jt-lookup:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.mosaic:jt-mosaic:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.nullop:jt-nullop:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.orderdither:jt-orderdither:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.piecewise:jt-piecewise:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.rescale:jt-rescale:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.rlookup:jt-rlookup:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.scale:jt-scale:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.scale2:jt-scale2:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.shadedrelief:jt-shadedrelief:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.stats:jt-stats:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.translate:jt-translate:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.utilities:jt-utilities:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.vectorbin:jt-vectorbin:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.warp:jt-warp:jar:1.1.3:compile
[INFO]    it.geosolutions.jaiext.zonal:jt-zonal:jar:1.1.3:compile
[INFO]    javax.measure:unit-api:jar:1.0:compile
[INFO]    javax.media:jai_codec:jar:1.1.3:compile
[INFO]    javax.media:jai_core:jar:1.1.3:compile
[INFO]    javax.media:jai_imageio:jar:1.1:compile
[INFO]    jgridshift:jgridshift:jar:1.0:compile
[INFO]    junit:junit:jar:3.8.1:test
[INFO]    net.sf.geographiclib:GeographicLib-Java:jar:1.49:compile
[INFO]    org.apache.xml:xml-commons-resolver:jar:1.2:compile
[INFO]    org.checkerframework:checker-qual:jar:2.5.2:compile
[INFO]    org.codehaus.mojo:animal-sniffer-annotations:jar:1.17:compile
[INFO]    org.ejml:ejml-core:jar:0.34:compile
[INFO]    org.ejml:ejml-ddense:jar:0.34:compile
[INFO]    org.geotools:gt-api:jar:20.1:compile
[INFO]    org.geotools:gt-coverage:jar:20.1:compile
[INFO]    org.geotools:gt-cql:jar:20.1:compile
[INFO]    org.geotools:gt-data:jar:20.1:compile
[INFO]    org.geotools:gt-epsg-hsql:jar:20.1:compile
[INFO]    org.geotools:gt-geotiff:jar:20.1:compile
[INFO]    org.geotools:gt-image:jar:20.1:compile
[INFO]    org.geotools:gt-main:jar:20.1:compile
[INFO]    org.geotools:gt-metadata:jar:20.1:compile
[INFO]    org.geotools:gt-opengis:jar:20.1:compile
[INFO]    org.geotools:gt-process:jar:20.1:compile
[INFO]    org.geotools:gt-referencing:jar:20.1:compile
[INFO]    org.geotools:gt-render:jar:20.1:compile
[INFO]    org.geotools:gt-shapefile:jar:20.1:compile
[INFO]    org.geotools:gt-swing:jar:20.1:compile
[INFO]    org.geotools:gt-wfs:jar:20.1:compile
[INFO]    org.geotools:gt-wms:jar:20.1:compile
[INFO]    org.geotools:gt-xml:jar:20.1:compile
[INFO]    org.hsqldb:hsqldb:jar:2.4.1:compile
[INFO]    org.jaitools:jt-utils:jar:1.5.0:compile
[INFO]    org.jaitools:jt-zonalstats:jar:1.5.0:compile
[INFO]    org.jdom:jdom2:jar:2.0.6:compile
[INFO]    org.locationtech.jts:jts-core:jar:1.16.0:compile
[INFO]    org.postgresql:postgresql:jar:9.4-1202-jdbc42:compile
[INFO]    org.slf4j:slf4j-api:jar:1.7.13:compile
[INFO]    si.uom:si-quantity:jar:0.7.1:compile
[INFO]    si.uom:si-units-java8:jar:0.7.1:compile
[INFO]    systems.uom:systems-common-java8:jar:0.7.2:compile
[INFO]    tec.uom:uom-se:jar:1.0.8:compile
[INFO]    tec.uom.lib:uom-lib-common:jar:1.0.2:compile
[INFO]    xerces:xercesImpl:jar:2.11.0:compile
[INFO]    xml-apis:xml-apis:jar:1.4.01:compile
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.701s
[INFO] Finished at: Wed Apr 03 18:37:35 EEST 2019
[INFO] Final Memory: 12M/243M
[INFO] ------------------------------------------------------------------------

这是pom.xml的一部分,它是maven阴影插件。

          <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</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>com.mycompany.gislaramaven.gisMap_3</Main-Class>
                                    </manifestEntries>
                                </transformer>
                                <!-- This bit merges the various
GeoTools META-INF/services files         -->
                                <transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                            </transformers>
                             <archive>
            <manifest>
                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
            <manifestEntries>
                <Specification-Vendor>Sun Microsystems, Inc</Specification-Vendor>
                <Implementation-Vendor>Sun Microsystems, Inc</Implementation-Vendor>
            </manifestEntries>
        </archive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

以下是我得到的新错误。似乎再次缺少与JAI库有关的内容。请看看:

    WARNING  The input argument(s) may not be null.
java.lang.IllegalArgumentException: The input argument(s) may not be null.
        at javax.media.jai.ParameterBlockJAI.getDefaultMode(ParameterBlockJAI.java:136)
        at javax.media.jai.ParameterBlockJAI.<init>(ParameterBlockJAI.java:157)
        at javax.media.jai.ParameterBlockJAI.<init>(ParameterBlockJAI.java:178)
        at it.geosolutions.jaiext.vectorbin.ROIGeometry.getAsImage(ROIGeometry.java:473)
        at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.addRoiIfMissing(GridCoverageRenderer.java:1095)
        at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.reproject(GridCoverageRenderer.java:509)
        at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:958)
        at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:1279)
        at org.geotools.renderer.lite.StreamingRenderer$RenderCoverageReaderRequest.execute(StreamingRenderer.java:3650)
        at org.geotools.renderer.lite.StreamingRenderer$PainterThread.run(StreamingRenderer.java:3744)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

2 个答案:

答案 0 :(得分:0)

您可能还没有构建胖罐

如果仅构建jar,则不包括依赖项,因此在IDE外部运行jar通常会导致类丢失。

您可以使用maven程序集插件或maven阴影插件来生成胖子。

答案 1 :(得分:0)

您需要使用以下方法将ImageIO添加到manifestEntries

          <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>com.ianturton.tileviewer.TileViewer</Main-Class>
                <Specification-Title> Java Advanced Imaging Image I/O Tools</Specification-Title>
                <Specification-Version>1.1</Specification-Version>          
                <Specification-Vendor> Sun Microsystems, Inc. </Specification-Vendor>
                <Implementation-Title> com.sun.media.imageio</Implementation-Title>
                <Implementation-Version> 1.1</Implementation-Version>       
                <Implementation-Vendor> Sun Microsystems, Inc.</Implementation-Vendor>
              </manifestEntries>                                            
            </transformer>                                                  
            <!-- This bit merges the various GeoTools META-INF/services files -->
            <transformer                                                    
              implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
          </transformers>