2017-10-09 8 views
0

En raison d'un conflit dans les dépendances, je veux nuancer io.netty. Après l'ombrage, le chargement des bibliothèques ssl natives (netty-tcnative-boringssl-static) cesse de fonctionner.Après l'ombrage io.netty tcnative arrête de fonctionner

principal pom

Mon principal pom a cette dépendance:

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

Library qui fait la trame de fond

La pom PubSub bibliothèque est comme ceci:

... 
<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> 
... 

le PubSub a ces 3 dépendances: io.netty:netty-codec-http2:jar:4.1.14.Final, io.netty:netty-handler-proxy:jar:4.1.14.Final et io.netty:netty-tcnative-boringssl-static:jar:2.0.3.Final

erreur

Le problème se pose lorsque io.netty.util.internal.NativeLibraryLoader tente de charger la bibliothèque native. Il me donne des erreurs telles que:

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) 

J'ai regardé à l'intérieur du pot généré par le pom principal. Et aucune bibliothèque native ne correspond à ce nom. Cela se trouve dans le répertoire META-INF/native:

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 

Qu'est-ce que je fais mal? Comment puis-je ombrer io.netty sans casser le tcnatif.

Répondre

0

Jetez un oeil à la NativeLibraryLoader source.

Cela pourrait ne pas être la même version que vous utilisez, mais il indique qu'il utilise quelques heuristiques pour trouver les bibliothèques natives et les plus propably ces heuristiques échouent sur l'ombre, mais peut-être facile à corriger

étudier attentivement le code et peut-être remplacer/déboguer/consigner NativeLibraryLoader.

Etes-vous obligé d'utiliser deux versions de certaines bibliothèques de dépendances de sorte que vous ne pouvez pas utiliser uniquement des exclusions maven?