Operating System - HP-UX
1757751 Members
2139 Online
108863 Solutions
New Discussion юеВ

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

 
SOLVED
Go to solution
Daavid Turnbull
Frequent Advisor

JNI/Java - Unable to load native library: insufficient room in the address space to load the library

I am trying to access java from the native side under HP-UX.

(I tried posting this to HP-UX/general but the silence was deafening.)

In the aCC++ source when I call:
_____

rc = JNI_CreateJavaVM(&jvm,(void **)&env, &vm_args);
_____
I get:


Error occurred during initialization of VM
Unable to load native library: insufficient room in the address space to load the library.

I tried a number of things including adjusting max stack etc. ulimit now reports:
_____

> ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 262144
stack(kbytes) 16384
memory(kbytes) unlimited
coredump(blocks) 4194303
________

One of the resources I have been using as a guide is:

http://www.hp.com/products1/unix/java/infolibrary/prog_guide/java1_3/JNI_java2.html#non_java_ac++

Attached is my (fairly) basis source code I have been using.

What I am I doing wrong??

(For completeness I include output from a make/run pass below.

In anticipation, __daavid

______________

daavid@ausccm1:/home/daavid/projects/CCT/servers/legacy
> make -f wc.mk clean
rm test2 test2.o WesCCT.class
daavid@ausccm1:/home/daavid/projects/CCT/servers/legacy
> make -f wc.mk
javac -classpath /opt/eia_3.6/classes:/opt/eia_3.6/conf:/opt/eia_3.6/lib/eialib_client.jar:/opt/eia_3.6/lib
/weblogic.jar::/home/daavid/projects/CCT/tools/WesTest/adminclient.jar:/home/daavid/projects/CCT/tools/WesTest/comm
ons-lang-1.0.jar:. WesCCT.java
aCC -g +u4 -c -ext -I /opt/java1.4/include -I /opt/java1.4/include/hp-ux -D_HPUX -D_POSIX_C_SOURCE=19950L -
D_REENTRANT test2.cpp
aCC -g -z -o test2 test2.o -L /opt/java1.4/jre/lib/PA_RISC/hotspot -ljvm -lpthread -llwp
daavid@ausccm1:/home/daavid/projects/CCT/servers/legacy
> ./test2
beginning execution... set up vm args structure
before CreateJavaVM
options[0] - -Djava.class.path=.:/opt/java1.4/jre/lib/rt.jar:/opt/hpservices/jre/lib/i18n.jar:/opt/java/lib/classes
.zip
Error occurred during initialization of VM
Unable to load native library: insufficient room in the address space to load the library.
daavid@ausccm1:/home/daavid/projects/CCT/servers/legacy
Behold the turtle for he makes not progress unless he pokes his head out.
7 REPLIES 7
Mike Stroyan
Honored Contributor

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

It looks like you missed a detail in the part of that document about running the program.
You need to set SHLIB_PATH to include /opt/java1.4/jre/lib/PA_RISC and /opt/java1.4/jre/lib/PA_RISC/hotspot.
I can get the same error message by setting SHLIB_PATH to include /opt/java1.4/jre/lib/PA_RISC but not include /opt/java1.4/jre/lib/PA_RISC/hotspot.

You could put those path elements in the executable's embedded path with -Wl,+b,/opt/java1.4/jre/lib/PA_RISC:/opt/java1.4/jre/lib/PA_RISC/hotspot
during the link step.
Daavid Turnbull
Frequent Advisor

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

Dear Mike,

Those two components are the first two elements in my $SHLIB_PATH variable. (See below)

I also added "-verbose" to one of the options.optionString which did not produce any more diagnostic information.

regards __daavid
_____________

daavid@ausccm1:/home/daavid
> echo $SHLIB_PATH
/opt/java1.4/jre/lib/PA_RISC:/opt/java1.4/lib/PA_RISC2.0/hotspot:/opt/java1.4/jre/lib:/opt/java1.4/jre/lib/PA_RISC/
classic:/opt/edimgr/lib:/opt/CCM/Australia/lib:/opt/edimgr/lib
daavid@ausccm1:/home/daavid
> cd projects/CCT/servers/legacy
daavid@ausccm1:/home/daavid/projects/CCT/servers/legacy
> ./test2
beginning execution... set up vm args structure
before CreateJavaVM
options[0] - -Djava.class.path=.:/opt/java1.4/jre/lib/rt.jar:/opt/hpservices/jre/lib/i18n.jar:/opt/java/lib/classes
.zip
Error occurred during initialization of VM
Unable to load native library: insufficient room in the address space to load the library.
daavid@ausccm1:/home/daavid/projects/CCT/servers/legacy
> env
_=/usr/bin/env
MANPATH=/usr/share/man/%L:/usr/share/man:/usr/contrib/man/%L:/usr/contrib/man:/usr/local/man/%L:/usr/local/man:/opt
/upgrade/share/man/%L:/opt/upgrade/share/man:/usr/dt/share/man:/opt/pd/share/man/%L:/opt/pd/share/man:/opt/ignite/s
hare/man/%L:/opt/ignite/share/man:/opt/hparray/share/man/%L:/opt/hparray/share/man:/opt/pred/share/man/%L:/opt/pred
/share/man:/opt/perl5/man:/opt/medusa/share/man:/opt/softbench/man:/opt/softbench/share/man:/opt/perf/man/%L:/opt/p
erf/man:/opt/maestro/man:/opt/omni/lib/man:/opt/pwplus/share/man:/opt/sir/man:/opt/socks/man:/opt/prm/man/%L:/opt/p
rm/man:/opt/aCC/share/man/%L:/opt/aCC/share/man:/opt/langtools/share/man/%L:/opt/langtools/share/man:/opt/resmon/sh
are/man:/opt/ssh/share/man:/opt/dce/share/man/%L:/opt/dce/share/man:/opt/aCC/share/man:/opt/TWWfsw/man:/opt/TWWfsw/
curl710/man:/opt/TWWfsw/zlib11/man:/opt/TWWfsw/libopenssl097/man
TCL_LIBRARY=/opt/edimgr/bin
EDIMGR_TIMEOUT_SECONDS=300
SHLIB_PATH=/opt/java1.4/jre/lib/PA_RISC:/opt/java1.4/lib/PA_RISC2.0/hotspot:/opt/java1.4/jre/lib:/opt/java1.4/jre/l
ib/PA_RISC/classic:/opt/edimgr/lib:/opt/CCM/Australia/lib:/opt/edimgr/lib
UX_COE_VER=4.10
PATH=/opt/edimgr/bin:/opt/java1.4/bin:/opt/eia_adk/jakarta-ant-1.3/bin:/opt/softbench/bin:/opt/socks/bin:/usr/bin:/
usr/ccs/bin:/usr/contrib/bin:/opt/nettladm/bin:/opt/fc/bin:/opt/fcms/bin:/opt/upgrade/bin:/opt/pd/bin:/usr/bin/X11:
/usr/contrib/bin/X11:/opt/java/bin:/opt/hparray/bin:/opt/pred/bin:/opt/ignite/bin:/opt/perl5/bin:/usr/local/bin:/op
t/coe/bin:/opt/coe/acu/sbin:/opt/coe/ipm/sbin:/opt/coe/ipm/bin:/opt/perf/bin:/opt/omni/bin:/opt/pwplus/bin:/opt/OV/
bin/OpC:/opt/einfo/bin:/usr/sbin/stm/uut/bin/progs:/opt/prm/bin:/opt/aCC/bin:/opt/langtools/bin:/opt/resmon/bin:/us
r/sbin/diag/contrib:/usr/sbin:/opt/coe/sbin:/opt/maestro/bin:/opt/ux2bn:/usr/bin/X11/xcoral:/home/OraHome/bin:/usr/
local/bin:/usr/emacs/bin:/usr/xemacs/bin:/opt:/var/opt:/sbin:/opt/CCM/A.05.83/bin:/bin:/usr/sbin:/opt/aCC/bin:.:/op
t/CCM/Australia/bin:/opt/TWWfsw/bin
EDIMGR_HOME_BUSINESS=HPC
EDIMGR_DIR=/opt/edimgr
COLUMNS=115
ENV_FILE=/home/daavid/.kshrc
EDITOR=xemacs -nw
RPC_SUPPORTED_NETADDRS=ncacn_ip_tcp:15.23.69.139
CLASSPATH=/opt/eia_3.6/classes:/opt/eia_3.6/conf:/opt/eia_3.6/lib/eialib_client.jar:/opt/eia_3.6/lib/weblogic.jar::
/home/daavid/projects/CCT/tools/WesTest/adminclient.jar:/home/daavid/projects/CCT/tools/WesTest/commons-lang-1.0.ja
r:.
EDIMGR_LOG_FILE=/opt/edimgr/error.log
LOGNAME=daavid
MAIL=/var/mail/daavid
ORACLE_SID=cprd
ERASE=^H
PS1=daavid@ausccm1:$PWD
>
RPC_BIND_ADDRS=TRUE
SYBASE=/opt/edimgr
EDIMGR_USER=edimgr
EDIMGR_APPLICATION_CONTEXT=RCA2.0
EIA_HOME=/opt/eia_3.6
TNS_ADMIN=/opt/oracle/product/8.1.5/network/admin
CC=aCC
CXX=aCC
DISPLAY=
CVSROOT=/opt/cvs
SHELL=/usr/bin/ksh
JAVA_HOME=/opt/java1.4
HOME=/home/daavid
INCLUDE=/usr/include:/opt/TWWfsw/libopenssl097/include:/opt/TWWfsw/zlib11/include:/opt/TWWfsw/curl710/include
ANT_HOME=/opt/eia_adk/jakarta-ant-1.3
TERM=vt100
ORACLE_HOME=/opt/oracle/product/8.1.5
i=/opt/CCM/Australia
PWD=/home/daavid/projects/CCT/servers/legacy
TZ=EST-10EDT
ENV=${ENV_FILE[ (_$-= 1) + (_ = 0) - (_$- != _${-%%*i*}) ]}
t=/tmp/tempfile.daavid
LINES=87
Behold the turtle for he makes not progress unless he pokes his head out.
Daavid Turnbull
Frequent Advisor

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

I suspect you get another error (ie: different explanation for the load failure) if the shared library path is not set correctly.

I keep coming back to this quote from: http://www.hp.com/products1/unix/java/infolibrary/prog_guide/java1_3/JNI_java2.html#non_java_ac++

<<
Note: The default stack size for 1.4 64-bit mode JVM- created threads is 1 MB. On PA-RISC 32 and 64-bit systems, the default stack size is 64 KB. Therefore, if you are using C language main programs that attach with JNI, you will want to adjust the stack size to avoid overflows.
>>

If the stack size is the culprit here what it the "best" way to increase it? I have looked at entities such as chatr and rebuilt a kernel with increased max values after reading:

http://www.hp.com/products1/unix/java/infolibrary/prog_guide/java1_3/configuration.html
Behold the turtle for he makes not progress unless he pokes his head out.
Vamsi Kottisa
New Member

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

My hunch is that the jvm heapsize was insufficient to load the shared libraries. You may want to try to increase the heapsize by adding the following jvm args.
-Xms32m -Xmx200m
Mike Stroyan
Honored Contributor
Solution

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

You have the SHLIB_PATH slightly wrong. You linked with /opt/java1.4/lib/PA_RISC/hotspot but you set SHLIB_PATH to include /opt/java1.4/lib/PA_RISC2.0/hotspot.

The actual error that produces the "insufficient room" message is that the trouble loading from the hotspot direct is somehow causing the libverify.sl library to be loaded twice. That produced an ENOMEM error when it tried to map one library a second time. The normal shared library load mechanism recognizes that and does not fail. Something unusual in the java implementation will not tolerate it.
Daavid Turnbull
Frequent Advisor

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

Thanks Mike, your response was one the money.

I had done a lot of shuffling in SHLIB_PATH but obviously not struck on this combination.

Thanks Vamsi, can you point me at a reference for the -X options for HPUX? The only reference I have found was a mention in the context of the "ignoreUnrecognized" flag.
Behold the turtle for he makes not progress unless he pokes his head out.
Mike Stroyan
Honored Contributor

Re: JNI/Java - Unable to load native library: insufficient room in the address space to load the library

You can get a short description of the "-X" options by just running "java -X".

There are more details in /opt/java1.4/java.os11.release.notes.