java - 在 Jetty 应用程序中部署时,Stanford CoreNLP 找不到正确版本的 ejml

标签 java scala stanford-nlp

有很多类似的问题,人们在使用 StanfordNLP 中的 SentimentAnalysis 库时会遇到如下错误:

java.io.InvalidClassException: org.ejml.simple.SimpleBase; local class incompatible: stream classdesc serialVersionUID = 7560584869544985034, local class serialVersionUID = -5535333403571293496
at edu.stanford.nlp.sentiment.SentimentModel.loadSerialized(SentimentModel.java:629)
at edu.stanford.nlp.pipeline.SentimentAnnotator.<init>(SentimentAnnotator.java:54)
at edu.stanford.nlp.pipeline.AnnotatorImplementations.sentiment(AnnotatorImplementations.java:241)
at edu.stanford.nlp.pipeline.AnnotatorFactories$16.create(AnnotatorFactories.java:571)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:375)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:139)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:135)
at com.ccri.crusher.slotfiller.SentimentAnalyzer$.<init>(SentimentSayer.scala:31)
at com.ccri.crusher.slotfiller.SentimentAnalyzer$.<clinit>(SentimentSayer.scala)

然后人们告诉他们将这个 ejml(来自 google 的矩阵库)添加到他们的类路径中:scala error acessing stanford corenlp sentiment - local class incompatible

这是另一个类似的问题: Getting the error while integrating stanford sentiment analysis with java

它甚至在 github 问题中得到了回答:https://github.com/stanfordnlp/CoreNLP/issues/8

但我在编译时没有收到该错误消息,在打开 mvn:scala 控制台时也没有收到该错误消息。那时效果非常好。

我在启动 mvn: jetty 网络服务器并以这种方式访问​​类后收到错误。

我已经尝试在我的项目的许多地方添加依赖项,包括父级 pom 和模块级 pom,以及作为对 mvn jetty 插件的依赖项,所有这些都具有相同的结果。这是我要添加的依赖项:

<!-- https://mvnrepository.com/artifact/com.googlecode.efficient-java-matrix-library/ejml -->
<dependency>
    <groupId>com.googlecode.efficient-java-matrix-library</groupId>
    <artifactId>ejml</artifactId>
    <version>0.23</version>
</dependency>

这与我运行的 Stanford CoreNLP 版本相同(3.6 或 3.7(从源代码编译))。

我怀疑 jetty 有自己的“ejml”版本,它在斯坦福强制使用它,而不是像我上面指定的那样使用 0.23 版的 ejml。

我尝试了多个版本的 Stanford 和 ejml 但均未成功。

更新:在尝试了这么多不同版本的 Stanford 和 ejml 之后,看到流与本地版本没有一点变化,我确信问题不在那里。也许是因为我的 .war 和 .jar 中的 scala/java 版本不同?

更新 2:mvn: war 的依赖树(当我使用 ejml .21 时):

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building crusher-war 1.1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ crusher-war ---
[INFO] com.ccri.crusher:crusher-war:war:1.1.0-SNAPSHOT
[INFO] +- com.ccri.commons:commons-scalatra_2.11:jar:1.1:compile
[INFO] |  +- org.scalatra:scalatra_2.11:jar:2.3.0:compile
[INFO] |  |  +- org.scalatra:scalatra-common_2.11:jar:2.3.0:compile
[INFO] |  |  +- org.slf4j:slf4j-api:jar:1.7.5:compile
[INFO] |  |  +- org.clapper:grizzled-slf4j_2.11:jar:1.0.2:compile
[INFO] |  |  +- org.scalatra.rl:rl_2.11:jar:0.4.10:compile
[INFO] |  |  +- com.googlecode.juniversalchardet:juniversalchardet:jar:1.0.3:compile
[INFO] |  |  +- eu.medsea.mimeutil:mime-util:jar:2.1.3:compile
[INFO] |  |  +- joda-time:joda-time:jar:2.3:compile
[INFO] |  |  +- org.joda:joda-convert:jar:1.6:compile
[INFO] |  |  +- org.scala-lang.modules:scala-parser-combinators_2.11:jar:1.0.1:compile
[INFO] |  |  \- org.scala-lang.modules:scala-xml_2.11:jar:1.0.2:compile
[INFO] |  +- org.json4s:json4s-jackson_2.11:jar:3.2.10:compile
[INFO] |  |  +- org.json4s:json4s-core_2.11:jar:3.2.10:compile
[INFO] |  |  |  +- com.thoughtworks.paranamer:paranamer:jar:2.6:compile
[INFO] |  |  |  \- org.scala-lang:scalap:jar:2.11.0:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-databind:jar:2.3.1:compile
[INFO] |  |     +- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] |  |     \- com.fasterxml.jackson.core:jackson-core:jar:2.3.1:compile
[INFO] |  +- org.scalatra:scalatra-json_2.11:jar:2.3.0:compile
[INFO] |  +- org.scalatra:scalatra-scalate_2.11:jar:2.3.0:compile
[INFO] |  |  \- org.scalatra.scalate:scalate-core_2.11:jar:1.7.0:compile
[INFO] |  |     +- org.scalatra.scalate:scalate-util_2.11:jar:1.7.0:compile
[INFO] |  |     \- org.scala-lang:scala-compiler:jar:2.11.0:compile
[INFO] |  +- org.springframework:spring-web:jar:3.1.4.RELEASE:compile
[INFO] |  |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:3.1.4.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-asm:jar:3.1.4.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:3.1.4.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-context:jar:3.1.4.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-expression:jar:3.1.4.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-core:jar:3.1.4.RELEASE:compile
[INFO] |  |     \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  \- com.typesafe.scala-logging:scala-logging_2.11:jar:3.1.0:compile
[INFO] |     \- org.scala-lang:scala-reflect:jar:2.11.1:compile
[INFO] +- com.ccri.dragonfish:meta-web-utils:jar:1.7.1:compile
[INFO] |  +- com.ccri.dragonfish:sparql-utils:jar:1.7.1:compile
[INFO] |  |  +- org.openrdf.sesame:sesame-query:jar:2.7.6:compile
[INFO] |  |  |  \- org.openrdf.sesame:sesame-rio-api:jar:2.7.6:compile
[INFO] |  |  +- com.ccri.commons:sparql-endpoint_2.11:jar:1.1.4:compile
[INFO] |  |  +- org.apache.rya:rya.api:jar:3.2.10-ccri:compile
[INFO] |  |  |  +- org.calrissian.mango:mango-core:jar:1.2.0:compile
[INFO] |  |  |  |  \- commons-net:commons-net:jar:3.3:compile
[INFO] |  |  |  +- org.openrdf.sesame:sesame-queryalgebra-model:jar:2.7.6:compile
[INFO] |  |  |  +- org.openrdf.sesame:sesame-queryalgebra-evaluation:jar:2.7.6:compile
[INFO] |  |  |  |  +- org.openrdf.sesame:sesame-repository-sparql:jar:2.7.6:compile
[INFO] |  |  |  |  |  +- org.openrdf.sesame:sesame-repository-api:jar:2.7.6:compile
[INFO] |  |  |  |  |  +- org.openrdf.sesame:sesame-queryparser-api:jar:2.7.6:compile
[INFO] |  |  |  |  |  +- org.openrdf.sesame:sesame-queryparser-sparql:jar:2.7.6:compile
[INFO] |  |  |  |  |  \- org.openrdf.sesame:sesame-queryresultio-sparqlxml:jar:2.7.6:compile
[INFO] |  |  |  |  \- org.openrdf.sesame:sesame-http-client:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-http-protocol:jar:2.7.6:compile
[INFO] |  |  |  |     \- org.openrdf.sesame:sesame-queryresultio-api:jar:2.7.6:compile
[INFO] |  |  |  +- com.google.guava:guava:jar:18.0:compile
[INFO] |  |  |  \- org.apache.hadoop:hadoop-common:jar:2.5.2:compile
[INFO] |  |  |     +- org.apache.hadoop:hadoop-annotations:jar:2.5.2:compile
[INFO] |  |  |     |  \- jdk.tools:jdk.tools:jar:1.6:system
[INFO] |  |  |     +- xmlenc:xmlenc:jar:0.52:compile
[INFO] |  |  |     +- commons-httpclient:commons-httpclient:jar:3.1:compile
[INFO] |  |  |     +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] |  |  |     +- org.mortbay.jetty:jetty:jar:6.1.26:compile
[INFO] |  |  |     +- org.mortbay.jetty:jetty-util:jar:6.1.26:compile
[INFO] |  |  |     +- com.sun.jersey:jersey-core:jar:1.9:compile
[INFO] |  |  |     +- com.sun.jersey:jersey-json:jar:1.9:compile
[INFO] |  |  |     |  +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  |  |     |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  |  |     |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.8.3:compile
[INFO] |  |  |     |  \- org.codehaus.jackson:jackson-xc:jar:1.8.3:compile
[INFO] |  |  |     +- com.sun.jersey:jersey-server:jar:1.9:compile
[INFO] |  |  |     |  \- asm:asm:jar:3.1:compile
[INFO] |  |  |     +- tomcat:jasper-compiler:jar:5.5.23:runtime
[INFO] |  |  |     +- tomcat:jasper-runtime:jar:5.5.23:runtime
[INFO] |  |  |     +- javax.servlet.jsp:jsp-api:jar:2.1:runtime
[INFO] |  |  |     +- commons-el:commons-el:jar:1.0:runtime
[INFO] |  |  |     +- net.java.dev.jets3t:jets3t:jar:0.9.0:compile
[INFO] |  |  |     |  \- com.jamesmurty.utils:java-xmlbuilder:jar:0.4:compile
[INFO] |  |  |     +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] |  |  |     +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] |  |  |     +- org.apache.avro:avro:jar:1.7.4:compile
[INFO] |  |  |     |  \- org.xerial.snappy:snappy-java:jar:1.0.4.1:compile
[INFO] |  |  |     +- com.google.protobuf:protobuf-java:jar:2.5.0:compile
[INFO] |  |  |     +- org.apache.hadoop:hadoop-auth:jar:2.5.2:compile
[INFO] |  |  |     |  \- org.apache.directory.server:apacheds-kerberos-codec:jar:2.0.0-M15:compile
[INFO] |  |  |     |     +- org.apache.directory.server:apacheds-i18n:jar:2.0.0-M15:compile
[INFO] |  |  |     |     +- org.apache.directory.api:api-asn1-api:jar:1.0.0-M20:compile
[INFO] |  |  |     |     \- org.apache.directory.api:api-util:jar:1.0.0-M20:compile
[INFO] |  |  |     +- com.jcraft:jsch:jar:0.1.42:compile
[INFO] |  |  |     \- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] |  |  +- org.apache.rya:accumulo.rya:jar:3.2.10-ccri:compile
[INFO] |  |  |  +- org.openrdf.sesame:sesame-rio-ntriples:jar:2.7.6:compile
[INFO] |  |  |  \- org.openrdf.sesame:sesame-rio-nquads:jar:2.7.6:compile
[INFO] |  |  +- org.apache.rya:rya.indexing:jar:3.2.10-ccri:compile
[INFO] |  |  |  +- org.apache.rya:rya.sail:jar:3.2.10-ccri:compile
[INFO] |  |  |  |  +- org.apache.rya:rya.provenance:jar:3.2.10-ccri:compile
[INFO] |  |  |  |  +- net.sf.ehcache:ehcache-core:jar:1.7.2:compile
[INFO] |  |  |  |  +- com.tinkerpop.blueprints:blueprints-core:jar:2.5.0:compile
[INFO] |  |  |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-json-org:jar:2.2.3:compile
[INFO] |  |  |  |  |  |  \- org.json:json:jar:20090211:compile
[INFO] |  |  |  |  |  \- colt:colt:jar:1.2.0:compile
[INFO] |  |  |  |  |     \- concurrent:concurrent:jar:1.3.4:compile
[INFO] |  |  |  |  \- org.openrdf.sesame:sesame-runtime:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-repository-manager:jar:2.7.6:compile
[INFO] |  |  |  |     |  \- org.openrdf.sesame:sesame-repository-event:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-repository-http:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-repository-contextaware:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-repository-sail:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-sail-api:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-sail-federation:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-queryparser-serql:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-queryresultio-binary:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-queryresultio-sparqljson:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-queryresultio-text:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-repository-dataset:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-rio-binary:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-rio-n3:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-rio-rdfjson:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-rio-rdfxml:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-rio-trix:jar:2.7.6:runtime
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-sail-inferencer:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-sail-memory:jar:2.7.6:compile
[INFO] |  |  |  |     +- org.openrdf.sesame:sesame-sail-nativerdf:jar:2.7.6:runtime
[INFO] |  |  |  |     \- org.openrdf.sesame:sesame-sail-rdbms:jar:2.7.6:runtime
[INFO] |  |  |  |        \- commons-dbcp:commons-dbcp:jar:1.3:runtime
[INFO] |  |  |  +- org.apache.rya:mongodb.rya:jar:3.2.10-ccri:compile
[INFO] |  |  |  |  +- org.mongodb:mongo-java-driver:jar:2.13.3:compile
[INFO] |  |  |  |  \- de.flapdoodle.embed:de.flapdoodle.embed.mongo:jar:1.50.0:compile
[INFO] |  |  |  |     \- de.flapdoodle.embed:de.flapdoodle.embed.process:jar:1.50.0:compile
[INFO] |  |  |  |        +- net.java.dev.jna:jna:jar:4.0.0:compile
[INFO] |  |  |  |        \- net.java.dev.jna:jna-platform:jar:4.0.0:compile
[INFO] |  |  |  +- org.apache.rya:rya.prospector:jar:3.2.10-ccri:compile
[INFO] |  |  |  |  \- org.codehaus.groovy:groovy-all:jar:2.3.11:compile
[INFO] |  |  |  +- org.apache.lucene:lucene-core:jar:3.6.2:compile
[INFO] |  |  |  +- org.apache.lucene:lucene-analyzers:jar:3.6.2:compile
[INFO] |  |  |  +- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  |  |  \- org.locationtech.geomesa:geomesa-accumulo-datastore:jar:1.2.0:compile
[INFO] |  |  |     +- org.locationtech.geomesa:geomesa-filter:jar:1.2.0:compile
[INFO] |  |  |     |  \- org.geotools:gt-transform:jar:14.1:compile
[INFO] |  |  |     +- org.locationtech.geomesa:geomesa-security:jar:1.2.0:compile
[INFO] |  |  |     +- org.locationtech.geomesa:geomesa-feature-all:jar:1.2.0:compile
[INFO] |  |  |     |  +- org.locationtech.geomesa:geomesa-feature-common:jar:1.2.0:compile
[INFO] |  |  |     |  +- org.locationtech.geomesa:geomesa-feature-kryo:jar:1.2.0:compile
[INFO] |  |  |     |  +- org.locationtech.geomesa:geomesa-feature-avro:jar:1.2.0:compile
[INFO] |  |  |     |  \- org.locationtech.geomesa:geomesa-feature-nio:jar:1.2.0:compile
[INFO] |  |  |     +- org.locationtech.geomesa:geomesa-z3:jar:1.2.0:compile
[INFO] |  |  |     |  \- org.locationtech.sfcurve:sfcurve-zorder_2.11:jar:0.1.1:compile
[INFO] |  |  |     |     \- org.locationtech.sfcurve:sfcurve-api_2.11:jar:0.1.1:compile
[INFO] |  |  |     +- org.geotools:gt-cql:jar:14.1:compile
[INFO] |  |  |     +- org.geotools:gt-render:jar:14.1:compile
[INFO] |  |  |     |  \- org.geotools:gt-coverage:jar:14.1:compile
[INFO] |  |  |     |     +- org.jaitools:jt-zonalstats:jar:1.4.0:compile
[INFO] |  |  |     |     +- org.jaitools:jt-utils:jar:1.4.0:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.affine:jt-affine:jar:1.0.8:compile
[INFO] |  |  |     |     |  +- it.geosolutions.jaiext.iterators:jt-iterators:jar:1.0.8:compile
[INFO] |  |  |     |     |  +- it.geosolutions.jaiext.utilities:jt-utilities:jar:1.0.8:compile
[INFO] |  |  |     |     |  +- it.geosolutions.jaiext.scale:jt-scale:jar:1.0.8:compile
[INFO] |  |  |     |     |  |  \- it.geosolutions.jaiext.translate:jt-translate:jar:1.0.8:compile
[INFO] |  |  |     |     |  \- javax.media:jai_codec:jar:1.1.3:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.algebra:jt-algebra:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.bandmerge:jt-bandmerge:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.bandselect:jt-bandselect:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.bandcombine:jt-bandcombine:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.border:jt-border:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.buffer:jt-buffer:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.crop:jt-crop:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.lookup:jt-lookup:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.mosaic:jt-mosaic:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.nullop:jt-nullop:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.rescale:jt-rescale:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.stats:jt-stats:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.warp:jt-warp:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.zonal:jt-zonal:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.binarize:jt-binarize:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.format:jt-format:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.colorconvert:jt-colorconvert:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.errordiffusion:jt-errordiffusion:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.orderdither:jt-orderdither:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.colorindexer:jt-colorindexer:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.imagefunction:jt-imagefunction:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.piecewise:jt-piecewise:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.classifier:jt-classifier:jar:1.0.8:compile
[INFO] |  |  |     |     +- it.geosolutions.jaiext.rlookup:jt-rlookup:jar:1.0.8:compile
[INFO] |  |  |     |     \- it.geosolutions.jaiext.vectorbin:jt-vectorbin:jar:1.0.8:compile
[INFO] |  |  |     +- org.geotools:gt-process-feature:jar:14.1:compile
[INFO] |  |  |     |  \- org.geotools:gt-process:jar:14.1:compile
[INFO] |  |  |     +- org.apache.commons:commons-csv:jar:1.0:compile
[INFO] |  |  |     \- org.apache.curator:curator-recipes:jar:2.7.1:compile
[INFO] |  |  |        \- org.apache.curator:curator-framework:jar:2.7.1:compile
[INFO] |  |  |           \- org.apache.curator:curator-client:jar:2.7.1:compile
[INFO] |  |  +- org.openrdf.sesame:sesame-rio-trig:jar:2.7.6:compile
[INFO] |  |  |  +- org.openrdf.sesame:sesame-rio-turtle:jar:2.7.6:compile
[INFO] |  |  |  +- org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.6:runtime
[INFO] |  |  |  \- org.openrdf.sesame:sesame-rio-languages:jar:2.7.6:runtime
[INFO] |  |  \- org.apache.accumulo:accumulo-core:jar:1.6.4:compile
[INFO] |  |     +- com.beust:jcommander:jar:1.32:compile
[INFO] |  |     +- commons-cli:commons-cli:jar:1.2:compile
[INFO] |  |     +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] |  |     +- commons-configuration:commons-configuration:jar:1.6:compile
[INFO] |  |     |  +- commons-digester:commons-digester:jar:1.8:compile
[INFO] |  |     |  |  \- commons-beanutils:commons-beanutils:jar:1.7.0:compile
[INFO] |  |     |  \- commons-beanutils:commons-beanutils-core:jar:1.8.0:compile
[INFO] |  |     +- commons-lang:commons-lang:jar:2.4:compile
[INFO] |  |     +- jline:jline:jar:2.11:compile
[INFO] |  |     +- log4j:log4j:jar:1.2.16:compile
[INFO] |  |     +- org.apache.accumulo:accumulo-fate:jar:1.6.4:compile
[INFO] |  |     +- org.apache.accumulo:accumulo-start:jar:1.6.4:compile
[INFO] |  |     +- org.apache.accumulo:accumulo-trace:jar:1.6.4:compile
[INFO] |  |     +- org.apache.commons:commons-math:jar:2.1:compile
[INFO] |  |     +- org.apache.commons:commons-vfs2:jar:2.0:compile
[INFO] |  |     |  +- org.apache.maven.scm:maven-scm-api:jar:1.4:compile
[INFO] |  |     |  |  \- org.codehaus.plexus:plexus-utils:jar:1.5.6:compile
[INFO] |  |     |  \- org.apache.maven.scm:maven-scm-provider-svnexe:jar:1.4:compile
[INFO] |  |     |     +- org.apache.maven.scm:maven-scm-provider-svn-commons:jar:1.4:compile
[INFO] |  |     |     \- regexp:regexp:jar:1.3:compile
[INFO] |  |     +- org.apache.hadoop:hadoop-client:jar:2.2.0:compile
[INFO] |  |     |  +- org.apache.hadoop:hadoop-hdfs:jar:2.2.0:compile
[INFO] |  |     |  +- org.apache.hadoop:hadoop-mapreduce-client-app:jar:2.2.0:compile
[INFO] |  |     |  |  +- org.apache.hadoop:hadoop-mapreduce-client-common:jar:2.2.0:compile
[INFO] |  |     |  |  |  +- org.apache.hadoop:hadoop-yarn-client:jar:2.2.0:compile
[INFO] |  |     |  |  |  |  +- com.google.inject:guice:jar:3.0:compile
[INFO] |  |     |  |  |  |  |  \- javax.inject:javax.inject:jar:1:compile
[INFO] |  |     |  |  |  |  +- com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly2:jar:1.9:compile
[INFO] |  |     |  |  |  |  |  +- com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.9:compile
[INFO] |  |     |  |  |  |  |  |  +- javax.servlet:javax.servlet-api:jar:3.1.0:provided
[INFO] |  |     |  |  |  |  |  |  \- com.sun.jersey:jersey-client:jar:1.9:compile
[INFO] |  |     |  |  |  |  |  \- com.sun.jersey:jersey-grizzly2:jar:1.9:compile
[INFO] |  |     |  |  |  |  |     +- org.glassfish.grizzly:grizzly-http:jar:2.1.2:compile
[INFO] |  |     |  |  |  |  |     |  \- org.glassfish.grizzly:grizzly-framework:jar:2.1.2:compile
[INFO] |  |     |  |  |  |  |     |     \- org.glassfish.gmbal:gmbal-api-only:jar:3.0.0-b023:compile
[INFO] |  |     |  |  |  |  |     |        \- org.glassfish.external:management-api:jar:3.0.0-b012:compile
[INFO] |  |     |  |  |  |  |     +- org.glassfish.grizzly:grizzly-http-server:jar:2.1.2:compile
[INFO] |  |     |  |  |  |  |     |  \- org.glassfish.grizzly:grizzly-rcm:jar:2.1.2:compile
[INFO] |  |     |  |  |  |  |     +- org.glassfish.grizzly:grizzly-http-servlet:jar:2.1.2:compile
[INFO] |  |     |  |  |  |  |     \- org.glassfish:javax.servlet:jar:3.1:compile
[INFO] |  |     |  |  |  |  \- com.sun.jersey.contribs:jersey-guice:jar:1.9:compile
[INFO] |  |     |  |  |  \- org.apache.hadoop:hadoop-yarn-server-common:jar:2.2.0:compile
[INFO] |  |     |  |  \- org.apache.hadoop:hadoop-mapreduce-client-shuffle:jar:2.2.0:compile
[INFO] |  |     |  +- org.apache.hadoop:hadoop-yarn-api:jar:2.2.0:compile
[INFO] |  |     |  +- org.apache.hadoop:hadoop-mapreduce-client-core:jar:2.2.0:compile
[INFO] |  |     |  |  \- org.apache.hadoop:hadoop-yarn-common:jar:2.2.0:compile
[INFO] |  |     |  \- org.apache.hadoop:hadoop-mapreduce-client-jobclient:jar:2.2.0:compile
[INFO] |  |     +- org.apache.thrift:libthrift:jar:0.9.1:compile
[INFO] |  |     |  \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] |  |     \- org.apache.zookeeper:zookeeper:jar:3.4.5:compile
[INFO] |  |        \- org.jboss.netty:netty:jar:3.2.2.Final:compile
[INFO] |  +- org.openrdf.sesame:sesame-model:jar:2.7.6:compile
[INFO] |  |  \- org.openrdf.sesame:sesame-util:jar:2.7.6:compile
[INFO] |  \- org.json4s:json4s-ast_2.11:jar:3.2.10:compile
[INFO] +- com.ccri.crusher:crusher-web-cqlknn:jar:1.1.0-SNAPSHOT:compile
[INFO] |  +- com.ccri.crusher:crusher-suggest:jar:1.1.0-SNAPSHOT:compile
[INFO] |  |  +- com.ccri:knn-core:jar:2.1:compile
[INFO] |  |  |  +- com.ccri:knn-api:jar:2.1:compile
[INFO] |  |  |  +- com.ccri:knn-iterators:jar:2.1:compile
[INFO] |  |  |  +- com.ccri.commons:commons-serialization:jar:0.1.0:compile
[INFO] |  |  |  \- com.ccri.commons:commons-reflection-annotations:jar:0.1.10:compile
[INFO] |  |  \- org.scalanlp:breeze_2.11:jar:0.11:compile
[INFO] |  |     +- org.scalanlp:breeze-macros_2.11:jar:0.11:compile
[INFO] |  |     +- com.github.fommil.netlib:core:jar:1.1.2:compile
[INFO] |  |     +- net.sourceforge.f2j:arpack_combined_all:jar:0.1:compile
[INFO] |  |     +- net.sf.opencsv:opencsv:jar:2.3:compile
[INFO] |  |     +- com.github.rwl:jtransforms:jar:2.4.0:compile
[INFO] |  |     |  \- junit:junit:jar:4.8.2:compile
[INFO] |  |     +- org.apache.commons:commons-math3:jar:3.2:compile
[INFO] |  |     \- org.spire-math:spire_2.11:jar:0.7.4:compile
[INFO] |  |        \- org.spire-math:spire-macros_2.11:jar:0.7.4:compile
[INFO] |  +- com.ccri.dragonfish:ccri-ontology:jar:1.7.1:compile
[INFO] |  +- com.ccri.dragonfish:dragonfish-accumulo-core:jar:1.7.1:compile
[INFO] |  +- com.ccri.dragonfish:dragonfish-geometry:jar:1.7.1:compile
[INFO] |  |  +- org.locationtech.geomesa:geomesa-utils:jar:1.2.0:compile
[INFO] |  |  |  +- commons-pool:commons-pool:jar:1.6:compile
[INFO] |  |  |  +- org.apache.commons:commons-compress:jar:1.4.1:compile
[INFO] |  |  |  |  \- org.tukaani:xz:jar:1.0:compile
[INFO] |  |  |  +- com.vividsolutions:jts:jar:1.13:compile
[INFO] |  |  |  +- org.geotools:gt-referencing:jar:14.1:compile
[INFO] |  |  |  |  +- com.googlecode.efficient-java-matrix-library:core:jar:0.26:compile
[INFO] |  |  |  |  \- net.sf.geographiclib:GeographicLib-Java:jar:1.44:compile
[INFO] |  |  |  +- org.geotools:gt-main:jar:14.1:compile
[INFO] |  |  |  +- org.geotools:gt-metadata:jar:14.1:compile
[INFO] |  |  |  +- org.geotools:gt-opengis:jar:14.1:compile
[INFO] |  |  |  |  \- net.java.dev.jsr-275:jsr-275:jar:1.0-beta-2:compile
[INFO] |  |  |  +- org.geotools:gt-api:jar:14.1:compile
[INFO] |  |  |  +- org.geotools:gt-grid:jar:14.1:compile
[INFO] |  |  |  +- org.geotools:gt-data:jar:14.1:compile
[INFO] |  |  |  \- com.spatial4j:spatial4j:jar:0.4.1:compile
[INFO] |  |  \- org.geotools:gt-shapefile:jar:14.2:compile
[INFO] |  |     +- org.jdom:jdom:jar:1.1.3:compile
[INFO] |  |     \- javax.media:jai_core:jar:1.1.3:compile
[INFO] |  +- com.ccri.dragonfish:dragonfish-imagery:jar:1.7.1:compile
[INFO] |  |  +- com.ccri.dragonfish:dragonfish-breeze:jar:1.7.1:compile
[INFO] |  |  +- com.ccri.dragonfish:dragonfish-serialization:jar:1.7.1:compile
[INFO] |  |  |  +- com.esotericsoftware.kryo:kryo:jar:2.21:compile
[INFO] |  |  |  |  +- com.esotericsoftware.reflectasm:reflectasm:jar:shaded:1.07:compile
[INFO] |  |  |  |  |  \- org.ow2.asm:asm:jar:4.0:compile
[INFO] |  |  |  |  +- com.esotericsoftware.minlog:minlog:jar:1.2:compile
[INFO] |  |  |  |  \- org.objenesis:objenesis:jar:1.2:compile
[INFO] |  |  |  \- com.twitter:chill_2.11:jar:0.5.0:compile
[INFO] |  |  |     \- com.twitter:chill-java:jar:0.5.0:compile
[INFO] |  |  +- com.ccri.opencv:opencv:jar:2.4.11-free-fix:compile
[INFO] |  |  \- org.slf4j:slf4j-log4j12:jar:1.7.5:compile
[INFO] |  \- com.ccri.dragonfish:dragonfish-native:jar:1.7.1:compile
[INFO] |     +- com.ccri.gdal:gdal-natives:jar:1.11.2:compile
[INFO] |     \- commons-io:commons-io:jar:2.4:compile
[INFO] +- com.ccri.crusher:crusher-web-enrich:jar:1.1.0-SNAPSHOT:compile
[INFO] |  +- com.ccri.crusher:crusher-enrich-core:jar:1.1.0-SNAPSHOT:compile
[INFO] |  \- com.typesafe:config:jar:1.2.1:compile
[INFO] +- com.ccri.crusher:crusher-enrich-imagechip:jar:1.1.0-SNAPSHOT:compile
[INFO] +- com.ccri.crusher:crusher-web-suggest:jar:1.1.0-SNAPSHOT:compile
[INFO] |  \- com.ccri.crusher:crusher-enrich-datetime:jar:1.1.0-SNAPSHOT:compile
[INFO] +- com.ccri.crusher:crusher-web-thumbnail:jar:1.1.0-SNAPSHOT:compile
[INFO] +- com.ccri.crusher:crusher-web-search:jar:1.1.0-SNAPSHOT:compile
[INFO] |  +- com.ccri.crusher:crusher-search:jar:1.1.0-SNAPSHOT:compile
[INFO] |  |  +- com.ccri.commons:commons-query-core:jar:0.0.1:compile
[INFO] |  |  \- org.apache.solr:solr-solrj:jar:4.10.2:compile
[INFO] |  |     +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile
[INFO] |  |     +- org.apache.httpcomponents:httpcore:jar:4.3:compile
[INFO] |  |     +- org.apache.httpcomponents:httpmime:jar:4.3.1:compile
[INFO] |  |     +- org.codehaus.woodstox:wstx-asl:jar:3.2.7:compile
[INFO] |  |     \- org.noggit:noggit:jar:0.5:compile
[INFO] |  \- com.ccri.commons:commons-query-parsing:jar:0.0.1:compile
[INFO] +- com.ccri.crusher:crusher-web-slotfiller:jar:1.1.0-SNAPSHOT:compile
[INFO] |  \- com.ccri.crusher:crusher-slot-filler:jar:1.1.0-SNAPSHOT:compile
[INFO] |     +- com.ccri.commons:commons-reflection-loaders:jar:0.1.10:compile
[INFO] |     +- edu.stanford.nlp:stanford-corenlp:jar:3.5.2:compile
[INFO] |     |  +- com.io7m.xom:xom:jar:1.2.10:compile
[INFO] |     |  |  +- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] |     |  |  +- xerces:xercesImpl:jar:2.8.0:compile
[INFO] |     |  |  \- xalan:xalan:jar:2.7.0:compile
[INFO] |     |  +- de.jollyday:jollyday:jar:0.4.7:compile
[INFO] |     |  |  \- javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] |     |  \- javax.json:javax.json-api:jar:1.0:compile
[INFO] |     +- edu.stanford.nlp:stanford-corenlp:jar:models:3.5.2:compile
[INFO] |     \- com.googlecode.efficient-java-matrix-library:ejml:jar:0.21:compile
[INFO] \- org.scala-lang:scala-library:jar:2.11.7:compile

最佳答案

我让自己引用 java.io.Serializable 的文档:

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long:

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;

If a serializable class does not explicitly declare a serialVersionUID, then the serialization runtime will calculate a default serialVersionUID value for that class based on various aspects of the class, as described in the Java(TM) Object Serialization Specification. However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected InvalidClassExceptions during deserialization. Therefore, to guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. It is also strongly advised that explicit serialVersionUID declarations use the private modifier where possible, since such declarations apply only to the immediately declaring class--serialVersionUID fields are not useful as inherited members. Array classes cannot declare an explicit serialVersionUID, so they always have the default computed value, but the requirement for matching serialVersionUID values is waived for array classes.

这里的问题是 ejml 库中的所有 Serializable 类都没有 serialVersionUID 字段。例如the SimpleBase class. 因此,在您的情况下发生的情况是,您的数据由库的一个版本/构建序列化,但由具有不同 serialVersionUID 的另一个版本/构建反序列化。

也就是说,您需要找出用于序列化数据的版本和构建,并仅使用该构建。如果它来自 maven,那么你应该从 maven 使用它。如果您自己编译该版本,则无法保证 serialVersionUID 相同。

但正确的解决方法是向 ejml 库发出合并请求,将 serialVersionUID 值显式添加到所有实现 Serializable 的类。

关于java - 在 Jetty 应用程序中部署时,Stanford CoreNLP 找不到正确版本的 ejml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41315285/

相关文章:

java - 如何在android库中包含内部jar文件

scala - 在 Scala 中实现 ifTrue、ifFalse、ifSome、ifNone 等以避免 if(...) 和简单的模式匹配

scala - "Stable identifer required"伴随对象导入期间的错误

java - 提取中心名词

java - 在 JAVA 中用词汇信息(中心词)注释树库

java - ClassNotFoundException : edu. stanford.nlp.tagger.maxent.ExtractorNonAlphanumeric

java - Java 中的高阶函数

java - 有没有办法追溯调试执行?

java - Angular向java发送错误的日期格式并且无法在表中创建对象

scala - 将 HadoopRDD 转换为 DataFrame