Dropwizard Application crashed by AbstractJAXBProvider

戏子无情 提交于 2019-12-14 03:55:17

问题


I have a server application implemented using Dropwizard and Gradle as Build System. Now I want to integrate Apache Mahout for some recommender system action.

After adding the Mahout dependency and try to run, I get exceptions.

My initial dependencies look like

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'
}

For doing some basic recommender system stuff I integrate the dependency

compile 'org.apache.mahout:mahout-mr:0.11.1'

When I now run the application I get a 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

So I tried to integrate this stuff as extra dependency via

compile 'com.sun.mail:javax.mail:1.5.4'

Running again the application, I get a different exception:

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)

The Code that causes the exception comes from Jersey:

@Context
public void setConfiguration(FeaturesAndProperties fp) {
    formattedOutput = fp.getFeature(FeaturesAndProperties.FEATURE_FORMATTED); // << Crash here
    xmlRootElementProcessing = fp.getFeature(FeaturesAndProperties.FEATURE_XMLROOTELEMENT_PROCESSING);
}

So it seems like the feature is null here and we can't do anything with it. Anyone an idea what's going on, or how I can manage this?


回答1:


The problem was / is that Dropwizard ships with a Jersey dependency (in my case org.glassfish.jersey in 2.22.x), and Apache Mahout ships with a different Jersey dependency (in my case com.sun.jersey in 1.9).

So excluding the Mahout Jersey dependency does the job. In my case this is done by

compile('org.apache.mahout:mahout-integration:0.11.1') {
    exclude group: 'com.sun.jersey'
}



回答2:


It is quite possible that a dependency that you are using might have a dependency that is not compatible with your module.

If you are using maven, use mvn dependency:tree to figure out.



来源:https://stackoverflow.com/questions/34136774/dropwizard-application-crashed-by-abstractjaxbprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!