• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in running JNI with in servlet

 
Swaroop Reddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am doing POC on JNI calling Native methods from servlet.The code I am posting here had worked fine for stand alone application,but when i work it out in servlet its giving an
java.lang.UnsatisfiedLinkError:


Please find my code below
1.
I am making this as a jar file to call it from servlet for ease use

2.

and finally in my servlet class I am calling the jar file created above at using prog1.java
3.my servlet file(giving only the method used in servlet)


but after running the servlet I am getting an error

java.lang.UnsatisfiedLinkError: sum
at prog.prog1.sum(Native Method)
at prog.prog1.Sum(prog1.java:25)
at prog1.main(prog1.java:27)


I refered the forums they are saying like put the dll in java.library path
my library path is
C:\j2sdk1.4.2_04\bin;.;C:\WINDOWS\system32;C:\WINDOWS;D:\Oracle\product\10.1.0\
Client_2\bin;D:\Oracle\product\10.1.0\Client_2\jre\1.4.2\bin\client;D:\Oracle\
product\10.1.0\Client_2\jre\1.4.2\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\
System32\Wbem;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\
Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;
C:\j2sdk1.4.2_04\bin;C:\j2sdk1.4.2_04\bin\include;C:\j2sdk1.4.2_04\bin\include\win32;
C:\J2SDK1.4.2_04\BIN


where should i include my prog1.dll file

Please help me to resolve the problem ,no specific data though googled,
thank you in prior
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DLL is not getting loaded. The system property to refer is java.library.path. That usually solves the problem.

Debug just before you load the library and use the Display view in eclipse to obtain the java.library.path value. Check if this contains the directory where your DLL resides. Try a System.loadLibrary() in the Display view after this is done.
 
Swaroop Reddy
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:The DLL is not getting loaded. The system property to refer is java.library.path. That usually solves the problem.
Debug just before you load the library and use the Display view in eclipse to obtain the java.library.path value. Check if this contains the directory where your DLL resides. Try a System.loadLibrary() in the Display view after this is done.




Hi,I checked the same as you specified still it is giving same error.I got the library path and added my dll to that path ,but still its giving same error
java.lang.UnsatisfiedLinkError: (method name)


Please any one can solve my problem
 
krish rajini
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add your .dll file in System32 folder

or anyother folder if you want.But if you use some other folder

try inserting the complete absolute path of the file.

In System.load("absolute path");

first do the console JNI application .

Then later add the servlet packages and doGet functions.

do the same procedure what you have done with console application.

except copy the .class servlet file in WEB-INF/classes folder.

check your web.xml file also.

if this all done correctly.It should work .

i tried with apache tomcat 6.0.20
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic