I'm getting crazy regarding JAX-RS 2 usage (Jersey 2.17). I migrated from JAX-RS 1.0 and some texts posted here are explaining to use response.readEntity(Class.class). But this method is missing in Jersey 2.17. Is its documentation outdated? How could I extract an entity from Response?
I found a problem in my pom.xml . It was a outdated glassfish-embedded-web with a conflict in Jersey. I removed it and now it's working fine.
I am using jersey-server, jersey-client, jersey-container-servlet-core, all 3 of version 2.23.1. Please make sure you have imported javax.ws.rs-api version 2.0.1 or later. I had not imported it in my build.gradle. After importing, I was able to see readEntity method for my Response class.
Related
I tried out spring-boot-starter-actuator, by default instructions, add to spring boot project in pom, and it works without any issues.
As soon as I add spring-boot-starter-web-reactive everything breaks down, newly created reactive endpoint works, but actuator stopped working, have anybody had such issue and maybe already have any ideas how to solve it?
Also noticed, that h2 /console which I had working before, also broken.
I receive no errors, no exceptions, these things just stop working.
As Github page of Spring Boot Web Reactive Starter mentiones:
This experimental project ...
and
Go to start.spring.io, set the Spring Boot version to 2.0.0(SNAPSHOT) and add the "Reactive Web" starter.
When it's experimental, it is clearly not meant to be used in production and is not fully stable. Feel free to contribute or create issue.
Please, refer to this post Netty HttpServer api changed/differs from available examples
As the reactive-web is experimental you should add BOM file with compatible versions of libraries.
I am trying to integrate JAX-RS and Swagger together. While doing that I see following error is coming. After spending a lots of hours still I am not able to resolve it. Looking quick help from your end.
I've attached my whole source code in the git repository: https://github.com/JavaNeed/JAXRS-Example. Please try to resolve this error.
I faced similar issues integrating swagger and jax-rs. I finally got them resolved using jersey servlet implementation. See if following project helps you.
https://github.com/sanketsw/jax_rs_REST_Example
Also following link has the details of how to get JSON and YAML specification from JAX-RS API
https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5
I've got a problem with resources linking in Dropwizard. With JAX-RS 2.0 we've got magical javax.ws.rs.core.Link class which with it's builder can do almost all the work for you. Unfortunately Dropwizard 0.7.1 doesn't depend on the new 2.0 API, but on the old javax.ws.rs:jsr311-api API, which can't handle linking. Or can it? This is the problem I want to solve with Dropwizard. I probably have two ways to do it and I don't know if any of them is valid:
Option 1: I add JAX-RS 2.0 dependency to my project. Voila! I've got Link. But the problem is, that it doesn't work well with old implementations from Jersey - I got AbstractMethodException from UriBuilder, which apparently changed from version 1 to 2. So the answer is to supply new implementations. Can I do it? If yes, than how can I do it? Will new implementations work with dropwizard well?
Option 2: I can just add some other resource linking to dropwizard. Is there some other linking standard/library? I can't use jersey-declarative-linking because it mixes representations with the resources (the linking takes place in representations), and I want my representations not to know a thing about resources layer. So is there another linking standard for Dropwizard, Jersey and JAX-RS 1?
I've finally found an answer to my question.
Option 2 was a dead end. There was no other jax-rs-2-like linking library to either dropwizard or jersey itself.
Option one also was hard to do, but fortunatelly yesterday dropwizard released version 0.8.0-rc1 of their framework, which depends on jersey 2, which is the implementation of JAX-RS 2.0. So for all of you that want to have HATEOAS in dropwizard, version 0.8.0 is for you.
i am developing a restful service with tomcat 7 and jdk 1.6. for json handling i am using jackson 2.4.2 and it works fine except when i try and deserialise an object (that it has no trouble serialising).
the error is:
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonFactory
which is the place where jackson 1.x kept that particular class. my jackson 2.4.2 has it at
com.fasterxml.jackson.core.JsonFactory
i have no idea as to why it is trying to link the old class. i never used jackson 1.x.
what i use:
asm-3.3.1
commons-io-2.4
jackson-core-2.4.2
jackson-databind-2.4.2
jersey-bundle-1.18
mysql-connector-java-5.1.27
and
com.fasterxml.jackson.annotation
which i have taken from github. what library could be trying to import the old jackson module? any help would be much appreciated.
The issue certainly comes from trying to use Jackson 1.x ObjectMapper and missing underlying JsonFactory for 1.x. Since these come from difference jars (jackson-mapper-asl vs jackson-core-asl), it is likely that somehow one is missing.
Now, since you are not directly using Jackson 1.x, question is who is: perhaps jersey is relying on 1.x?
So there are two related questions: (a) if Jackson 1.x is needed, to bring in core jar as well, or (b) how to remove use of Jackson 1.x altogether.
Note that technically it is quite possible to use both 1.x and 2.x versions of Jackson, since 2.x was specifically designed to be able to co-exist. This to make upgrades easier, and allow gradual (component-by-component) upgrading.
What is the difference between com.sun.jersey and org.glassfish.jersey?
Currently I have my REST service working on com.sun.jersey and I want to write tests, but I can't find a good tutorial for this (nothing seems to work). However, I can find good documentation about the org.glassfish.jersey tests.
The only difference between com.sun.jersey and org.glassfish.jersey is that the package name was changed because Jersey team is now part of another organization (Glassfish).
Versions below 2 use package com.sun.jersey, versions above 2 use org.glassfish.jersey.
And yes, there are some differences between 1.x and 2.x.