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

Gustavo Martin updated SUBMARINE-487:
-------------------------------------
    Description: 
In order to create an 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]

The native library used by 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}



  was:
In order to create an uber jar, Java packages must be renamed. Renaming 
packages make 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]

The native library used by 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}




> 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
>
> In order to create an 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]
> The native library used by 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to