Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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

1) dependency in pom to

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

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 ):

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 .

So if someone could point me where the problem might be, that's would be awesome.

Cheers!

like image 920
Fedor Skrynnikov Avatar asked May 25 '15 07:05

Fedor Skrynnikov


1 Answers

The problem seems to be occurring in the FilteringJacksonJaxbJsonProvider, which is Jersey own Jackson provider, for it's support for it 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

<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.

You said in your comments you are using gf-cdi. Maybe that is the problem. That artifact is no longer produced after Jersey 2.14 (you're using Jersey 2.17). The CDI support module has changed. You can see 27.3.1. Release 2.15 Highlights. It mentions some things about the CDI support dependencies.

CDI support improvement caused breaking changes for those users directly referring to the following CDI supporting Jersey module in maven:

<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:

<dependency>
     <groupId>org.glassfish.jersey.ext.cdi</groupId>
     <artifactId>jersey-cdi1x-transaction</artifactId>
     <version>2.17</version>
</dependency>
like image 198
Paul Samsotha Avatar answered Nov 09 '22 11:11

Paul Samsotha