为什么GeoTools找不到MutablePicoContainer#registerComponentImplementation方法?

时间:2018-02-15 12:55:21

标签: java xsd kml geotools

我刚刚开始使用GeoTools并尝试生成KML。我按照我的应用程序的两个主要示例,但我看到这个奇怪的错误,其中gt-xsd-core无法从 MutablePicoContainer 类中找到此方法 registerComponentImplementation

  

java.lang.NoSuchMethodError:org.picocontainer.MutablePicoContainer.registerComponentImplementation(Ljava / lang / Object; Ljava / lang / Class;)Lorg / picocontainer / ComponentAdapter;在org.geotools.xs.XSConfiguration.registerBindings(XSConfiguration.java:130)〜[gt-xsd-core-16.1.jar:na]       在org.geotools.xml.Configuration.setupBindings(Configuration.java:528)~ [gt-xsd-core-16.1.jar:na]       在org.geotools.xml.Encoder。(Encoder.java:230)〜[gt-xsd-core-16.1.jar:na]       在org.geotools.xml.Encoder。(Encoder.java:214)〜[gt-xsd-core-16.1.jar:na]

我对Geo Tools的所有导入都运行相同的版本,我尝试过版本18.2,18.1,17.4和16.1。

    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-shapefile</artifactId>
        <version>${geo.tools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools.xsd</groupId>
        <artifactId>gt-xsd-kml</artifactId>
        <version>${geo.tools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-metadata</artifactId>
        <version>${geo.tools.version}</version>
    </dependency>
        <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-epsg-hsql</artifactId>
        <version>${geo.tools.version}</version>
    </dependency>
 import org.geotools.data.DataUtilities;
 import org.geotools.data.simple.SimpleFeatureCollection;
 import org.geotools.feature.simple.SimpleFeatureBuilder;
 import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
 import org.geotools.kml.KMLConfiguration;
 import org.geotools.xml.Encoder;

    SimpleFeatureCollection featureCollection = DataUtilities.collection(features);
    Encoder encoder = new Encoder(new KMLConfiguration()); // Error Line
    encoder.setIndenting(true);

    try {
        encoder.encode(featureCollection, org.geotools.kml.KML.kml, System.err);

我没有编译或启动错误。我的其他RESTful服务工作正常。 Mvn clean install成功通过。我已经尝试将Pico Container(1.2)依赖项添加到我的pom.xml中,但这也无效。

我正在查看MutablePicoContainer类的文档,我没有看到GeoTools正在使用的方法,即使我可以看到他们的代码正在使用引用进行编译。

PicoContainer JavaDoc:http://picocontainer.com/javadoc/core/org/picocontainer/MutablePicoContainer.html

GeoTools XSConfiguration(18.x)来源:https://github.com/geotools/geotools/blob/18.x/modules/extension/xsd/xsd-core/src/main/java/org/geotools/xs/XSConfiguration.java

GeoTools示例:http://docs.geotools.org/latest/userguide/extension/xsd/kml.html

OSGEO示例:http://svn.osgeo.org/geotools/tags/2.7.5/demo/example/src/main/java/org/geotools/demo/xml/KMLExample.java

请帮助这花费了我很多时间调试,而且我对它可能是什么没有想法。

1 个答案:

答案 0 :(得分:1)

我几乎可以构建identical code并运行它而不会遇到这些依赖项的问题。如果我使用shade插件来创建超级jar,它包含以下依赖项。正如你所见,picocontianer-1.2就在那里。

我唯一能想到的就是你的类路径中缺少它,或者你有下载的伪装。

[INFO] Including org.geotools:gt-shapefile:jar:18.1 in the shaded jar.
[INFO] Including org.geotools:gt-data:jar:18.1 in the shaded jar.
[INFO] Including org.jdom:jdom:jar:1.1.3 in the shaded jar.
[INFO] Including org.geotools.xsd:gt-xsd-kml:jar:18.1 in the shaded jar.
[INFO] Including org.geotools.xsd:gt-xsd-core:jar:18.1 in the shaded jar.
[INFO] Including picocontainer:picocontainer:jar:1.2 in the shaded jar.
[INFO] Including commons-jxpath:commons-jxpath:jar:1.3 in the shaded jar.
[INFO] Including commons-collections:commons-collections:jar:3.2.2 in the shaded jar.
[INFO] Including org.eclipse.emf:org.eclipse.emf.common:jar:2.12.0 in the shaded jar.
[INFO] Including org.eclipse.emf:org.eclipse.emf.ecore:jar:2.12.0 in the shaded jar.
[INFO] Including org.eclipse.xsd:org.eclipse.xsd:jar:2.12.0 in the shaded jar.
[INFO] Including org.eclipse.emf:org.eclipse.emf.ecore.xmi:jar:2.12.0 in the shaded jar.
[INFO] Including org.geotools:gt-metadata:jar:18.1 in the shaded jar.
[INFO] Including org.geotools:gt-opengis:jar:18.1 in the shaded jar.
[INFO] Including net.java.dev.jsr-275:jsr-275:jar:1.0-beta-2 in the shaded jar.
[INFO] Including commons-pool:commons-pool:jar:1.5.4 in the shaded jar.
[INFO] Including org.geotools:gt-epsg-hsql:jar:18.1 in the shaded jar.
[INFO] Including org.geotools:gt-referencing:jar:18.1 in the shaded jar.
[INFO] Including com.googlecode.efficient-java-matrix-library:core:jar:0.26 in the shaded jar.
[INFO] Including jgridshift:jgridshift:jar:1.0 in the shaded jar.
[INFO] Including net.sf.geographiclib:GeographicLib-Java:jar:1.44 in the shaded jar.
[INFO] Including org.hsqldb:hsqldb:jar:2.3.0 in the shaded jar.
[INFO] Including org.geotools:gt-main:jar:18.1 in the shaded jar.
[INFO] Including org.geotools:gt-api:jar:18.1 in the shaded jar.
[INFO] Including com.vividsolutions:jts-core:jar:1.14.0 in the shaded jar.
[INFO] Including org.geotools:gt-render:jar:18.1 in the shaded jar.
[INFO] Including org.geotools:gt-coverage:jar:18.1 in the shaded jar.
[INFO] Including javax.media:jai_imageio:jar:1.1 in the shaded jar.
[INFO] Including it.geosolutions.imageio-ext:imageio-ext-tiff:jar:1.1.18 in the shaded jar.
[INFO] Including it.geosolutions.imageio-ext:imageio-ext-utilities:jar:1.1.18 in the shaded jar.
[INFO] Including it.geosolutions.imageio-ext:imageio-ext-geocore:jar:1.1.18 in the shaded jar.
[INFO] Including it.geosolutions.imageio-ext:imageio-ext-streams:jar:1.1.18 in the shaded jar.
[INFO] Including javax.media:jai_codec:jar:1.1.3 in the shaded jar.
[INFO] Including com.vividsolutions:jts-example:jar:1.14.0 in the shaded jar.
[INFO] Including com.vividsolutions:jts-io:jar:1.14.0 in the shaded jar.
[INFO] Including com.googlecode.json-simple:json-simple:jar:1.1 in the shaded jar.
[INFO] Including org.jaitools:jt-zonalstats:jar:1.4.0 in the shaded jar.
[INFO] Including org.jaitools:jt-utils:jar:1.4.0 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.affine:jt-affine:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.algebra:jt-algebra:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.bandmerge:jt-bandmerge:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.bandselect:jt-bandselect:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.bandcombine:jt-bandcombine:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.border:jt-border:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.buffer:jt-buffer:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.crop:jt-crop:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.iterators:jt-iterators:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.lookup:jt-lookup:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.mosaic:jt-mosaic:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.nullop:jt-nullop:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.rescale:jt-rescale:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.scale:jt-scale:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.stats:jt-stats:jar:1.0.16 in the shaded jar.
[INFO] Including com.google.guava:guava:jar:17.0 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.translate:jt-translate:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.utilities:jt-utilities:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.warp:jt-warp:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.zonal:jt-zonal:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.binarize:jt-binarize:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.format:jt-format:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.colorconvert:jt-colorconvert:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.errordiffusion:jt-errordiffusion:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.orderdither:jt-orderdither:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.colorindexer:jt-colorindexer:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.imagefunction:jt-imagefunction:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.piecewise:jt-piecewise:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.classifier:jt-classifier:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.rlookup:jt-rlookup:jar:1.0.16 in the shaded jar.
[INFO] Including it.geosolutions.jaiext.vectorbin:jt-vectorbin:jar:1.0.16 in the shaded jar.
[INFO] Including org.geotools:gt-cql:jar:18.1 in the shaded jar.
[INFO] Including org.geotools:gt-swing:jar:18.1 in the shaded jar.
[INFO] Including com.miglayout:miglayout:jar:swing:3.7 in the shaded jar.
[INFO] Including commons-io:commons-io:jar:2.4 in the shaded jar.
[INFO] Including net.sourceforge.javacsv:javacsv:jar:2.0 in the shaded jar.
[INFO] Including com.sun.xml.bind:jaxb-impl:jar:2.1.13 in the shaded jar.
[INFO] Including javax.xml.bind:jaxb-api:jar:2.1 in the shaded jar.
[INFO] Including javax.xml.stream:stax-api:jar:1.0-2 in the shaded jar.
[INFO] Including javax.activation:activation:jar:1.1 in the shaded jar.
[INFO] Including javax.media:jai_core:jar:1.1.3 in the shaded jar.
[INFO] Including org.apache.xmlgraphics:batik-svggen:jar:1.7 in the shaded jar.
[INFO] Including org.apache.xmlgraphics:batik-util:jar:1.7 in the shaded jar.
[INFO] Including xml-apis:xml-apis:jar:1.3.04 in the shaded jar.
[INFO] Including org.apache.xmlgraphics:batik-awt-util:jar:1.7 in the shaded jar.
[INFO] Including org.geotools:gt-epsg-wkt:jar:18.1 in the shaded jar.
[INFO] Including commons-cli:commons-cli:jar:1.4 in the shaded jar.

mvn dependency:tree的输出很吻合。