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

[jira] [Comment Edited] (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:comment-tabpanel&focusedCommentId=17098125#comment-17098125 ] 

Gustavo Martin edited comment on SUBMARINE-487 at 5/2/20, 10:59 PM:
--------------------------------------------------------------------

By the way, perhaps it would be better to stop using uber jar and include the required libraries in the same way as it is done over here: [https://github.com/apache/submarine/blob/master/submarine-dist/src/assembly/distribution.xml]

 

I could create a new PR with the required changes for using this project [https://github.com/apache/submarine/blob/master/submarine-dist/pom.xml] instead of the current uber jar.


was (Author: gumartinm):
By the way, perhaps it would be better to stop using uber jars and include the required libraries in the same way as it is done over here: [https://github.com/apache/submarine/blob/master/submarine-dist/src/assembly/distribution.xml]

 

I could create a new PR with the required changes for using this project [https://github.com/apache/submarine/blob/master/submarine-dist/pom.xml] instead of the current uber jar.

> 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
>            Priority: Major
>              Labels: pull-request-available
>
> In order to create a uber jar, Java packages must be renamed. Renaming 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 renames 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