Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JVM and shared libraries

Reply
Thread Tools

JVM and shared libraries

 
 
Dave Neary
Guest
Posts: n/a
 
      06-09-2004
Hi all,

I have a Java applet which uses some JNI stuff to interract with a scanner.

The basic way things are is:

java -> call sane stuff
sane.jar -> loadLibrary(sanej)
sanej.dll contains the jni wrapper stuff around sane.dll

On windows, sanej.dll is in jre/bin, and sane.dll is on the system PATH
(in c:\sane). On linux, libsanej.so is in jre/lib/i386, and libsane.so is
in /usr/local/lib, which is in the system ld.so search path.

When I run the applet as an application (calling the constructor, init,
start, etc manually in the main method) all goes well, I get a scan.

When I load the applet in a browser on Windows, however, it all goes
pear-shaped and the browser dies without a trace.

On Linux, the same applet works fine.

The questions, then, are
1) How can I get more information about what's going wrong on windows?
I assume that the problem is that sane.dll isn't being found when a
function in the library is called. What search mechanism will be used to
search for sane.dll? I have also tried putting sane.dll in jre/bin,
without success.

2) Anyone know how to fix it and make everything better?

Thanks a lot,
Dave.

 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      06-09-2004
On 09 Jun 2004 17:13:02 GMT, Dave Neary <>
wrote or quoted :

>When I load the applet in a browser on Windows, however, it all goes
>pear-shaped and the browser dies without a trace.


I hope your Applet was signed, required to use JNI.

Try using load instead of loadlibrary. Your path may not be what you
think.

Use Wassup to find out what your path really is when you are in the
browser.

See http://mindprod.com/wassup.html

Then make sure your dll in on THAT path.

This sort of thing can drive you round the bend.

Consider Java Web Start which automatically installs your dlls on the
path.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
 
ALR
Guest
Posts: n/a
 
      06-09-2004
Hi Dave

You can try to open the java console (option somewhere in the browser's
menu ), so the stack trace (if any) could be printed.
You can also write some additional stuff to start your application in a
frame (your application could be run in the browser or outside)
and start java.exe in a C debugger to debug your dll by setting some
parameters in the command line of your debugger.

Regards
Alain

"Dave Neary" <> a écrit dans le message de news:
ldomain...
> Hi all,
>
> I have a Java applet which uses some JNI stuff to interract with a

scanner.
>
> The basic way things are is:
>
> java -> call sane stuff
> sane.jar -> loadLibrary(sanej)
> sanej.dll contains the jni wrapper stuff around sane.dll
>
> On windows, sanej.dll is in jre/bin, and sane.dll is on the system PATH
> (in c:\sane). On linux, libsanej.so is in jre/lib/i386, and libsane.so is
> in /usr/local/lib, which is in the system ld.so search path.
>
> When I run the applet as an application (calling the constructor, init,
> start, etc manually in the main method) all goes well, I get a scan.
>
> When I load the applet in a browser on Windows, however, it all goes
> pear-shaped and the browser dies without a trace.
>
> On Linux, the same applet works fine.
>
> The questions, then, are
> 1) How can I get more information about what's going wrong on windows?
> I assume that the problem is that sane.dll isn't being found when a
> function in the library is called. What search mechanism will be used to
> search for sane.dll? I have also tried putting sane.dll in jre/bin,
> without success.
>
> 2) Anyone know how to fix it and make everything better?
>
> Thanks a lot,
> Dave.
>



 
Reply With Quote
 
Dave Neary
Guest
Posts: n/a
 
      06-10-2004
Hi,

In article <40c77752$0$17194$>, ALR wrote:
> You can try to open the java console (option somewhere in the browser's
> menu ), so the stack trace (if any) could be printed.


Thanks for the tip. As I said, though, the browser and the jvm crash and
burn completely on the error. There is no stack trace to view, because
the java console window disappears on me.

> You can also write some additional stuff to start your application in a
> frame (your application could be run in the browser or outside)
> and start java.exe in a C debugger to debug your dll by setting some
> parameters in the command line of your debugger.


I have added lots of traces to my code, so I know that the problem occurs
when the native method is called. I'm not sure where in that method the
problem is though.

And as I said, when I run it as an application, there is no problem.

Thanks for your tips, though.

Cheers,
Dave.

 
Reply With Quote
 
Dave Neary
Guest
Posts: n/a
 
      06-10-2004
Hi Roedy,

In article <>, Roedy Green wrote:
> I hope your Applet was signed, required to use JNI.


It is indeed.

> Try using load instead of loadlibrary. Your path may not be what you
> think.
>
> Use Wassup to find out what your path really is when you are in the
> browser.


Indeed, jre/bin was not on the path, and java.library.path gets the system
path. I moved the dlls all into the one directory, on the path, but the
results were identical.

> This sort of thing can drive you round the bend.


Tell me about it

> Consider Java Web Start which automatically installs your dlls on the
> path.


Unfortunately, this is a client constraint (*must* be web, *must* look
like a normal web page) - the applet is in the page header, and provides
an API for its actions which get called by javascript on the buttons in
the page.


Thanks for the help,
Dave.

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-10-2004
On 10 Jun 2004 13:54:30 GMT, Dave Neary <>
wrote or quoted :

>Indeed, jre/bin was not on the path, and java.library.path gets the system
>path. I moved the dlls all into the one directory, on the path, but the
>results were identical.


You have a nightmare here. You have no control over how each user
sets up his path or how every browser on earth does it. You have to
get that dll somewhere on HIS path.

Check the path. There should be no ;; in it.

I found further that Netscape insisted the DLL be installed BEFORE
Netscape even started or it would not recognise it.

I went through this with Setclock and eventually gave up and turned it
into a JWS application. See http://mindprod.com/jgloss/setclock.html

I'd say your best bet is to put the dll in some standard place and use
load rather than loadlibrary to find it.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-10-2004
On Thu, 10 Jun 2004 14:10:22 GMT, Roedy Green
<look-> wrote or quoted :

>
>I found further that Netscape insisted the DLL be installed BEFORE
>Netscape even started or it would not recognise it.


Java should be fixed so that load also looks in the jar for the DLL.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
alr
Guest
Posts: n/a
 
      06-10-2004
Hi
If you want to live dangerously you can try to run IE in the debugger, as
the jvm is an activex, I think it should work...

> And as I said, when I run it as an application, there is no problem.



 
Reply With Quote
 
Dave Neary
Guest
Posts: n/a
 
      06-11-2004
Hi,

In article <>, Roedy Green wrote:
> You have a nightmare here. You have no control over how each user
> sets up his path or how every browser on earth does it. You have to
> get that dll somewhere on HIS path.


I caught a break on this, I found a hs_err_pidXXXX.log file (god knows why
I didn't see them earlier, there is a bunch of them) which gives me the
answer to why IExplorer crashes.

The dlls with the JNI bindings are installed and found fine, as is
sane.dll. The problem is in cygwin1.dll/ Here's the first few lines of the
log file I mentioned above:

An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at
PC=0x61044A01
Function=getservbyname+0xC1
Library=c:\sane\cygwin1.dll

Current Java thread:
at org.sane.Sane.getNumberOfDevices(Native Method)
at com.phenix.framework.scan.ScanApplet.init(ScanAppl et.java:227)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:534)

Does this mean that cygwin1.dll doesn't have the necessary permissions to
make the system call, or that there is a bug in cygwin? As I said before,
as an application, this works fine.

Cheers,
Dave.

 
Reply With Quote
 
Gordon Beaton
Guest
Posts: n/a
 
      06-11-2004
On 11 Jun 2004 13:36:09 GMT, Dave Neary wrote:
> An unexpected exception has been detected in native code outside the VM.
> Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at
> PC=0x61044A01
> Function=getservbyname+0xC1
> Library=c:\sane\cygwin1.dll
>
> Current Java thread:
> at org.sane.Sane.getNumberOfDevices(Native Method)
> at com.phenix.framework.scan.ScanApplet.init(ScanAppl et.java:227)
> at sun.applet.AppletPanel.run(AppletPanel.java:353)
> at java.lang.Thread.run(Thread.java:534)
>
> Does this mean that cygwin1.dll doesn't have the necessary
> permissions to make the system call, or that there is a bug in
> cygwin? As I said before, as an application, this works fine.


More likely it means that you have incorrectly called getservbyname()
from getNumberOfDevices(), for example by passing it (or another
function that calls it) an invalid pointer.

For some concrete suggestions, see this:
http://www.eskimo.com/~scs/C-faq/q16.5.html

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the permission for JVM shared memory? Sumant Sankaran Java 1 03-28-2008 05:01 PM
MS JVM and Sun JVM problem Young-Jin Lee Java 3 01-21-2004 04:25 AM
Different behavior for newStringUTF() for Sun JVM and IBM Jvm Lasse Java 1 01-05-2004 07:49 PM
IBM JVM: loading two native libraries in JNI, second one has problems Alex Hunsley Java 4 11-14-2003 10:08 AM
Re: Handling both MS JVM and Sun JVM Kevin Hooke Java 2 09-02-2003 05:31 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57