简体   繁体   中英

How can I use another rest client than jersey in an OSGi environment?

I am currently trying to deploy an application to Apache Felix that can access an external rest webservice. I am using jax-rs for that and Apache CXF as the rest client, so my code looks somehow like this:

ClientBuilder.newClient().target("http://my-endpoint.com/")
.path("path-to-api/")
.request(MediaType.APPLICATION_JSON_TYPE)
.get();

I have already deployed the Apache CXF rest client as an osgi bundle, but still I am getting the following exception: java.lang.ClassNotFoundException: org.glassfish.jersey.client.JerseyClientBuilder cannot be found . The application works in a unit test and also when I directly use the implementation org.apache.cxf.jaxrs.client.WebClient instead of the interface javax.ws.rs.client.Client . How can I use another rest client than jersey in an osgi environment?

I already found the solution by myself. The problem was that I used the dependency org.apache.aries.javax.jax.rs-api instead of javax.ws.rs-api .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM