Yeah,Hi Wade., Thank you very much! I can pass the System.loadlibrary method...while calling my method only i'm getting error. Actually i did copy the dill to winnt/system32 and jre/bin folder. Dll accessing java code i recompiled with new jdk.
So i'm in right way right? what will be issue in my case..
Thanks.,
MALAI
----- Original Message ----- From: "Wade Chandler" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Friday, April 23, 2004 2:37 PM
Subject: Re: Accessing Dll's
Wade Chandler wrote:
armalai_uk wrote:
Hi., This code has been written in JDK 1.3.0_03 couple of years back and
i
implemented in JRun 3.1 Now i'm trying to use this same code in Tomcat 4.1 with J2SDK
1.4.2_03.
According to your previos mail i understand that i have to rewrite the code using J2SDK 1.4.2 specifications. Is it correct? Can you please give me the steps that i have to do inorder to make my code compatible to 1.4.2..
Thanks., MALAI ----- Original Message ----- From: "Wade Chandler" <[EMAIL PROTECTED]> To: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Friday, April 23, 2004 12:52 AM Subject: Re: Accessing Dll's
Wade Chandler wrote:
Annamalai Ramasamy wrote:
Hi., Yes,I did see my dll path using this line.
Thanks., MALAI Ryan Lissack <[EMAIL PROTECTED]> wrote: Hi,
Execute the following :
System.out.println(System.getProperty("java.library.path"));
See what directories are there. If the one(s) with your DLL(s) are
not
//--------------------------------------------------------------------------listed you can add them as a startup param to the VM using the -D
option
(java -Djava.library.path=.....)
HTH
Regards, Ryan.
-----Original Message----- From: Annamalai Ramasamy [mailto:[EMAIL PROTECTED] Sent: 22 April 2004 16:33 To: Tomcat Users List Subject: RE: Accessing Dll's
Hi., Check my below java code. I do not have native source codes.
I'm sure there is no version conflicts. But i have copied the dll in more than one places..like winnt, system32 and jre/bin like that.
any idea?
public class AddressValidate {
private Address inad; private Address outad; private String usercompany;
public StringBuffer csReturnErrorMsg; public StringBuffer csReturnStreet; public StringBuffer csReturnCityName; public StringBuffer csReturnCounty; public StringBuffer csReturnState; public StringBuffer csReturnZip; //To load DLL AvsWebInrterface static{ try{ System.loadLibrary("AvsWebInterface"); System.out.println("DLL Loaded"); }catch(Exception e){ System.err.println("Could not load DLL \"AvsWebInterface \" : "+e.toString()); System.out.println("Could not load DLL \"AvsWebInterface \" : "+e.toString());
}catch(Throwable e){ System.err.println("Could not load DLL \"AvsWebInterface:\" "+e.toString()); System.out.println("Could not load DLL \"AvsWebInterface:\" "+e.toString()); } } //end of static
-
//Native method implemented in cpp public native String JAVAAVSValidate (String company, String street1, String city, String state, String zip, StringBuffer csReturnStreet, StringBuffer csReturnCityName, StringBuffer csReturnCounty, StringBuffer csReturnState, StringBuffer csReturnZip, StringBuffer csReturnErrorMsg)
;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
- public AddressValidate(){ inad=null; outad=null; usercompany=new String("");
}
- public String validate (Address inad,Address outad){ csReturnStreet=new StringBuffer(""); csReturnCityName=new StringBuffer(""); csReturnCounty=new StringBuffer(""); csReturnState=new StringBuffer(""); csReturnZip=new
StringBuffer("");
csReturnErrorMsg=new StringBuffer(""); this.inad=inad; this.outad=outad;
try{ // System.out.println("Street1 :"+inad.Street1); // System.out.println("city :"+inad.City); // System.out.println("state :"+inad.State); // System.out.println("postalcode"+inad.PostalCode);
JAVAAVSValidate (usercompany, inad.Street1, inad.City, inad.State, inad.PostalCode, csReturnStreet, csReturnCityName, csReturnCounty, csReturnState, csReturnZip, csReturnErrorMsg); outad.Street1 = csReturnStreet.toString(); outad.City = csReturnCityName.toString(); outad.County =
csReturnCounty.toString();
outad.State = csReturnState.toString(); outad.PostalCode = csReturnZip.toString(); // System.out.println("Street1
:"+outad.Street1);
// System.out.println("city :"+outad.City); // System.out.println("state :"+outad.State); // System.out.println("postalcode"+outad.PostalCode);
}catch(Exception e){ System.out.println("Error in Validating Address " + e.toString()); }
return (csReturnErrorMsg.toString()); }
}
Peter Guyatt wrote: Hi There,
Can I see you native code and your class that declares you native methods.
Thanks
Pete
-----Original Message----- From: Mark Schmeets [mailto:[EMAIL PROTECTED] Sent: 22 April 2004 16:13 To: Tomcat Users List Subject: Re: Accessing Dll's
Hi, Is it possible that this dll is being loaded somewhere else in your instance? My experience with this error came from trying to use the Oracle native JDBC drivers. It usually came down to one of three issues, first
that
the dll couldn't be "found", second that another web-app had already loaded it, third it was a dll versioning problem. Hope it helps.
Mark
Annamalai Ramasamy wrote:
Hi., Again same error. I did put the dll to /jre/bin and winnt/system32. Any other ideas please... Thanks., MALAI
Hans Wichman wrote: sorry, i meant lib\bin\ instead of lib\ext\
grtz Sorv
At 03:43 PM 4/22/2004 +0100, Annamalai Ramasamy wrote:
Hi., Again Same Error.. Actually after the System.loadlibrary..i can able to see my system.out.println values. Then while trying to call my method i'm getting
UnsatishfiedLinkError.
Thanks., MALAI
Hans Wichman wrote: try putting them in the lib/ext folder of your j2sdk1.4.2_03
folder.
grtz Sorv
At 03:24 PM 4/22/2004 +0100, Annamalai Ramasamy wrote:
Hi., I'm using Tomcat4.0.29 with J2SDK 1.4.2_03. I have my native libraries(dll's) in winnt folder. I'm loading the dll thru System.loadlibrary and accessing the
methods.
I'm getting UnsatishfiedLinkError. My class files are in my web-inf classes directory. In forums i searcehed, and i tried out all possibility like setting path and changing my classes to common/classes and all. Please give me your suggestions... Thanks., MALAI
--------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends
today!
--------------------------------------------------------------------Download Messenger Now
-
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
--------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:
[EMAIL PROTECTED]
--------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends
today!
Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends
today!
Download Messenger Now
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------- Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now
This may sound like a strange question, though I have not seen it asked. Are you using JNI? You have to use JNI to be able to access the methods. The library could load fine, but the DLL still not be
found.
Also, did you use javah to create your h file? If not this is your problem. You have a special set of entry points so the C code can be used by the java code. C++ name mangling causes issues, and the JNI has a special way it looks for method names. If you are not using JNI
you
can look it up in the latest java docs.
Wade
I meant the library could load fine and the methods still not be found in the dll. This is because of the naming conventions.
Wade.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
The spec did change, but not enough to cause incompatibilties with old code. There were some new invocation methods created and I think that was basically the gist of the changes. The same exact code should work fine. Did you recompile your lib? Just to make sure something wasn't going on? Also, I think someone else already mentioned this, but if you changed the java classpath then you would get the unsatisfied link error. I hope that helps.
One other thing. Obviously it is loading your library or you would get an exception on the loadLibrary call. So it definitely has to do with it not finding the method inside the library. You don't have multiple copies do you? Maybe it's loading a lib you don't know about? Windows searches the path and then uses the first one it finds.
Wade
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
First one it finds meaning first file it finds....I've got to get into better habits.
;-)
-- Wade Chandler Red-e Set Grow, LLC Phone: 336-777-0075 x1705 Email: [EMAIL PROTECTED] www.redesetgrow.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
I would delete the one from the jre/bin. For no reason other than to not have two of them out there...you'll change one and forget about the other one.
If the code passes the loadLibrary call without exception then it is finding the library file. If you only get the error at method call time then that means it can't find the method with the correct signature in the file (more than likely) depends on the JVMs and things like that.
Also, I would recompile my C code including the Sun header files and lib file from your current jdk. Maybe the JRun libs had something different going on. I'm not sure, but to be sun certified they had to be standard and JNI (surely). Did you generate your headers using javah? I've not used JRun, so don't know the vms they had ... was it a sun jdk? Either way, you may or may not find the issue at compile time this way...
My guess is that it is linking your file. Do you have a logging mechanism on your c/c++ side? If so then output some log messages from your DllMain method. This way you can tell when it is loading at least. If you don't have a logging mechanism. Include the windows.h file from your dll and (MS VC++ 6.0 code)
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { ::MessageBox(NULL, "Actually attaching the library", "Testing load", MB_OK); }//end if DLL...ATTACH }//end DllMain
If you get that popup then you know it has loaded your lib through Windows. Thus it means you have something wrong with the method signature...name counts in this use of the word "signature".
Did you change the package names perhaps in your java code or anything? for instance lets say I have a package
com.redesetgrow.util.TestNative
with
public native void showNativeMessage(String message, String caption);
then I must have (unless using a specialized VM)
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_redesetgrow_util_TestNative
* Method: showNativeMessage
* Signature: (Ljava/lang/String;Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_redesetgrow_util_TestNative_showNativeMessage
(JNIEnv * env, jobject o, jstring message, jstring caption)
{
const char* cmsg = env->GetStringUTFChars(message, 0);
const char* ccap = env->GetStringUTFChars(caption, 0);
::MessageBox(NULL, cmsg, ccap, MB_OK);
env->ReleaseStringUTFChars(message, cmsg);
env->ReleaseStringUTFChars(caption, ccap);
}
#ifdef __cplusplus } #endif
If I put this and the DllMain method here in a dll they will produce the two message boxes. So, that is one quick way for you to see quickly whether or not the lib is loading or not.
You could do something similar just to test your VM and make sure you're able to make the calls. I would run javah against my class file I'm trying to use. Then compare that H files method signatures to the ones in your current code. If there is an issue that will show you that.
Those are about the only answers I have to throw at you. Good luck and hope that helps you out a bit.
Wade
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]