ContainX / openstack4j

A Fluent OpenStack SDK / Client Library for Java
http://openstack4j.com
Other
290 stars 366 forks source link

UriBuilder AbstractMethod runtime error while using Openstack4j with deps v. 2.0.5 #472

Open Muntaner opened 9 years ago

Muntaner commented 9 years ago

I'm preparing a REST service which uses the Restlet + JAX-RS extension framework. At a certain point, I had to add the openstack4j library since some of the REST services are related to a private Openstack cloud installation. But when I try to call a method which uses Openstack4j library, I get this exception:

java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder; at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119) at org.glassfish.jersey.client.JerseyWebTarget.(JerseyWebTarget.java:71) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:177) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:68) at org.openstack4j.connectors.jersey2.HttpCommand.initialize(HttpCommand.java:51) at org.openstack4j.connectors.jersey2.HttpCommand.create(HttpCommand.java:45) at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.invoke(HttpExecutorServiceImpl.java:53) at org.openstack4j.connectors.jersey2.HttpExecutorServiceImpl.execute(HttpExecutorServiceImpl.java:33) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:51) at org.openstack4j.openstack.internal.OSAuthenticator.authenticateV2(OSAuthenticator.java:97) at org.openstack4j.openstack.internal.OSAuthenticator.invoke(OSAuthenticator.java:48) at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:107) at org.openstack4j.openstack.client.OSClientBuilder$ClientV2.authenticate(OSClientBuilder.java:71) at swopenstack.utils.Authenticator.authenticate(Authenticator.java:23) at swopenstack.oshypervisor.OSRouterService.createRouter(OSRouterService.java:29) at restservices.hypervisor.networks.RouterRESTService.createRouter(RouterRESTService.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.restlet.ext.jaxrs.internal.wrappers.AbstractMethodWrapper.internalInvoke(AbstractMethodWrapper.java:162) at org.restlet.ext.jaxrs.internal.wrappers.ResourceMethod.invoke(ResourceMethod.java:283) at org.restlet.ext.jaxrs.JaxRsRestlet.invokeMethod(JaxRsRestlet.java:997) at org.restlet.ext.jaxrs.JaxRsRestlet.handle(JaxRsRestlet.java:746) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202) at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:75) at org.restlet.Application.handle(Application.java:385) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.routing.Router.doHandle(Router.java:422) at org.restlet.routing.Router.handle(Router.java:639) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.routing.Router.doHandle(Router.java:422) at org.restlet.routing.Router.handle(Router.java:639) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:140) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.routing.Filter.doHandle(Filter.java:150) at org.restlet.routing.Filter.handle(Filter.java:197) at org.restlet.engine.CompositeHelper.handle(CompositeHelper.java:202) at org.restlet.Component.handle(Component.java:408) at org.restlet.Server.handle(Server.java:507) at org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63) at org.restlet.engine.adapter.HttpServerHelper.handle(HttpServerHelper.java:143) at org.restlet.engine.connector.HttpServerHelper$1.handle(HttpServerHelper.java:64) at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79) at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83) at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82) at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675) at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79) at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

I found a similar issue: https://github.com/gondor/openstack4j/issues/6, but it didn't help me in solving my issue. If I try to use the openstack4j library without deps, I have more errors of notfound classes.

AFAIK, it is a Jersey versions problem, but can't exactly understand how to solve it. Should I remove the openstack4j library jersey's dependency manually?

I'm using Intellij IDEA 14 community edition. The project is a Java SE one. The libraries I actually have in my project are:

Muntaner commented 9 years ago

I (think I) solved it by integrating my project with Maven and using the openstack4j package without deps, adding the needed deps via Maven itself.

My pom.xml deps are:

<dependencies>
    <dependency>
        <groupId>org.pacesys</groupId>
        <artifactId>openstack4j-core</artifactId>
        <version>2.0.5</version>
    </dependency>
    <dependency>
        <groupId>org.pacesys.openstack4j.connectors</groupId>
        <artifactId>openstack4j-okhttp</artifactId>
        <version>2.0.5</version>
    </dependency>
</dependencies>

So, I guess openstack4j now uses okhttp library and does not conflict with my restlet + JAX-RS stuff. This seems to be working with openstack4j-httpclient dependency too.

In my opinion, this isn't really an issue but more a fault of mine, but surely a better exception handling and outputs may help the developer in understanding which is the problem.

gondor commented 9 years ago

Thank you for updating this. Your correct, I should come up with a better way to explain the various connector choices like you found out. The biggest reason we offer the choices is for mixed environments and so you can use OpenStack4j without conflicts. In the past we only offered Jersey 2 and users who had older versions of Jersey running in their environments had problems with class loading and other issues. This is where connectors solved the issue so you can choose a solution which best fits your environment.

I'll look into making these docs more visible and easier to understand.