这是我的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'

添加大气变色后,我得到以下错误:
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$3.run(Utilities.java:1310)
at org.jvnet.hk2.internal.Utilities$3.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中可以看到,他们使用的是jersey 1.x,而dropwizard使用的是jersey2.x。而且这两个库相处得并不好。我相信大气层没有直接支持jersey 2,至少在最新版本中也没有。

因此,我想您不能使用atmosphere-jersey,但我看到我的同事正在使用dropwizard 0.8的atmosphere-runtimeatmosphere-annotations很好。

关于compiler-errors - Atmosphere ,空投和 Jersey 注入(inject)错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30019832/

10-10 04:22