Atmosphere、dropwizard 和 jersey 注入错误

Atmosphere, dropwizard and jersey injection error

这是我的 gradle 文件:

compile group: 'io.dropwizard', name: 'dropwizard-core', version: '0.8.0'
compile group: 'io.dropwizard', name: 'dropwizard-auth', version: '0.8.0'
compile group: 'io.dropwizard', name: 'dropwizard-client', version: '0.8.0'

compile group: 'org.glassfish.jersey.media', name: 'jersey-media-multipart', version: '2.16'

compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.16'
compile group: 'org.atmosphere', name: 'atmosphere-jersey', version: '2.1.10'

添加 atmosphere-jursey 后出现以下错误:

WARN  [2015-05-03 21:13:38,796] 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/MessagingException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2532)
at java.lang.Class.getDeclaredConstructors(Class.java:1901)
at org.jvnet.hk2.internal.Utilities.run(Utilities.java:1310)
at org.jvnet.hk2.internal.Utilities.run(Utilities.java:1306)
at java.security.AccessController.doPrivileged(Native Method)...
MultiException stack 2 of 3
java.lang.IllegalStateException: Unable to perform operation: method inject
on com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:395)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)
at org.jvnet.hk2.internal.PerLookupContext.findOrCreate(PerLookupContext.java:69)..
MultiException stack 3 of 3
java.lang.IllegalStateException: Unable to perform operation: 
create on org.glassfish.jersey.message.internal.MessageBodyFactory...
org.glassfish.hk2.api.MultiException: A MultiException has 
3 exceptions.    They are:
! 1. java.lang.NullPointerException
! 2. java.lang.IllegalStateException: Unable to perform operation: 
method inject on   com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App
! 3. java.lang.IllegalStateException: Unable to perform operation: 
create on org.glassfish.jersey.message.internal.MessageBodyFactory

据我在 atmosphere's pom.xml 中看到的情况,他们使用球衣 1.x 而 dropwizard 使用球衣 2.x。而且这两个图书馆相处得不好。我相信大气层没有直接支持球衣2,至少在最新版本中也没有。

所以我猜你不能使用 atmosphere-jersey 但我看到我的同事正在使用 atmosphere-runtimeatmosphere-annotations 以及 dropwizard 0.8 就好了。