Forum OpenACS Q&A: nsjava error : Unable to load libnsjava.so.

Hi everyone,

I've been getting this error when I'm trying to use nsjava..

(from the log)
"Unable to load libnsjava.so.  It's probably not in your library path when you start aolserver.  Standard install puts libnsjava.so in the aolserver bin directory, so you need to add that directory to LD_LIBRARY_PATH before you start aolserver"

All the environment vars are set correctly (classpath, path, ld_library_path, java_home) so I'm not sure what's going on.

Any ideas?

Collapse
Posted by Jonathan Ellis on
where is libnsjava.so in the filesystem?  what does your aolserver .tcl init script say about it?
Collapse
Posted by jeff wang on
-where is libnsjava.so in the filesystem?

it's located in /home/aol34/bin/

-what does your aolserver .tcl init script say about it?

The aolserver .tcl init script loads perfectly fine and does not complain.  The weird thing is that when I start up aolserver as nsadmin then everything works fine.  But when I do a "sudo" and start the server as another user, then it loads fine but will spit out that error about "unable to load libnsjava.so" whenever I try to make new java objects. I initially thought it had something to do with the permissions on the nsjava.jar or libnsjava.so file but I gave full permissions (chmod 777) to those files and it's still broken.

Below are the pertinent portions of my .tcl init script:

----------------------------------------
# enable the java module
ns_param EnableJava on
# same as java command line verbose mode.  setting it to "on" will show the
# loading of libraries in the log file.
ns_param VerboseJvm off
# Some 1.1 jvm's segfault when destroyed.  This option can be used to bypass
# destroying the jvm at shutdown.
ns_param DestroyJvm no
ns_param  DisableJITCompiler  "off"
ns_param  LogLevel            "Notice"
# Prepend the following to the default classpath. This is just an example, your
# classpath will probably be different.
ns_param ClassPath "${cpath}${pns_jars}/home/aol34/bin/nsjava.jar:${ws_lib}:${wrapper_lib}"

ns_param  nsjava          ${bindir}/libnsjava.so
------------------

Thanks,
Jeff

Collapse
Posted by Jonathan Ellis on
is it permissions on nsjava.jar or some other class?

You could try passing -verbose:class and see where exactly it's having a problem.  It sounds like "unable to load libnsjava" is someone casting too broad an exception-casting net.

Collapse
Posted by jeff wang on
I turned verbose jvm and it seems to be getting an UnsatisfiedLinkError when loading nsjava.NsLog.

The log has:

..
[Loaded nsjava.internal.TclNumArgsException]
[Loaded nsjava.NsLog]
[Loaded java.lang.UnsatisfiedLinkError from /usr/local/java/j2sdk1.4.1_02/jre/lib/rt.jar]
Unable to load libnsjava.so. It's probably not in your library path when you start aolserver...

----

I'm not quite sure how this all works but it seems like when it's trying to load nsjava.NsLog it can't link the right native language definition in the libnsjava.so file. Any suggestions?

Thanks,
Jeff

Collapse
Posted by xx xx on
What does your serverlog say. Did it load nsjava.so? Or do you have a FATAL there.

Although it is in the standard config.tcl, are you sure that the ns_param is set correct? I don't use it but "libnsjava.so" seems weird. Do you have a file like that?

ns_param  nsjava          ${bindir}/libnsjava.so
Collapse
Posted by Jonathan Ellis on
Aldert: yes, he's past that point.

Jeff: I think you're going to have to edit the nsjava source and take out that bogus exception handler to see what's really going on.