我有一个使用Dropwizard和Gradle作为构建系统的服务器应用程序。现在,我想集成一些推荐系统操作的阿帕奇马乌特。
在添加Mahout依赖项并尝试运行之后,我会得到异常。
我的初始依赖项看起来像
dependencies {
compile 'io.dropwizard:dropwizard-core:0.9.1'
compile 'io.dropwizard:dropwizard-jdbi:0.9.1'
compile 'mysql:mysql-connector-java:5.1.37'
compile 'redis.clients:jedis:2.8.0'
compile 'com.google.guava:guava:18.0'
compile 'joda-time:joda-time:2.9.1'
compile 'org.apache.commons:commons-math3:3.4.1'
}为了做一些基本的推荐系统,我集成了依赖项。
compile 'org.apache.mahout:mahout-mr:0.11.1'当我现在运行应用程序时,我得到一个NoClassDefFoundException:
WARN [2015-12-07 15:03:09,696] org.glassfish.jersey.internal.Errors:
The following warnings have been detected: WARNING: HK2 service reification
failed for [com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider]
with an exception:
MultiException stack 1 of 2
java.lang.NoClassDefFoundError: javax/mail/internet/ParseException所以我试着把这些东西整合成额外的依赖关系
compile 'com.sun.mail:javax.mail:1.5.4'再次运行应用程序,我得到一个不同的例外:
WARN [2015-12-07 15:05:02,161] org.glassfish.jersey.internal.Errors: The
following warnings have been detected: WARNING: Unknown HK2 failure detected:
MultiException stack 1 of 2
java.lang.NullPointerException at
com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.setConfiguration(AbstractJAXBProvider.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)导致异常的代码来自泽西岛:
@Context
public void setConfiguration(FeaturesAndProperties fp) {
formattedOutput = fp.getFeature(FeaturesAndProperties.FEATURE_FORMATTED); // << Crash here
xmlRootElementProcessing = fp.getFeature(FeaturesAndProperties.FEATURE_XMLROOTELEMENT_PROCESSING);
}所以看起来这个特性在这里是空的,我们不能用它做任何事情。有谁知道这是怎么回事,或者我怎么处理这件事?
发布于 2015-12-07 17:11:49
问题是,Dropwizard附带了泽西依赖项(在我的例子中是2.22.x中的org.glassfish.jersey ),Apache提供了不同的泽西依赖项(在我的例子中是1.9中的com.sun.jersey )。
因此,除去马赫特泽西岛的依赖性,就能做到这一点。在我的例子中,这是通过
compile('org.apache.mahout:mahout-integration:0.11.1') {
exclude group: 'com.sun.jersey'
}发布于 2017-09-14 09:28:08
您所使用的依赖项很可能具有与您的模块不兼容的依赖项。
如果您使用的是maven,请使用mvn dependency:tree来计算。
https://stackoverflow.com/questions/34136774
复制相似问题