简体   繁体   English

无法解析类型[org.glassfish.jersey.message.filtering.spi.ObjectProvider的所有bean。 <com.fasterxml.jackson.databind.ser.FilterProvider> ]

[英]Unable to resolve any beans for Types [org.glassfish.jersey.message.filtering.spi.ObjectProvider<com.fasterxml.jackson.databind.ser.FilterProvider>]

trying to move from Moxy to Jackson json media provider for my Jersey web service and found couple of issues which I can't resolve so far: 试图从Moxy迁移到我的Jersey网络服务的Jackson json媒体提供程序,并发现了到目前为止我无法解决的几个问题:

first of all moxy was working fine for the same piece of code, but because we are using jackson everywhere in other projects I want to keep things consistent... so I changed 首先,moxy对于同一段代码工作正常,但是由于我们在其他项目中到处都使用杰克逊,所以我想保持一致。

1) dependency in pom to 1)依赖pom

<dependency>
    <groupId>org.glassfish.jersey.media</groupId>
    <artifactId>jersey-media-json-jackson</artifactId>
    <version>${jersey.version}</version>
</dependency>

2) ResourceConfig regester 2)ResourceConfig regester

register(JacksonFeature.class)

but I started to get this exception when I run my webservice(basically it happens when I return from the web service method ): 但是我在运行Web服务时开始遇到此异常(基本上是从Web服务方法返回时发生):

Caused by: org.jboss.weld.exceptions.UnsatisfiedResolutionException: WELD-001308: Unable to resolve any beans for Types: [org.glassfish.jersey.message.filtering.spi.ObjectProvider<com.fasterxml.jackson.databind.ser.FilterProvider>]; Bindings: [QualifierInstance{annotationClass=interface javax.enterprise.inject.Default, values={}, hashCode=48147280}]
    at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:815) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
    at org.jboss.weld.bean.builtin.InstanceImpl.get(InstanceImpl.java:75) [weld-core-impl-2.1.2.Final.jar:2014-01-09 09:23]
    at org.glassfish.jersey.jackson.internal.FilteringJacksonJaxbJsonProvider.writeTo(FilteringJacksonJaxbJsonProvider.java:130) [jersey-media-json-jackson-2.17.jar:]
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1128) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:664) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:421) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:411) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:308) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.internal.Errors.process(Errors.java:267) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) [jersey-common-2.17.jar:]
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:288) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1110) [jersey-server-2.17.jar:]
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:401) [jersey-container-servlet-core-2.17.jar:]
    ... 29 more

yea...and apparently we use WildFly as an application server if it matters . 是的...很显然,如果重要的话,我们将WildFly用作应用程序服务器。

So if someone could point me where the problem might be, that's would be awesome. 因此,如果有人可以指出问题所在,那就太好了。

Cheers! 干杯!

The problem seems to be occurring in the FilteringJacksonJaxbJsonProvider , which is Jersey own Jackson provider, for it's support for it Entity Data Filtering . 该问题似乎是在Jerseying自己的Jackson提供者FilteringJacksonJaxbJsonProvider发生的,因为它支持Entity Data Filtering Seems there is some injection (invoking Weld) going on that causes it to fail. 似乎正在进行一些注入(调用“焊接”)导致其失败。 If you don't need the entity data filtering feature, you could get rid of the jersey-media-json-jackson and instead use 如果您不需要实体数据过滤功能,则可以摆脱jersey-media-json-jackson ,而改用

<dependency>
  <groupId>com.fasterxml.jackson.jaxrs</groupId>
  <artifactId>jackson-jaxrs-json-provider</artifactId>
  <version>${jackson2.version}</version>
</dependency>
// as of now ${jackson2.version} == 2.5.3

As for the Weld problem, I am not sure if it will cause a problem for you in the future, so I would not consider changing the Jackson dependency being a solution, rather a work-around. 至于Weld问题,我不确定将来是否会给您带来问题,因此我不认为更改Jackson依赖关系是一种解决方案,而是一种解决方法。

You said in your comments you are using gf-cdi . 您在评论中说您正在使用gf-cdi Maybe that is the problem. 也许这就是问题所在。 That artifact is no longer produced after Jersey 2.14 (you're using Jersey 2.17). 在Jersey 2.14(您使用的是Jersey 2.17)之后,不再生成该工件。 The CDI support module has changed. CDI支持模块已更改。 You can see 27.3.1. 您可以看到27.3.1。 Release 2.15 Highlights . 发布2.15亮点 It mentions some things about the CDI support dependencies. 它提到了有关CDI支持依赖项的一些信息。

CDI support improvement caused breaking changes for those users directly referring to the following CDI supporting Jersey module in maven: CDI支持改进导致直接参考以下Maven中的以下CDI支持Jersey模块的用户的重大更改:

 <dependency> <groupId>org.glassfish.jersey.containers.glassfish</groupId> <artifactId>jersey-gf-cdi</artifactId> <version>${pre-2.15-version}</version> </dependency> 

The above dependency needs to be replaced with: 上面的依赖关系需要替换为:

 <dependency> <groupId>org.glassfish.jersey.ext.cdi</groupId> <artifactId>jersey-cdi1x</artifactId> <version>2.17</version> </dependency> 

The following needs to be included in addition if you want to leverage CDI JTA support: 如果要利用CDI JTA支持,还需要包括以下内容:

 <dependency> <groupId>org.glassfish.jersey.ext.cdi</groupId> <artifactId>jersey-cdi1x-transaction</artifactId> <version>2.17</version> </dependency> 

I was able to solve this by simply putting "Accept: application/xml" in the request. 我只需在请求中添加“ Accept:application / xml”就可以解决此问题。 I also used @Consumes annotation as shown in the screenshot. 我还使用了@Consumes批注,如屏幕截图所示。 在此处输入图片说明

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flink启动时java.lang.ClassNotFoundException:com.fasterxml.jackson.databind.ser.FilterProvider - java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ser.FilterProvider when flink boot up java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider - java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider com.fasterxml.jackson.databind.ser.BeanSerializer.serialize Spring JPA - com.fasterxml.jackson.databind.ser.BeanSerializer.serialize Spring JPA 如何解决 com.fasterxml.jackson.databind.ser 错误 - How To Solve com.fasterxml.jackson.databind.ser Error 杰克逊错误 com.fasterxml.jackson.databind.ser.ContainerSerializer: 方法<init> (Lcom/fasterxml/jackson/databind/JavaType;)V 未找到 - Jackson error com.fasterxml.jackson.databind.ser.ContainerSerializer: method <init>(Lcom/fasterxml/jackson/databind/JavaType;)V not found 服务器崩溃并出现错误:com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields - Server crashes with the error: com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.Z93F725A07423FE1C889F448B33BootD21F:248B33BootD21F - com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25 SpringBoot java.lang.StackOverflowError: null at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields - java.lang.StackOverflowError: null at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields com.fasterxml.jackson.databind.node.ObjectNode无法转换为org.codehaus.jackson.node.ObjectNode - com.fasterxml.jackson.databind.node.ObjectNode cannot be converted to org.codehaus.jackson.node.ObjectNode com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException - com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM