[controller-dev] RPC implementation not found with Apache HttpClient

Vratko Polak -X (vrpolak - PANTHEON TECHNOLOGIES at Cisco) vrpolak at cisco.com
Fri Aug 12 14:29:00 UTC 2016


I can confirm bug3 branch leads to the described error,
but commenting-out just the GsonBuilder line avoids the error.
Obviously some kind of introspection takes place.

Looking at TRACE logs, it is not clear to me
why the Rpc was not registered.
I see logs from visitMethod [0],
but I was unable to determine what is it trying to achieve.

Vratko.

[0] http://grepcode.com/file/repo1.maven.org/maven2/org.apache.aries.proxy/org.apache.aries.proxy.impl/0.4/org/apache/aries/proxy/impl/common/AbstractWovenProxyAdapter.java#293


From: controller-dev-bounces at lists.opendaylight.org [mailto:controller-dev-bounces at lists.opendaylight.org] On Behalf Of Tyler Levine (tylevine)
Sent: 12 August, 2016 01:54
To: controller-dev at lists.opendaylight.org; mdsal-dev at lists.opendaylight.org
Subject: Re: [controller-dev] RPC implementation not found with Apache HttpClient

Hi All,

I've been continuing to work on my ODL application and I keep running into the issue detailed in my earlier post. Not only does it appear with Apache's http client library, but also I have discovered that it also appears with Square's OkHttp library and Google's GSON library (which is for JSON parsing, it should have nothing to do with RPCs or networking in general). However, using Java's native HttpUrlConnection to make HTTP requests does not trigger this issue.

I've updated my rpc-bug repository with examples to demonstrate this. They're in branches "bug3" and "bug4". You can find the repo here: https://github.com/tjlevine/rpc-bug

Since I've seen this problem appear when using 3 different libraries from 3 different vendors, I have to conclude that this is indeed an issue with ODL's RPC implementation.

If anyone can shed some light on what's going on here (or put me in touch with someone who can), it would be greatly appreciated. It's becoming difficult to continue to develop my application while having to reinvent the wheel all the time.

Thanks,
Tyler Levine

From: <controller-dev-bounces at lists.opendaylight.org<mailto:controller-dev-bounces at lists.opendaylight.org>> on behalf of Tyler Levine <tylevine at cisco.com<mailto:tylevine at cisco.com>>
Date: Wednesday, August 10, 2016 at 20:02
To: "controller-dev at lists.opendaylight.org<mailto:controller-dev at lists.opendaylight.org>" <controller-dev at lists.opendaylight.org<mailto:controller-dev at lists.opendaylight.org>>, "mdsal-dev at lists.opendaylight.org<mailto:mdsal-dev at lists.opendaylight.org>" <mdsal-dev at lists.opendaylight.org<mailto:mdsal-dev at lists.opendaylight.org>>
Subject: [controller-dev] RPC implementation not found with Apache HttpClient

Hi All,

I'm writing an Opendaylight application which receives RPCs and then uses Apache's HttpClient library to grab some data to return in the RPC output.

However, whenever I make reference to Request.Get(), the RPC call fails with a 501 Not Implemented HTTP response code and an error message:
{
  "errors": {
    "error": [
      {
        "error-type": "application",
        "error-tag": "operation-not-supported",
        "error-message": "No implementation of RPC AbsoluteSchemaPath{path=[(urn:opendaylight:params:xml:ns:yang:rpc-bug?revision=2015-01-05)noop]} available"
      }
    ]
  }
}

Notice how above I said "make reference", and not call. That's because this bug appears even when the method which calls Request.Get() is NOT CALLED. It appears even when you reference Request.Get() in another class which itself is not referenced nor instantiated (check out the bug2 branch for this variant).

Since I'm sure you're now thinking that this is outright impossible, I've generated a new ODL project using the startup archetype, and implemented a minimal noop RPC to demonstrate this issue.

You can clone it here: https://github.com/tjlevine/rpc-bug

Here's how to demonstrate the bug:
1) First, build the master branch. I used the following command: mvn clean install -DskipTests -Dmaven.javadoc.skip
2) Run karaf
3) Once the controller has come up, run the following cURL command:

curl -i -XPOST -H 'Authorization: Basic YWRtaW46YWRtaW4=' -H 'Content-Type: application/json' -d '{"input": {}}' 'http://localhost:8181/restconf/operations/rpc-bug:noop'

4) Notice that we get a 200 return code, and no content. The RPC was successful:

HTTP/1.1 200 OK
Set-Cookie: JSESSIONID=1glywbxn7t6mh1396kszy7jkdi;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Wed, 10-Aug-2016 02:11:24 GMT
Content-Type: application/yang.operation+json
Content-Length: 0
Server: Jetty(8.1.17.v20150415)

5) Now go checkout the branch called "bug"
6) Rebuild and run karaf again
7) Once the controller comes up, run the curl command above once again.
8) Notice that we get a 501 Not Implemented return code, and the error message which appears above:

HTTP/1.1 501 Not Implemented
Set-Cookie: JSESSIONID=14dvnl6re3iwcpstpdv707169;Path=/restconf
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Set-Cookie: rememberMe=deleteMe; Path=/restconf; Max-Age=0; Expires=Wed, 10-Aug-2016 02:17:44 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Server: Jetty(8.1.17.v20150415)

{"errors":{"error":[{"error-type":"application","error-tag":"operation-not-supported","error-message":"No implementation of RPC AbsoluteSchemaPath{path=[(urn:opendaylight:params:xml:ns:yang:rpc-bug?revision=2015-01-05)noop]} available"}]}}

9) Now go look at the diff between the master and the bug branches (I'll save you the trouble, it's right here):

tylevine at TYLEVINE-M-X247:~/src/odl/rpc-bug (bug) $ git diff master..bug
diff --git a/impl/pom.xml b/impl/pom.xml
index 3e95e92..f91e77a 100644
--- a/impl/pom.xml
+++ b/impl/pom.xml
@@ -29,6 +29,12 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <version>${project.version}</version>
     </dependency>

+    <dependency>
+      <groupId>org.apache.httpcomponents</groupId>
+      <artifactId>httpclient-osgi</artifactId>
+      <version>4.5.2</version>
+    </dependency>
+
     <!-- Testing Dependencies -->
     <dependency>
       <groupId>junit</groupId>
diff --git a/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java b/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java
index d89311a..a3243ed 100644
--- a/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java
+++ b/impl/src/main/java/org/opendaylight/impl/RpcBugProvider.java
@@ -8,6 +8,7 @@
 package org.opendaylight.impl;

 import java.util.concurrent.Future;
+import org.apache.http.client.fluent.Request;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpc.bug.rev150105.NoopInput;
@@ -30,9 +31,12 @@ public class RpcBugProvider {
         rpcProviderRegistry.addRpcImplementation(RpcBugService.class, new RpcBugService() {
             @Override
             public Future<RpcResult<NoopOutput>> noop(NoopInput input) {
-
                 return RpcResultBuilder.<NoopOutput>success().buildFuture();
             }
+
+            private void notCalled() {
+                Request.Get("http://google.com"<http://google.com%22>);
+            }
         });
     }

Now I hope you believe what I say is true :)

This leads me to a few questions:

  1.  Can you reproduce this? I have reproduced this on my local machine as well as in a VM running ubuntu 16.04.
  2.  Is this actually a bug? Or is there something I'm missing here that leads this to be a desired behavior?
  3.  If this is a bug, is it a bug in Apache's http client library or in MDSAL's RPC implementation?
  4.  What is the root cause of this rather unusual problem (speculation here is acceptable)? Is there any workaround that would allow me to use Apache's http client and MDSAL RPCs in the same project?

Thanks as always,
Tyler Levine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opendaylight.org/pipermail/controller-dev/attachments/20160812/2410cf59/attachment-0001.html>


More information about the controller-dev mailing list