Skip to main content

run the awt demo ,can't load the libawtjpeg.so

16 replies [Last post]
friver
Offline
Joined: 2010-08-11
Points: 0

I use this command for run the awt demo:

bin/cvm -Dsun.boot.library.path=/home/phoneme/lib -cp democlasses.jar basis.DemoFrame

and ls /home/phoneme/lib print:

ls /home/phoneme/lib/
basis.jar libawtjpeg.so security
content-types.properties libqtawt.so zi

but , if run it ,have some infomation like this:

===========================================================================
java.lang.UnsatisfiedLinkError: no libawtjpeg.so in sun.boot.library.path
at java.lang.ClassLoader.loadLibraryInternal(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at sun.security.action.LoadLibraryAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at sun.awt.image.JPEGImageDecoder.(Unknown Source)
at java.lang.Class.runStaticInitializers(Unknown Source)
at sun.awt.image.InputStreamImageSource.getDecoder(Unknown Source)
at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
at java.lang.Thread.startup(Unknown Source)

any one know it ?
Thanks a lot.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
friver
Offline
Joined: 2010-08-11
Points: 0

But I can't find the reason for the jpeg_resync_to_restart undefined.
it's in the libawtjpeg.so which is a jpeg library changed from libjpeg.so.62(I guess).

and in the src/share/basis/native/image/jpeg/lib , have a jdmarker.c ,define the function:

GLOBAL(boolean)
jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
{

int marker = cinfo->unread_marker;
int action = 1;

/* Always put up a warning. */
WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);

/* Outer loop handles repeated decision after scanning forward. */
for (;;) {
if (marker < (int) M_SOF0)
action = 2; /* invalid marker */
else if (marker < (int) M_RST0 || marker > (int) M_RST7)
................

why dlopen have the undefine err?

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Does nm show that jpeg_resync_to_restart is defined in libawtjpeg.so? If not, how about jResyncRestart.

You may want to try removing or renaming /usr/include/libjpeg.h. gcc may be pulling in it instead of the copy in src/share/basis/native/image/jpeg/lib/

friver
Offline
Joined: 2010-08-11
Points: 0

I disable the qt library's jpeg depend with the -no-jpeg option when configure for qte.
but the problem exist yet.

Then I what to debug the loadLibrary0, add some print :

========================================================
private static Object loadLibrary0(Class fromClass, final File file,
boolean isXrunLibrary)
{
Check to see if the file exists:
System.out.println("friver debug:LoadLibrary0 fun,file.getPath:" + file.getPath());
if (!NativeLibrary.exists(file.getPath())) {
System.out.println("friver debug:LoadLibrary0 fun,file.getPath fail!" + file.getPath());
return null;
}

// Go load the library:
String name;
try {
name = file.getCanonicalPath();
} catch (IOException e) {
return null;
}
return loadLibrary0(fromClass, name, false, isXrunLibrary);
}
========================================================
and I found the running print meg is :

================================
friver debug:LibraryName :libqtawt_g.soLibpath :/home/phoneme_debug/lib
friver debug:LoadLibrary0 fun,file.getPath:/home/phoneme_debug/lib/libqtawt_g.so
friver debug:libObj success,libname :libqtawt_g.so
friver debug:LibraryName :libawtjpeg_g.soLibpath :/home/phoneme_debug/lib
friver debug:LoadLibrary0 fun,file.getPath:/home/phoneme_debug/lib/libawtjpeg_g.
so
friver debug:LoadLibrary0 fun,file.getPath fail!/home/phoneme_debug/lib/libawtjp
eg_g.so
friver debug:load failed libraryname is :libawtjpeg_g.so

Message was edited by: friver

================================================

I look at the loadLibrary0 function :

the NativeLibrary.exists return a null when the library is libawtjpeg.so , but in the disk ,it's exist .

I want to know the NativeLibrary.exists function ,but find a define :

static native boolean exists(String name);

who can find the exists function how to do ? where the detil code ?

Message was edited by: friver

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Look in src/share/native/java/lang/ClassLoader.c for Java_java_lang_ClassLoader_00024NativeLibrary_exists.

Chris

friver
Offline
Joined: 2010-08-11
Points: 0

Dear cjplummer:

Thanks for your help .

I add some debug in the Java_java_lang_ClassLoader_00024NativeLibrary_exists function, and find the CVMdynlinkExists(cname) function return fail msg.

so I look at the src/portlibs/dlfcn/linker_md.c and add some code.

CVMBool
CVMdynlinkExists(const char *name)
{
void *handle;

handle = dlopen((const char *) name, RTLD_LAZY);
printf("friver debug: CVMdynlinkExists, dlopen: %s\n",name);
if (handle != NULL) {
printf("friver debug: CVMdynlinkExists,handel != NULL.\n");
dlclose(handle);
}
return (handle != NULL);
}

I find the dlopen return NULL.

then I write a small test for it:

===========================================================
#include
#include
#include

int main(void)
{
void *handle;
char *name = "/home/phoneme_debug/lib/libawtjpeg_g.so";
handle = dlopen((const char *) name, RTLD_LAZY);
perror("friver debug perror");
printf("friver debug:after dlopen: %s\n",name);
printf("friver debug:dlerror is:%s\n",dlerror());
if (handle != NULL) {
printf("friver debug: handel != NULL,success!\n");
dlclose(handle);
}else{
printf("friver debug: handel == NULL,failed!\n");
}
return (handle != NULL);
}
=====================================================
run it , it's give me some msg:

friver debug perror: Success
friver debug:after dlopen: /home/phoneme_debug/lib/libawtjpeg_g.so
friver debug:dlerror is:/home/phoneme_debug/lib/libawtjpeg_g.so: undefined symbol: jpeg_resync_to_restart
friver debug: handel == NULL,failed!

OK, now I know the reson for the load err. but I hane no time for debug it.

if any one have some msg, replay this ,thanks.

Thanks again for cjplummer's help.

Message was edited by: friver

cjplummer
Offline
Joined: 2006-10-16
Points: 0

I had eliminated the runtime linkage error as a possible cause since there is debugging code in CVMdlopen() that would have printed out the error message. However, CVMdynlinkExists() is somewhat new, is called before CVMdlopen(), and does not print out the error message. It probably should be made to do this since in the past this error message in CVMdlopen() has been the key to quickly solving problems like the one you had.

friver
Offline
Joined: 2010-08-11
Points: 0

and I run the test ,have these :
==========================================================
friver debug:LibraryName :libqtawt_g.so
friver debug:libObj success,libname :libqtawt_g.so
friver debug:LibraryName :libawtjpeg_g.so
friver debug:load failed libraryname is :libawtjpeg_g.so
java.lang.UnsatisfiedLinkError: no libawtjpeg_g.so in sun.boot.library.path
at java.lang.ClassLoader.loadLibraryInternal(Ljava/lang/Class;Ljava/lang
/String;ZZ)Ljava/lang/Object;(ClassLoader.java:1649)
at java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;
Z)V(ClassLoader.java:1543)
at java.lang.Runtime.loadLibrary0(Ljava/lang/Class;Ljava/lang/String;)V(
Runtime.java:878)
at java.lang.System.loadLibrary(Ljava/lang/String;)V(System.java:928)
at sun.security.action.LoadLibraryAction.run()Ljava/lang/Object;(LoadLib
raryAction.java:70)
at java.security.AccessController.doPrivileged(Ljava/security/Privileged
Action;Ljava/security/AccessControlContext;)Ljava/lang/Object;(AccessController.
java:299)
at java.security.AccessController.doPrivileged(Ljava/security/Privileged
Action;)Ljava/lang/Object;(AccessController.java:273)
at sun.awt.image.JPEGImageDecoder.()V(JPEGImageDecoder.java:54)
at java.lang.Class.runStaticInitializers()V(Class.java:1643)
at sun.awt.image.InputStreamImageSource.getDecoder(Ljava/io/InputStream;
)Lsun/awt/image/ImageDecoder;(InputStreamImageSource.java:235)
at sun.awt.image.URLImageSource.getDecoder()Lsun/awt/image/ImageDecoder;
(URLImageSource.java:159)
at sun.awt.image.InputStreamImageSource.doFetch()V(InputStreamImageSourc
e.java:257)
at sun.awt.image.ImageFetcher.fetchloop()V(ImageFetcher.java:199)
at sun.awt.image.ImageFetcher.run()V(ImageFetcher.java:155)
at java.lang.Thread.startup(Z)V(Thread.java:785)

++++++++++++++++++++++++++++++++++++++++++++++++++++
And I not use the -Dsun.boot.library.path option for testcase , have the same err.
if remove the libqtawt_g.so the err msg is about not find the libqtawt_g.so in the sun.boot.library.path .

I think the libqtawt_g.so is load success, but the awtjpeg can't .

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Try calling some File APIs to see what the full path name is and if the file exists. If that doesn't turn up anything, you'll need to dig into loadLibrary0.

friver
Offline
Joined: 2010-08-11
Points: 0

I just use the strace for run the test example , I find something surprise ,

write(1, "friver debug:LibraryName :libqtaw"..., 39) = 39
write(1, "\n"..., 1) = 1
[b]open("/home/phoneme_debug/lib/libqtawt_g.so", O_RDONLY) = 5[/b]
read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\10\0\1\0\0\0p\240\0\0004\0\0\0\220"..., 512) = 512
fstat64(5, {st_mode=S_IFREG|0755, st_size=1109585, ...}) = 0
old_mmap(NULL, 220288, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x2b7c8000
mprotect(0x2b7ea000, 61440, PROT_NONE) = 0
old_mmap(0x2b7f9000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x21000) = 0x2b7f9000
close(5) = 0
open("./tls/libqte.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("./libqte.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("../tls/libqte.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("../libqte.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
[b]open("/home/qte/qt-2.3.10/lib/libqte.so.2", O_RDONLY) = 5[/b]
open("/lib/libgcc_s.so.1", O_RDONLY) = 5
open("/usr/lib/libjpeg.so.62", O_RDONLY) = 5
open("/home/lib/libuni_porting_graphics.so", O_RDONLY) = 5
.......................
lstat64("/home", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/phoneme_debug", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/phoneme_debug/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat64("/home/phoneme_debug/lib/libqtawt_g.so", {st_mode=S_IFREG|0755, st_size=1109585, ...}) = 0
..........................................................

=====================================================

It's have some system call for laod the libqtawt.so and it's depend's library, like the libqte.so.2.

but , why have not anything for libawtjpeg.so 's load ? what happand ?

the libqt.so which I build depend on these library:

# mipsel-oe-linux-objdump -x libqte.so.2.3.10 | grep NEEDED
NEEDED libm.so.6
NEEDED libjpeg.so.62
NEEDED libuni_porting_graphics.so
NEEDED libc.so.6

I think the libawtjpeg.so is similar as the libjpeg.so.62 ,but is this will bring on the load err ?

is my guess.

cjplummer
Offline
Joined: 2006-10-16
Points: 0
friver
Offline
Joined: 2010-08-11
Points: 0

I read the wiki , and make sure the dep. for any so library is in the rootfs and the LD_LIBRARY_PATH is setup right.

But the problem look at as same as yesterday.

and I find the err infomation is not same as the wiki say:

===================================================================
QWSClient invokeCreate begin
QWSClient sendEvent else
QWSClient sendPropertyNotifyEvent begin
QWSClient sendEvent else
java.lang.UnsatisfiedLinkError: no libawtjpeg.so in sun.boot.library.path
at java.lang.ClassLoader.loadLibraryInternal(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at sun.security.action.LoadLibraryAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at sun.awt.image.JPEGImageDecoder.(Unknown Source)
at java.lang.Class.runStaticInitializers(Unknown Source)
at sun.awt.image.InputStreamImageSource.getDecoder(Unknown Source)
at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
at java.lang.Thread.startup(Unknown Source)
========================================================
if I not set the QTDIR/lib to LD_LIBRARY_PATH , the err infomation is like the wiki:

it's say the libqtawt.so cann't load :

java.lang.UnsatisfiedLinkError: no libqtawt.so in sun.boot.library.path
at java.lang.ClassLoader.loadLibraryInternal(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at sun.security.action.LoadLibraryAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.awt.QtGraphicsEnvironment.(Unknown Source)
at java.awt.QtToolkit.(Unknown Source)
at java.awt.Toolkit$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.security.AccessController.doPrivileged(Unknown Source)
at java.awt.Toolkit.getDefaultToolkit(Unknown Source)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
at java.awt.Window.(Unknown Source)
at java.awt.Frame.(Unknown Source)
at java.awt.Frame.(Unknown Source)
at basis.DemoFrame.(Unknown Source)
at basis.DemoFrame.main(Unknown Source)
at sun.misc.CVM.runMain(Unknown Source)
=======

If I add the qtlib path to ld_library_path ,this err is not occur, and the qt seem is running , some infomation in the qtlibrary which I add is print to the screen . like this :

QWSClient invokeCreate begin

I can't understand why , I use the mips-oe-linux-objdump find the NEEDED library by the libawtjpeg.so ,it dep. on two library: libm and libc, the rootfs have this library and in the LD_LIBRARY_PATH.

Thanks for your help and it's useful for understand the java load library .

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Have you tried a CVM_DEBUG=true build yet? It usually provides a bit of extra info for UnsatisfiedLinkError. Make sure you have _g.so copies of all you JNI libraries if you do this.

friver
Offline
Joined: 2010-08-11
Points: 0

yes, I have build it use CVM_DEBUG=true setup, have this debug msg and not useful .
=========================================================
java.lang.UnsatisfiedLinkError: no libawtjpeg_g.so in sun.boot.library.path
at java.lang.ClassLoader.loadLibraryInternal(Ljava/lang/Class;Ljava/lang
/String;ZZ)Ljava/lang/Object;(ClassLoader.java:1646)
at java.lang.ClassLoader.loadLibrary(Ljava/lang/Class;Ljava/lang/String;
Z)V(ClassLoader.java:1543)
at java.lang.Runtime.loadLibrary0(Ljava/lang/Class;Ljava/lang/String;)V(
Runtime.java:878)
at java.lang.System.loadLibrary(Ljava/lang/String;)V(System.java:928)
at sun.security.action.LoadLibraryAction.run()Ljava/lang/Object;(LoadLib
raryAction.java:70)
at java.security.AccessController.doPrivileged(Ljava/security/Privileged
Action;Ljava/security/AccessControlContext;)Ljava/lang/Object;(AccessController.
java:299)
at java.security.AccessController.doPrivileged(Ljava/security/Privileged
Action;)Ljava/lang/Object;(AccessController.java:273)
at sun.awt.image.JPEGImageDecoder.()V(JPEGImageDecoder.java:54)
at java.lang.Class.runStaticInitializers()V(Class.java:1643)
at sun.awt.image.InputStreamImageSource.getDecoder(Ljava/io/InputStream;
)Lsun/awt/image/ImageDecoder;(InputStreamImageSource.java:235)
at sun.awt.image.URLImageSource.getDecoder()Lsun/awt/image/ImageDecoder;
(URLImageSource.java:159)
at sun.awt.image.InputStreamImageSource.doFetch()V(InputStreamImageSourc
e.java:257)
at sun.awt.image.ImageFetcher.fetchloop()V(ImageFetcher.java:199)
at sun.awt.image.ImageFetcher.run()V(ImageFetcher.java:155)
at java.lang.Thread.startup(Z)V(Thread.java:785)

cjplummer
Offline
Joined: 2006-10-16
Points: 0

Based on the error message, it is not even finding libawtjpeg_g.so, so the problem is not with loading it. Do you know if libqtawt_g.so is being loaded before this point? If you remove libqtawt_g.so, do you get a different error?

I noticed you are setting sun.boot.library.path. Normally this should not be needed as long as the cvm bin and lib directories are in the same directory. Have you tried this setup yet, and not bother setting sun.boot.library.path?

You might want to try adding some debugging code to ClassLoader.java. The exception is being thrown right after this point, and this is the code that tries to locate the jni library:

// Search sun.boot.library.path for the native library:
String mappedLibraryName = System.mapLibraryName(name);
for (int i = 0 ; i < sys_paths.length ; i++) {
File libfile = new File(sys_paths[i], mappedLibraryName);
libObj = loadLibrary0(fromClass, libfile, isXrunLibrary);
if (libObj != null) {
return libObj;
}
}

friver
Offline
Joined: 2010-08-11
Points: 0

// Search sun.boot.library.path for the native library:
String mappedLibraryName = System.mapLibraryName(name);
for (int i = 0 ; i < sys_paths.length ; i++) {
System.out.println("friver debug:LibraryName :" + mappedLibraryName );
File libfile = new File(sys_paths, mappedLibraryName);
libObj = loadLibrary0(fromClass, libfile, isXrunLibrary);
if (libObj != null) {
System.out.println("friver debug:libObj success,libname :" + mappedLibraryName );
return libObj;
}
}
if (loader == null) {
System.out.println("friver debug:load failed libraryname is :" + mappedLibraryName );
throw new UnsatisfiedLinkError("no " + mappedLibraryName + " in sun.boot.library.path");
}

Message was edited by: friver

friver
Offline
Joined: 2010-08-11
Points: 0

I build the x86 runtime use the same code base. and use this command to run the awt demo:

bin/cvm -cp democlasses.jar basis.DemoFrame

it's running and look at success. I'm not use the option:

-Dsun.boot.library.path=/home/phoneme/lib

who can tell me how to do on the embedded system with my mips board?

Thanks a lot.