Applet deployment - buildpath error?

Dear All,



I wanted  to deploy one of the example applets, but I get the following Exception when running in mozilla 3.5.7, JRE6



19-Jan-2010 15:34:13 com.jme.system.lwjgl.LWJGLDisplaySystem <init>

INFO: LWJGL Display System created.

java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

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

at java.lang.Runtime.loadLibrary0(Unknown Source)

at java.lang.System.loadLibrary(Unknown Source)

at org.lwjgl.Sys$1.run(Sys.java:72)

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

at org.lwjgl.Sys.doLoadLibrary(Sys.java:65)

at org.lwjgl.Sys.loadLibrary(Sys.java:81)

at org.lwjgl.Sys.<clinit>(Sys.java:98)

at org.lwjgl.opengl.AWTGLCanvas.<clinit>(AWTGLCanvas.java:84)

at com.jmex.awt.lwjgl.LWJGLAWTCanvasConstructor.makeCanvas(LWJGLAWTCanvasConstructor.java:45)

at com.jmex.awt.lwjgl.LWJGLAWTCanvasConstructor.makeCanvas(LWJGLAWTCanvasConstructor.java:42)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(LWJGLDisplaySystem.java:212)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(LWJGLDisplaySystem.java:189)

at runner.SceneEditorDemo6b.getGlCanvas(SceneEditorDemo6b.java:213)

at runner.SceneEditorDemo6b.init(SceneEditorDemo6b.java:178)

at runner.SceneEditorDemo6b.<init>(SceneEditorDemo6b.java:115)

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)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

java.lang.NoClassDefFoundError: Could not initialize class com.jmex.awt.lwjgl.LWJGLCanvas

at com.jmex.awt.lwjgl.LWJGLAWTCanvasConstructor.makeCanvas(LWJGLAWTCanvasConstructor.java:45)

at com.jmex.awt.lwjgl.LWJGLAWTCanvasConstructor.makeCanvas(LWJGLAWTCanvasConstructor.java:42)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(LWJGLDisplaySystem.java:212)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(LWJGLDisplaySystem.java:189)

at runner.SceneEditorDemo6b.getGlCanvas(SceneEditorDemo6b.java:213)

at runner.SceneEditorDemo6b.init(SceneEditorDemo6b.java:178)

at runner.SceneEditorDemo6b.<init>(SceneEditorDemo6b.java:115)

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)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)



I'm using lwjgl-applet-2.2.1.zip content, JMonkey 2.0.1 stable distribution, all jars beside the .html, all lowercase.



Teszt.jar contains the applet and relatad code.



I'm using the following .html code:



(I have rewritten one of the flag rush examples to run as an applet. It works fine under Eclipse, not the same JRE though, that caused security exceptions, already resolved that issue,just in case it'shelpful…)



(I have tried this config with jmetest.applet examples with the same results: runs in eclipse, doesn't in Mozilla)



<script src="http://www.java.com/js/deployJava.js"></script>

<applet code = 'runner.SceneEditorDemo6b.class'

archive ='lwjgl_util_applet.jar,lwjgl.jar,windows_natives.jar,natives.jar,jme.jar,jme-awt.jar,teszt.jar'

codebase='.'

width = 300

height = 300 />

<script language="JavaScript" src="/js/omi/jsc/s_code_remote.js"></script></



Everything is deployed locally, in the same library.



By the way…could someone please explain the difference between native.jar and windows_natives.jar?



All helpis welcome, regards, Daniel

I think you are missing a .dll in your java library path.

Hi,



You are indeed missing a DLL in your path.  Specifically lwjgl.dll (the native windows .dll).  If your deploying the applet from a web page I'm pretty sure the new method is to use the LWJGL AppletLauncher.  You can download it from the LWJGL website along with the all the other source.



http://lwjgl.org/download.php



Essentially any LWJGL applet needs the native dlls to be downloaded to the target system before it can run.  The applet launcher does all this for you then switches itself for your applet and away you go.

Thanks for the quick and useful answer, the problem is solved.  :slight_smile:


One last question:



I've tried AppletLoader as suggested,but get the followingException:

Exception in thread "AppletLoader.loaderThread" java.lang.NoClassDefFoundError: org/lwjgl/util/applet/AppletLoader$2

at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:542)

at java.lang.Thread.run(Unknown Source)



Any hints? I have simply modified the parameters accordingly. Jars are at the same dir.



<applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar, lzma.jar" codebase="." width="640" height="480">

 

    <!-- The following tags are mandatory -->

   

    <!-- Name of Applet, will be used as name of directory it is saved in, and will uniquely identify it in cache -->

    <param name="al_title" value="appletloadertest">

   

    <!-- Main Applet Class -->

    <param name="al_main" value="jmetest.awt.applet.AppletTestBoxColor">

   

    <!-- logo to paint while loading, will be centered -->

    <param name="al_logo" value="Orchid_flower.jpg">

   

    <!-- progressbar to paint while loading. Will be painted on top of logo, width clipped to percentage done -->

    <param name="al_progressbar" value="Orchid_flower.gif">

   

    <!-- List of Jars to add to classpath -->

    <param name="al_jars" value="lwjgl_applet.jar.pack.lzma, lwjgl.jar.pack.lzma, jinput.jar.pack.lzma, lwjgl_util.jar.pack.lzma, res.jar.lzma,jme.jar,jme-awt.jar, teszt.jar">

    <!-- signed windows natives jar in a jar -->

    <param name="al_windows" value="windows_natives.jar.lzma">

   

    <!-- signed linux natives jar in a jar -->

    <param name="al_linux" value="linux_natives.jar.lzma">

   

    <!-- signed mac osx natives jar in a jar -->

    <param name="al_mac" value="macosx_natives.jar.lzma">



    <!-- signed solaris natives jar in a jar -->

    <param name="al_solaris" value="solaris_natives.jar.lzma">

   

   

just thought I'd nitpick a little, its AppletLoader not AppletLauncher.



second you don't get it separately from the lwjgl site, its included with lwjgl. Its in the lwjgl_util_applet.jar, its a way to deploy lwjgl natives completely via html (no extra code needed).



as for the above post it looks like your missing the lwjgl_util_applet.jar, according to your html code above it should be in the same place as your html file.



p.s make sure your using the latest lwjgl, at least lwjgl 2.2.1 if on windows and nightly build if on linux.

Thanks for all the replies I finally managed to resolve all my issues, but one:

signing a jar: I signed my jar teszt.jar, but still get the following Exception:



Fatal error occured (5): null

java.lang.NullPointerException

at org.lwjgl.util.applet.AppletLoader.validateCertificateChain(AppletLoader.java:1142)

at org.lwjgl.util.applet.AppletLoader.extractNatives(AppletLoader.java:1118)

at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:630)

at java.lang.Thread.run(Unknown Source)



I edited my JVM-s policy file to grant AllPermission, to resolve this relative painless…but it doesn’t work. altough it worked without AppletLoader



With the first approach I was able to run my applet, very smoothly, so could someone explain me:

-  what are the benefits of using AppletLoader?



As it looks like it’s definetly not worth the pain of signing every jar, and above everything to pay to a CA…

  • is there a painless way of signing all my jars with jarsigner all myself without a CA?

    As far as I know, I should use a certificate chain and resign the jwgl and jme jars too.
  • would it be enough to sign the jars one-by-one without a chain?



    Thanks again for the help provided this far and looking forward for any sggestions.

ok, it looks like your using an older version of lwjgl (than lwjgl 2.2.1), it had a problem where it was downloading corrupt jars.



the only way to fix it now is to make sure you have lwjgl 2.2.1+ (especially the lwjgl_util_applet.jar), then either find where the appletloader is downloading the jars and manually delete them (somewhere in your temp folder) or changle al_title to something else.



remember if your signing your own jars, its good practice to clear out any existing certificate from the jars (just open the jar files and delete the META-INF folder) and resign. lwjgl_util_applet.jar and the jars that contain the native files must have the same certificates.



most painless way to sign your jars is to use something like ANT to automatically do it for you.

Hmm unfortunately I didn't read the forum often enough to spare some midnight debugging…



You were basically right, the problem was that I signed a jar with multiple certificates, deleting META-INF and resigning it solved this issue.



Until now you managed to solve a bunch of different problems related to applet deployment, I think I will update the wiki page a bit, to prevent others repeating my mistakes.



Thanks again everyone.