2017-10-09 123 views
0

由于依赖关系的冲突,我想遮罩io.netty。在着色之后,本地ssl库(netty-tcnative-boringssl-static)的加载停止工作。遮光后io.netty tcnative停止工作

主要POM

我主要POM具有这种依赖性:

... 
<dependency> 
    <groupId>com.example.myapp</groupId> 
    <artifactId>pubsub-library<artifactId> 
    <version>1.0</version> 
</dependency> 
... 

图书馆,做阴影

PubSub的库POM是这样的:

... 
<dependency> 
    <groupId>com.google.cloud</groupId> 
    <artifactId>google-cloud-pubsub</artifactId> 
    <version>0.24.0-beta</version> 
<dependency> 
... 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-shade-plugin</artifactId> 
    <version>3.1.0</version> 
    <executions> 
     <execution> 
      <phase>package</phase> 
      <goals> 
       <goal>shade</goal> 
      </goals> 
      <configuration> 
       <relocations> 
        <relocation> 
         <pattern>io.netty</pattern> 
          <shadedPattern>com.example.myapp.shaded.io.netty</shadedPattern> 
        </relocation> 
       </relocations> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
... 

的发布订阅具有这3个依存关系:io.netty:netty-codec-http2:jar:4.1.14.Finalio.netty:netty-handler-proxy:jar:4.1.14.Finalio.netty:netty-tcnative-boringssl-static:jar:2.0.3.Final

错误

,就会出现问题,当io.netty.util.internal.NativeLibraryLoader尝试加载本地库。它给了我错误,如:

17:44:48.230 [main] DEBUG com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader - -Dio.netty.tmpdir: /var/folders/ll/wy1vgf8945l_87mpfc9ylb94fglr7d/T (java.io.tmpdir) 
17:44:48.230 [main] DEBUG com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader - -Dio.netty.native.workdir: /var/folders/ll/wy1vgf8945l_87mpfc9ylb94fglr7d/T (io.netty.tmpdir) 
17:44:48.241 [main] DEBUG com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader - Unable to load the library 'com.example.myapp-shaded-netty-tcnative-osx-x86_64', trying other loading mechanism. 
java.lang.UnsatisfiedLinkError: no com.example.myapp-shaded-netty-tcnative-osx-x86_64 in java.library.path 
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867) 
    at java.lang.Runtime.loadLibrary0(Runtime.java:870) 
    at java.lang.System.loadLibrary(System.java:1122) 
    at com.example.myapp.shaded.io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38) 
    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:498) 
    at com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:311) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:303) 
    at com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:291) 
    at com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:224) 
    at com.example.myapp.shaded.io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:172) 
    at com.example.myapp.shaded.io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:423) 
    at com.example.myapp.shaded.io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:91) 
    at com.example.myapp.job.audit.GoogleCloudCompatChecker.check(GoogleCloudCompatChecker.java:30) 
    at com.example.myapp.job.audit.AuditJobMain.main(AuditJobMain.java:8) 

我看过里面的主要生成的罐子里。没有本地库匹配该名称。这是在META-INF /本地目录内:

libnetty-tcnative-linux-x86_64.so 
libnetty-tcnative-osx-x86_64.jnilib 
libnetty-transport-native-epoll.so 
linux32 
linux64 
netty-tcnative-windows-x86_64.dll 
osx 
windows32 
windows64 

我在做什么错?如何在不破坏购物的情况下遮阳伞。

回答

0

看看NativeLibraryLoader source

这可能不是你使用相同的版本,但它表示,它使用几个启发式找到本机库和最propably这些启发式失败遮荫,但可能很容易修复

认真研究代码也许重写/调试/记录NativeLibraryLoader。

你是否被迫使用一些依赖库的两个版本,以便你不能只使用maven排除?