Library is not working because of dependencies
WojciechZankowski opened this issue · comments
Describe the bug
With other dependencies library is failing because of lack of dependencies.
To Reproduce
- Create Spring Boot project
- Add dependency to IEXTrading4j library
- Library is not able to parse response because of missing dependency
Expected behavior
Library should work fine with other frameworks
Additional context
Caused by: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json;charset=utf-8, type=interface java.util.List, genericType=java.util.List<pl.zankowski.iextrading4j.api.stocks.Chart>.
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:231)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:834)
at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:368)
at org.glassfish.jersey.client.InboundJaxrsResponse$2.call(InboundJaxrsResponse.java:126)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:419)
at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:267)
at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:123)
at pl.zankowski.iextrading4j.client.rest.manager.RestManager.executeRequest(RestManager.java:38)
... 33 more
I'm experiencing an issue that may be similar. Again, Spring Boot (using Jhipster), when I invoke the ref-data resource, I get the following stack trace:
java.lang.NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object;[Ljava/lang/Object;)V
at org.glassfish.jersey.client.ClientRequest.accept(ClientRequest.java:335)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:222)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:60)
at pl.zankowski.iextrading4j.client.rest.manager.RestManager.executeRequest(RestManager.java:27)
at pl.zankowski.iextrading4j.client.rest.AbstractRestEndpoint.execute(AbstractRestEndpoint.java:16)
at pl.zankowski.iextrading4j.client.rest.endpoint.GenericRestEndpoint.executeRequest(GenericRestEndpoint.java:14)
at pl.zankowski.iextrading4j.client.IEXTradingClient.executeRequest(IEXTradingClient.java:35)
at com.test.integration.iex.IEXTradingSymbolsTest.testFetchSymbols(IEXTradingSymbolsTest.java:24)
I don't run into this issue in a plain Java project. I'm using Gradle.
Hello @1in9ui5t
I updated all libraries in the project. There was new version of jersey-client that required some changes in project dependencies. But your case looks a bit different then all issues reported with external libraries.
Here is maven dependency, hope you will be able to transform it into gradle dependency.
<dependency>
<groupId>pl.zankowski</groupId>
<artifactId>iextrading4j-all</artifactId>
<version>2.2.2</version>
</dependency>
Could you please chceck if this fixed your issue?
Thanks!
@WojciechZankowski thanks for that. I just tried with 2.2.2
compile group: "pl.zankowski", name: "iextrading4j-all", version: "2.2.2"
however that didn't resolve the issue. The addAll
method of javax.ws.rs.core.MultivaluedMap.addAll
was introduced by JEE7; it's absent from JEE6.
My spring-boot configuration utilizes embedded undertow. Attached is my dependency tree.
That looks like dependency conflict. In your dependency tree I can see both:
jsr311-api - This is the official spec jar for the JAX-RS 1.x - from spring-cloud-eureka-client
javax.ws.rs-api - This is the official spec jar for the JAX-RS 2.x from my library
Currently most of the libraries moved to JAX-RS 2.x but for whatever reason spring-cloud-eureka still stays on JAX-RS 1.x Most likely because eureka-client-jersey2 that supports JAX-RS 2.x is not maintained by Netflix, but by community.
Some issues related to the topic:
- Eureka dependency update to JAX-RS 2.x: Netflix/eureka#600
- Spring Cloud Eureka support for JAX-RS 2.x: spring-cloud/spring-cloud-netflix#846 (still open)
So at the end, to use any library that is using JAX-RS 2.x (not only this one) you would need to exclude this old JAX-RS 1.x spec.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.0.RC1</version>
<exclusions>
<exclusion>
<artifactId>jsr311-api</artifactId>
<groupId>javax.ws.rs</groupId>
</exclusion>
</exclusions>
</dependency>
You can give it a try if you want, but I cannot guarantee that it will work...
Seems like I cannot do anything more about this, sorry :(
Cheers,
Wojtek
@WojciechZankowski thank you, much appreciated.
Hello
I am experiencing this issue as well.
Exception in thread "main" org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json;charset=utf-8, type=interface java.util.List, genericType=java.util.List<pl.zankowski.iextrading4j.api.stocks.Chart>.
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:208)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:132)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1067)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:850)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:810)
at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:339)
at org.glassfish.jersey.client.InboundJaxrsResponse$2.call(InboundJaxrsResponse.java:102)
at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
at org.glassfish.jersey.internal.Errors.process(Errors.java:205)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:365)
at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:240)
at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:99)
at pl.zankowski.iextrading4j.client.rest.manager.RestManager.executeRequest(RestManager.java:50)
at pl.zankowski.iextrading4j.client.rest.AbstractRestEndpoint.execute(AbstractRestEndpoint.java:16)
at pl.zankowski.iextrading4j.client.rest.endpoint.GenericRestEndpoint.executeRequest(GenericRestEndpoint.java:14)
at pl.zankowski.iextrading4j.client.IEXTradingClient.executeRequest(IEXTradingClient.java:62)
at com.algotech.iexfeed.IexFeed.getPricing(IexFeed.java:126)
at com.algotech.iexfeed.IexFeed.main(IexFeed.java:118)
this is my maven entry
pl.zankowski iextrading4j-all 3.0.1Any ideas how to resolve this? I have tried several things but to no avail. Interestingly it runs fine inside NetBeans but not as a standalone application
Thanks in advance for any pointers …..
@algotechnology it is really hard to say. I would need some details. For example what libraries do you have in your pom. If you don't want to share your pom here then you can send me it over the email from my profile.
@algotechnology I just saw your email. Exactly, here is the answer for your problem with uber jar: https://stackoverflow.com/questions/37735728/messagebodyprovidernotfoundexception-while-running-jar-from-command-line
Cheers!
That looks like dependency conflict. In your dependency tree I can see both:
jsr311-api - This is the official spec jar for the JAX-RS 1.x - from spring-cloud-eureka-client
javax.ws.rs-api - This is the official spec jar for the JAX-RS 2.x from my libraryCurrently most of the libraries moved to JAX-RS 2.x but for whatever reason spring-cloud-eureka still stays on JAX-RS 1.x Most likely because eureka-client-jersey2 that supports JAX-RS 2.x is not maintained by Netflix, but by community.
Some issues related to the topic:
- Eureka dependency update to JAX-RS 2.x: Netflix/eureka#600
- Spring Cloud Eureka support for JAX-RS 2.x: spring-cloud/spring-cloud-netflix#846 (still open)
So at the end, to use any library that is using JAX-RS 2.x (not only this one) you would need to exclude this old JAX-RS 1.x spec.
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> <version>2.0.0.RC1</version> <exclusions> <exclusion> <artifactId>jsr311-api</artifactId> <groupId>javax.ws.rs</groupId> </exclusion> </exclusions> </dependency>
You can give it a try if you want, but I cannot guarantee that it will work...
Seems like I cannot do anything more about this, sorry :(
Cheers,
Wojtek
Thanks :)
worked like a charm!!