Issue when opening same applet with JNIWrapper from two different URLs

480 views
Skip to first unread message

Mariusz Pala

unread,
Jun 1, 2011, 6:33:13 AM6/1/11
to JNIWrapper Forum
I have an applet with JNIWrapper 3.7.3 and WinPack 3.7.1
When running in multiple browser tabs using the same URL everything
seems to be fine, but when I try using my application from different
URLs, applet throws an exception on the following line:

Shell32.shellExecute(null, "open", "rundll32.exe" ....

It still works on the first opened tab, but all other throws the
exception:

Exception is:

java.lang.UnsatisfiedLinkError: Cannot load native JNIWrapper library
(jniwrap.dll).
at com.jniwrapper.Library.loadNativeCode(SourceFile:79)
at com.jniwrapper.Library.loadNativeCode(SourceFile:104)
at com.jniwrapper.Library.ensureNativeCode(SourceFile:114)
at com.jniwrapper.PlatformContext.a(SourceFile:452)
at
com.jniwrapper.PlatformContext.getDefaultStructureAlignment(SourceFile:
386)
at com.jniwrapper.Structure.<init>(SourceFile:43)
at com.jniwrapper.win32.system.VersionInfo.<init>(VersionInfo.java:
47)
at com.jniwrapper.win32.system.Kernel32.isUnicode(Kernel32.java:77)
at com.jniwrapper.win32.FunctionName.<clinit>(FunctionName.java:24)
at com.jniwrapper.win32.shell.Shell32.<clinit>(Shell32.java:43)
at com.generiscorp.contentmanager.ContentManager
$5$1.run(ContentManager.java:370)
at java.lang.Thread.run(Unknown Source)
java.lang.NoClassDefFoundError: Could not initialize class
com.jniwrapper.win32.shell.Shell32
at com.generiscorp.contentmanager.ContentManager
$5$1.run(ContentManager.java:386)
at java.lang.Thread.run(Unknown Source)



Any idea how can I fix it? It's the same when I close one tab and open
another with different URL.

Thanks in advance for any help.
Mariusz

Sergei Piletsky

unread,
Jun 1, 2011, 1:01:42 PM6/1/11
to Mariusz Pala, JNIWrapper Forum
Hi Mariusz,

We have already seen such exception before. The cause of this issue is that Applets from different URLs are being loaded by different Java class loaders. However, there is the limitation in Java class loaders that they cannot access the same shared native library, which is loaded once per JVM process. That's why first loading of JNIWrapper library always works fine in your case, but all subsequent attempts to load it always fail.

So, this is not the issue of JNIWrapper, but the limitation of the Java itself, because you can get the same exception when you use any JNI library in a Java Applet.

Here is the discussion of the same issue on Oracle forums: http://forums.oracle.com/forums/thread.jspa?messageID=5521242 They even provide some workarounds for this issue which might be helpful for you.

Please let me know if you have any further questions.

Sincerely,
Serge

Sergei Piletsky

unread,
Jun 3, 2011, 9:11:55 AM6/3/11
to Mariusz Pala, JNIWrapper Forum
Hi,

Such exception "java.lang.NoClassDefFoundError: com/jniwrapper/win32/com/IUnknown" indicates that Java was unable to find the required IUnknown class in the class path of your Applet application. The IUnknown class is available in our ComfyJ library.

You were trying to create a SelectFolderDialog object, but the functionality of SelectFolderDialog class uses IShellFolder COM interface. I should mention that there are several classes in WinPack, such as SelectFolderDialog, ShellLink, IActiveDesktop, which are using COM integration and thus ComfyJ library should be included to the class path of the application. We are planning to move them from WinPack to ComfyJ library in one of the future version of ComfyJ to avoid this ambiguity. Meanwhile, in order to fix this issue you just need to download ComfyJ library from our web side: http://www.teamdev.com/comfyj/  and include to the class path of your application.


Please let me know if you have any further questions.

Sincerely,
Serge


On Fri, Jun 3, 2011 at 3:49 PM, Mariusz Pala <marius...@gmail.com> wrote:

Hi,

 

No I have another issue when I call the following  API (both winpack and jniwrapper jars are included, but there is no mentioned class inside):

 

      Wnd owner = null;

                             try {

                                   owner = Wnd.getForegroundWindow();

                             } catch (Throwable e) {

                             }

                             SelectFolderDialog dialog = new SelectFolderDialog(owner);

 

java.lang.NoClassDefFoundError: com/jniwrapper/win32/com/IUnknown

                at java.lang.ClassLoader.defineClass1(Native Method)

                at java.lang.ClassLoader.defineClassCond(Unknown Source)

                at java.lang.ClassLoader.defineClass(Unknown Source)

                at java.security.SecureClassLoader.defineClass(Unknown Source)

                at java.net.URLClassLoader.defineClass(Unknown Source)

                at java.net.URLClassLoader.defineClass(Unknown Source)

                at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)

                at java.security.AccessController.doPrivileged(Native Method)

                at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)

                at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

                at java.lang.ClassLoader.loadClass(Unknown Source)

                at java.lang.ClassLoader.defineClass1(Native Method)

                at java.lang.ClassLoader.defineClassCond(Unknown Source)

                at java.lang.ClassLoader.defineClass(Unknown Source)

                at java.security.SecureClassLoader.defineClass(Unknown Source)

                at java.net.URLClassLoader.defineClass(Unknown Source)

                at java.net.URLClassLoader.defineClass(Unknown Source)

                at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

                at java.lang.reflect.Method.invoke(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)

                at java.security.AccessController.doPrivileged(Native Method)

                at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)

                at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

                at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

                at java.lang.ClassLoader.loadClass(Unknown Source)

                at com.generiscorp.contentmanager.ContentManager$1.run(ContentManager.java:135)

Reply all
Reply to author
Forward
0 new messages