You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by "Liu Xun (Jira)" <ji...@apache.org> on 2020/05/04 13:38:00 UTC

[jira] [Resolved] (SUBMARINE-487) submarine-spark-security: JNA does not work in uber jar

     [ https://issues.apache.org/jira/browse/SUBMARINE-487?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Liu Xun resolved SUBMARINE-487.
-------------------------------
    Fix Version/s: 0.5.0
       Resolution: Fixed

Issue resolved by pull request 273
[https://github.com/apache/submarine/pull/273]

> submarine-spark-security: JNA does not work in uber jar
> -------------------------------------------------------
>
>                 Key: SUBMARINE-487
>                 URL: https://issues.apache.org/jira/browse/SUBMARINE-487
>             Project: Apache Submarine
>          Issue Type: Bug
>          Components: Security
>            Reporter: Gustavo Martin
>            Assignee: Gustavo Martin
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 0.5.0
>
>
> In order to create a uber jar, Java JNA packages are being renamed. Renaming JNA packages makes JNI fail.
>  
>  1. ranger-plugins-common requires JNA through com.kstruct:gethostname4j
>      See the following code: [https://github.com/apache/ranger/blob/release-ranger-2.0.0/agents-common/src/main/java/org/apache/ranger/plugin/util/RangerRESTUtils.java#L83]
> 2. gethostname4j uses JNA, through net.java.dev.jna:jna
>      See the followingcode: [https://github.com/mattsheppard/gethostname4j/blob/master/src/main/java/com/kstruct/gethostname4j/Hostname.java#L30]
> 3. net.java.dev.jna:jna uses JNI
>      See the following code: [https://github.com/java-native-access/jna/blob/master/src/com/sun/jna/Native.java#L1018]
> 4. The native library used by net.java.dev.jna:jna is libjnidispatch.so.
>      libjnidispatch.so was compiled with the package com.sun.jna (example for linux-x86-64):
> {noformat}
> readelf -aW libjnidispatch.so | grep Java_com_sun_jna_Native_getNativeVersion
>    178: 000000000000bde0    24 FUNC    GLOBAL DEFAULT   12 Java_com_sun_jna_Native_getNativeVersion
>    227: 000000000000bde0    24 FUNC    GLOBAL DEFAULT   12 Java_com_sun_jna_Native_getNativeVersion
> {noformat}
>  
> Because maven-shade-plugin is renaming JNA packages, JNA fails when trying to call the native method getNativeVersion (which is always called when using JNA for the first time):
> {noformat}
> Exception in thread "HiveServer2-Handler-Pool: Thread-81" java.lang.UnsatisfiedLinkError: submarine_spark_ranger_project.com.sun.jna.Native.getNativeVersion()Ljava/lang/String;
>     at submarine_spark_ranger_project.com.sun.jna.Native.getNativeVersion(Native Method)
>     at submarine_spark_ranger_project.com.sun.jna.Native.<clinit>(Native.java:197)
>     at submarine_spark_ranger_project.com.kstruct.gethostname4j.Hostname$UnixCLibrary.<clinit>(Hostname.java:12)
>     at submarine_spark_ranger_project.com.kstruct.gethostname4j.Hostname.getHostname(Hostname.java:30)
>     at org.apache.ranger.plugin.util.RangerRESTUtil
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org