1

I have written an API Man plugin which uses com.squareup.okhttp3:okhttp:3.11.0 as a dependency, this has a transient dependency on com.squareup.okio:okio:jar:1.14.0. However it appears Wildfly (10.1.0.Final) is using a different version off this com.squareup.okio:okio:jar:1.4.0, as a result I am getting the following exception.

java.lang.NoSuchMethodError: okio.BufferedSource.readUtf8LineStrict(J)Ljava/lang/String;
   at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
   at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
   at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
   at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)

To try and get around this I have included the following jboss-deployment-structure.xml in my projects src/main/webapp/WEB-INF directory

<jboss-deployment-structure>
  <deployment>
    <!-- Exclusions allow you to prevent the server from automatically adding
      some dependencies -->
    <exclusions>
      <module name="okio" />
    </exclusions>
  </deployment>
</jboss-deployment-structure>

It doesn't seem to have resolved it however

PDStat
  • 5,513
  • 10
  • 51
  • 86

1 Answers1

2

To avoid dependency load from wildly you need to add an exclusion. The exclusion you added is incorrect

<exclusions>
  <module name="com.squareup.okhttp3" /> ///Correct exclusion
</exclusions>

Also if you are using classes related to above dependency in your code then provide these jar files externally in your classpath/lib folder of deployable. Add below two jars in your lib folder.

  1. okhttp-3.x.x.jar
  2. okio-1.x.x.jar
Abhijeet
  • 4,069
  • 1
  • 22
  • 38