ExceptionInInitializerError on dynamically loaded dll
843802Jul 29 2008 — edited Jul 30 2008I am making a plugin type app that starts using jnlp.
It will basically looks at jar files in a plugins directory on the pc and copy the resources (.txt, dll's....) to the current working directory which will be part of java.library.path where System.loadLibary will look to load a dll.
Problem I am having is that after I copy the dll to the current working dir (from the "Plugin" jar), a class in the "Plugin" jar will call System.loadLibary and get the following exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at com.mypackage.plugin.<init>(ThePlugin.java:29)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
.................
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission loadLibrary.libgi_decode)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkLink(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.somepackage.processor.TheProcessor.<clinit>(TheProcessor.ja
...............
(*NOTE: I have changed a couple of the package names from my code in the above stack trace)
This does not happen when I run in eclipse for instance, only when running off WebStart using JNLP.
Is there something I am missing that I need to do. I know that dll's that will be used should be defined in the.jnlp file but these are plugins and dll's may or may not exist. And if they do I don't necessarily know the dll name.
Thanks,