incubator-s4-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "唐装鼠" <654125...@qq.com>
Subject 回复: 回复: jni error
Date Tue, 09 Jul 2013 02:25:36 GMT
Hello,I don't think it is permission problem.My testing is below:
Shellcode is a class which uses jni.
First,I build Calling.java which call Shellcode Class.The code is below:
--------------------------------------------------------------------------------------------------------------------------------
class Shellcode {
    public native void checkShellcode(String filename);
    public native int checkShellcode(byte[] payload,int length,int[] array);
}
public class Calling {

    /**
     * @param args
     */
    public static void main(String[] args) {
        System.load("/root/s4share/shellcode/build/libshellcode.so");
        Shellcode sc=new Shellcode();
        sc.checkShellcode("/root/ehualu.jar");
    }

}




----------------------------------------------------------------------------------------------------------------------------------
Then javac Calling.java to produce Calling.class.Next,java Calling to run.And it works well.


Second,I copy it to S4 examples by only modifying the HelloPE class.The code is below:
-------------------------------------------------------------------------------------------------------------------------------
package hello;

import org.apache.s4.base.Event;
import org.apache.s4.core.ProcessingElement;
class Shellcode {
    public native void checkShellcode(String filename);
    public native int checkShellcode(byte[] payload,int length,int[] array);
}
public class HelloPE extends ProcessingElement {
        public void onEvent(Event event) {
        // in this example, we use the default generic Event type, by you can also define
your own type
        System.load("/root/s4share/shellcode/build/libshellcode.so");
        Shellcode sc=new Shellcode();
        sc.checkShellcode("/root/ehualu.jar");
    }

    @Override
    protected void onCreate() {
    }

    @Override
    protected void onRemove() {
    }

}


-------------------------------------------------------------------------------------------------------------------------------------


Runing,then errors come out:


 09:59:14.418 [names] ERROR org.apache.s4.core.S4Node - Uncaught exception in thread names
java.lang.UnsatisfiedLinkError: hello.Shellcode.checkShellcode(Ljava/lang/String;)V
    at hello.Shellcode.checkShellcode(Native Method) ~[myApp.jar:unspecified]
    at hello.HelloPE.onEvent(HelloPE.java:41) ~[myApp.jar:unspecified]
    at OverloadDispatcher2912.dispatchEvent(Unknown Source) ~[na:na]
    at org.apache.s4.core.ProcessingElement.handleInputEvent(ProcessingElement.java:461) ~[s4-core-0.6.0-incubating.jar:0.6.0-incubating]
    at org.apache.s4.core.Stream$StreamEventProcessingTask.run(Stream.java:333) ~[s4-core-0.6.0-incubating.jar:0.6.0-incubating]
    at org.apache.s4.comm.staging.BlockingThreadPoolExecutorService$RunnableWithPermitRelease.run(BlockingThreadPoolExecutorService.java:178)
~[s4-comm-0.6.0-incubating.jar:0.6.0-incubating]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) ~[na:1.7.0_25]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) ~[na:1.7.0_25]
    at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]




God help me!
I think there must be some differences between S4 loading libraries and system loading libraries.
Help!!! 
------------------ 原始邮件 ------------------
发件人: "Matthieu Morel"<mmorel@apache.org>;
发送时间: 2013年7月9日(星期二) 凌晨1:41
收件人: "s4-user"<s4-user@incubator.apache.org>; 

主题: Re: 回复: jni error





According to the java API doc, UnsatisfiedLinkError means the JVM cannot find the specified
file. If it cannot read the file, either the file does not exist or the jvm does not have
proper permission. So: is that file available and readable on the host you are running S4,
for the user running the S4 node process?


Matthieu  



On Jul 8, 2013, at 11:13 , 唐装鼠 <654125993@qq.com> wrote:

Yes.I load the native library.I used System.load().The java code is showed as below:


 public class Shellcode {
   static 
    { 
         try 
         { 
           System.load("/root/s4share/shellcode/build/libshellcode.so"); 
       }  catch (Exception e) {
           e.printStackTrace();
       } 
     } 
    public native void checkShellcode(String filename);
    public native int checkShellcode(byte[] payload,int length,int[] array);
    /**
     * @param args
     */
    public static void main(String[] args) {
       Shellcode sc=new Shellcode();
       sc.checkShellcode("/root/test.txt");
    }

}






I tested the class and it works well.
I can't understand.Why it can not work in s4 while it can work well in terminal.
Help!


------------------ 原始邮件 ------------------
发件人: "Matthieu Morel"<matthieu@yahoo-inc.com>;
发送时间: 2013年7月8日(星期一) 下午4:54
收件人: "<s4-user@incubator.apache.org>"<s4-user@incubator.apache.org>; 

主题: Re: jni error



Hi,

with merely the stacktrace it is difficult to make any diagnostic.

How are you loading/embedding the native library? Is it embedded in the S4R archive (you'd
probably need some customization here)?

Is this possible to reproduce, and how?

Regards,

Matthieu

On Jul 8, 2013, at 10:42 , 唐装鼠 <654125993@qq.com> wrote:

> Hi,it looks like S4 has problem when loading libraries.
> I use JNI in my project.When call the native method,errors come out as below:
> 
> 16:31:52.626 [atos] ERROR org.apache.s4.core.S4Node - Uncaught exception in thread atos
> java.lang.UnsatisfiedLinkError: hello.Shellcode.checkShellcode(Ljava/lang/String;)V
>     at hello.Shellcode.checkShellcode(Native Method) ~[qqApp.jar:unspecified]
>     at hello.ShellcodeCheckPE.onEvent(ShellcodeCheckPE.java:106) ~[qqApp.jar:unspecified]
>     at OverloadDispatcher709.dispatchEvent(Unknown Source) ~[na:na]
>     at org.apache.s4.core.ProcessingElement.handleInputEvent(ProcessingElement.java:461)
~[s4-core-0.6.0-incubating.jar:0.6.0-incubating]
>     at org.apache.s4.core.Stream$StreamEventProcessingTask.run(Stream.java:333) ~[s4-core-0.6.0-incubating.jar:0.6.0-incubating]
>     at org.apache.s4.comm.staging.BlockingThreadPoolExecutorService$RunnableWithPermitRelease.run(BlockingThreadPoolExecutorService.java:178)
~[s4-comm-0.6.0-incubating.jar:0.6.0-incubating]
>     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
~[na:1.7.0_25]
>     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
~[na:1.7.0_25]
>     at java.lang.Thread.run(Thread.java:724) ~[na:1.7.0_25]
> 
> Could anyone help me?

.
Mime
View raw message