Operating System - HP-UX
1755840 Members
4143 Online
108838 Solutions
New Discussion юеВ

Re: JNI_CreateJavaVM return Exec format error when called from shared library

 
Angad
New Member

JNI_CreateJavaVM return Exec format error when called from shared library

I am desperately looking for solution, Can somebody help me?

Our tool has a Java and native component on unix box. It is runs okay on Alpha Tru64, we are trying to port it on HP-UX 11.11.

The overall flow is as follows:
The Java Class 'A' needs to instantiate the Java class 'B' upon some event. The 'B' class can have multiple instances running at one time. In other words the 'B' needs to run either as a thread or a different process (to optimize the performance). The Thread approach is pretty much straight forward and works as it is.

The Process aproach architecture: The java class 'B' calls the JNI code(native library written in C), the JNI library in turn calls the standalone process written in C (let's call it StartProcess). The StartProcess process calls the Java shared library libjvm.sl and invokes the Java program (Class 'B') by calling JNI_CreateJavaVM etc. It works perfectly fine on Alpha Tru64, but the call JNI_CreateJavaVM return following error message HP-UX.

/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /op
t/java1.3/bin/../jre/lib/PA_RISC2.0/server/libjvm.sl
/usr/lib/dld.sl: Exec format error
Can't load library "/opt/java1.3/jre/lib/PA_RISC/libverify.sl", because specifie
d file is not a shared library, or a format error was detected.
can't create java vm
When I call StartProcess process directly from the shell, it works okay (calls the class 'B') but returns error when called from the java program 'A'. I am suspecting the reason could be either because of Compiler options or my profile. I have looked into the HP documentation and have tried different compiler options, still not able to connect all pieces together.
Following are the compiler options I am giving currently

Compiler Options:
For JNI library:
aCC -Ae +u4 +z -c -D_HPUX -DNATIVE -D_POSIX_C_SOURCE=199506L \
-I/opt/java1.3/include -I/opt/java1.3/include/hp-ux \
ProcessImpl.c

aCC -b -o libprocessimpl.sl ProcessImpl.o \
-lCsup -lstream -lstd -lcl

For standalone process (StartProcess)
aCC -z -g +u4 -c -Ae -D_HPUX \
-DNATIVE -D_POSIX_C_SOURCE=199506L \
-I/opt/java1.3/include -I/opt/java1.3/include/hp-ux \
StartProcess.c

aCC -g -o StartProcess StartProcess.o -lpthread
Angad
2 REPLIES 2
Steven E. Protter
Exalted Contributor

Re: JNI_CreateJavaVM return Exec format error when called from shared library

http://www.hp.com/go/java

Get and install a current version of java.

More important, whatever version you have, make sure its properly patched. The patch list for each version is on the site above.

Lastly on HP-UX

swverify \*

Report any java errors to HP and get them corrected.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
susan gregory
Advisor

Re: JNI_CreateJavaVM return Exec format error when called from shared library

Another thing to also look into is the env var LD_PRELOAD (look for information about it in the ld man page) that will allow you to dynamically load libraries that contain thread local storage. I don't know if you are doing that but it the error isn't bogus, that may solve that part of the problem.