tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dan ancona <>
Subject Re: I can't stand the "UnsatisfiedLinkErrors" anymore with Tomcat 4.0.1!
Date Tue, 12 Feb 2002 17:35:04 GMT
I've gotten this to work, so it can somehow be done.  It was tricky and it
did take some futzing around, though.  Here are a few ideas...

0 - What OS etc are you on?  I got it working in solaris 5.7, both tomcat
3.2 & 4.0.1, java 1.3.0.

1 - Make sure your LD_LIBRARY_PATH is set right both for you and for
whichever user tomcat is running as if it isn't you.  Ditto for any
env. variables your c code might need.

2 - I had big problems getting the header file to work right with my code
inside a package.  If the methods in your c code look something like

Java_edu_ucsb_adl_z2adl_QueryThread_zInit(JNIEnv *env, blah blah)

and you're doing javah -jni from the right place (the top of the
hierarchy), you're on the right track.  Since it's working ok from the
command line, I'm guessing you've got this dialed.  If you suspect it
might still be an issue, there's a nice example somewhere on the 'net -
let me know if you can't find it and I'll try to dig up the link.

3 - There's a warning somewhere in the tomcat docs (maybe in the release
notes?) about Something Bad happening if your shared object gets loaded
twice somehow.  I haven't personally had this problem, but it is in there.

Hm, that's all I can think of off the top of my head.  My c code is having
some weird interactions with tomcat that I'm going to post about in detail
at some point, but the JNI stuff does seem to be working still.

Good luck, hope this helps...if it doesn't, I could maybe send along some
of my test code if you think that'd be helpful.


da - dan ancona.  software engineer, adept project  

On Tue, 12 Feb 2002, Craig R. McClanahan wrote:

> On Mon, 11 Feb 2002, Larry Meadors wrote:
> > After more that a week of messing with it, I'm convinced there is no
> > way to call native methods within Tomcat. I have read the class loader
> > INFO file 100 times, searched and read the list serve archives for
> > hours, followed all the suggestions found within those messages, and
> > still I receive "UnsatisfiedLinkErrors" whenever I attempt to run native
> > methods.
> >
> > Facts:
> >
> > * I can execute the methods with no problems when run from the command
> > line, but I get "UnsatisfiedLinkErrors" running under Tomcat 4.0.1.
> > Hummm...
> >
> I never do this in "real life", so all I can offer is suppositions:
> > Questions:
> >
> > * Can the class loader used to load the classes in the web app load
> > native libraries with System.loadLibrary? Some list serve messages say
> > no, others suggest yes.
> Class loaders are *not* used to load native code itself -- my
> understanding is that native libraries have to be found on the PATH
> environment variable, not the CLASSPATH.  You also need to ensure that a
> particular native library is loaded once and only once (even in the face
> of application restarts) within a single (Tomcat) JVM.
> However, the Java stubs that represent the native methods *are* made
> visible through a class loader -- and you will need this to be done in a
> classloader that is visible to all your apps.
> > * Do I really need to load my class with the native methods in the
> > "Common" class loader?  If so, how? None of the methods I have tried
> > work.
> Based on the above, I wouls assume the answer is yes.
> > * Basically, how do I need to sweet talk Tomcat to make it execute my
> > native methods?
> >
> > I'm really frustrated and desperate!  If anyone has made this work,
> > please share your wisdom. I am a big fan of open source, but the
> > troubles I am having really make me wish I could call tech support at
> > some software company!  Any suggestions are welcome.  Thanks..
> >
> > Cheers,
> >
> > Jim Boone
> >
> >
> Craig
> --
> To unsubscribe:   <>
> For additional commands: <>
> Troubles with the list: <>

To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message