I am using Jersey 1.9 and it is generating my WADL perfectly except I need to redefine the resources base URI.
I'm running Jetty 7 sitting behind Apache using mod_proxy as a reverse proxy to route REST requests back to Jetty / Jersey. So Jersey generates the resources base URI as
http://localhost:8080/testRestAPI/rest/
when I need something like
http://mydomain.com/rest/
I found this from Google but it is not working: http://jersey.576304.n2.nabble.com/Changing-baseURI-when-generating-WADL-td6169703.html
unfortunately, you've found a bug in Jersey implementation. Please file a new issue as stated on mailing list - jira link: http://java.net/jira/browse/JERSEY
What you can do for now is downgrade to Jersey 1.8, which should not be affected by latest changes in this area. Thanks and sorry for inconvenience!
EDIT: issue link: http://java.net/jira/browse/JERSEY-773
it is already fixed, so you should be able to use this feature in Jersey 1.10-b02 and newer.
Related
We use Apache CXF in our application with jax-rs to build REST Api. As of now, there is no documentation about the various endpoints available and is deployed on Tomcat 8.5 server.
I have done some R&D on how to find a solution. I understand that Swagger can be used.
But, I did not find enough documentation to user swagger with Apache CXF.
I understand that these type of questions are prohibited in the site. At the same time, I am not sure which chat room to use for this purpose.
Any information on this would help me a lot.
Depending on the CXF version that you are using, I would suggest to use OpenApiFeature (OpenAPI is newer than Swagger) as described here: http://cxf.apache.org/docs/openapifeature.html
You can also find multiple sample projects with Swagger or OpenAPI here: https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs
I have a REST API that was working with Jersey 2.6 and Swagger 1.3.7. I read that Jersey 2.9 fixes a warning that I was getting so I upgraded to the latest Jersey 2.16 but then Swagger stopped working. I went back and upgraded one version at a time until I saw that Swagger was working with 2.15 so I settled on that. Now, the PUT API fails with Swagger with the following error:
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method
The API works using FireFox RESTClient and specifying "application/json".
I do have "jersey-media-json-jackson" as a dependency and call "Client client = ClientBuilder.newClient().register(JacksonFeature.class);" in the program.
I tried upgrading Swagger but that did not help.
Has Swagger been verified to work with Jersey 2.15/2.16?
I've recently managed to get swagger-core to work with Jersey 2.16 with a similar issue. Keep in mind they are using the latest version (1.5.X) and not 1.3.X but the same solution will apply.
The problem is most likely with version resolution, specifically, the one of jackson-databind. For some reason, even jersey-media-json-jackson 2.16 depends on an older version of jackson-databind, even though it works fine with the latest version. Without having more details, it would be difficult to suggest a full solution, but you can follow the dependency tree and see the conflicts there.
If you do require further assistance, I'd suggest either using our mailing list, or even better, the IRC channel where we could interact online and resolve it.
We were working on creating a RESTful service. We have thought of using frameworks like jersey or cxf. But apparently we found that just using the javax.ws.rs-api-2.0.jar and the related annotations, we can get the service working.
Question is:
How does it work? Is it dependent on the application servers?
What if we application server does not support or have the implementation of the API?
If it is dependent on application servers, can I find out the library which the server is using especially tomcat?
EDIT 1
This question is invalid. javax.ws.rs-api-2.0.jar is just an API. Using this jar does not suffice. It will not give compilation errors.
But at run-time, you need providers which will implement the rs-api. And thus we need the frameworks like jersey or cxf.
In our application, these jars were added to the war during ant-build from external location and that is why it confused us.
I am closing this question.
Hello and thanks for your time!
I have been looking for solution long enough, but didn't find how to connect glassfish with built-in Jersey via Rest. Actually, it's not a point make it via Rest, but I found out that I can't do that anyway else, if I plan using not-embedded neo4j.
http://docs.neo4j.org/chunked/milestone/server-java-rest-client-example.html
In the manual I need to install Jersey, but that Jersey is different than Glassfish's one, there's no needed classes inside.
I cant just replace Jersey files in Glassfish because of GF incompability. So, do I need to use another Jersey client, foreing to Glassfish, for Rest queries?
I found also framework neo4j-rest-graphdb, but I'm not sure it will work and probably is what I need. http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-rest-graphdb/2.0.0-M06/
I found JDBC driver for Neo4j - is this a better for these purposes?
Thank you!
Neo4j uses jersey version 1.* while glassfish uses version 2.*
The API has been changed as you can check in their respective docs :
https://jersey.java.net/documentation/1.17/client-api.html
https://jersey.java.net/documentation/latest/client.html
You basically need to create a client in both cases, and then define a webresource in 1.*, and a webtarget in 2.*
The import paths were also modified.
For instance, the client in 1.* is :
import com.sun.jersey.api.client.Client;
while in 2.* it is :
import javax.ws.rs.client.Client;
You should check the API for more details.
I assume you are using Glassfish 4. You can use the Jersey client APIs bundled with it you don't need to install one. Some of the client class names in the Jersey2 client are different then Jersey 1
Do RESTEasy, Jersey or Restlet integrate client sided caching?
I read something about a CacheClient for Jersey
Is that an official implementation? If not, are they working on Client Caching for Jersey 2.0? Can someone confirm this?
For Resteasy I read here something about official client sided cache control.
Im not sure about Restlet. Are there some official good solutions?
Regarding Restlet, we are planning to add a caching service in version 2.2. That will benefit the JAX-RS extension as well.
See our detailled roadmap here.