InvocationTargetException

Hello,

I’m working on making a JOGL application that is launched via web start, like the JOGL demos.

The program compiles and runs fine on my development computer, both locally and via web start. When run from a different computer however I get a java.lang.reflect.InvocationTargetException, caused by com/sun/opengl/util/Animator. Thinking it might be something in my program I tried it with the gears demo, but got the same thing.

I did the following:

  • download the gears.java file
  • change frame.show() to frame.setVisible(true) to fix deprecation warning
  • compile with javac Gears.java
  • put the class files in [root]/demos/gears
  • put the META-INF folder from jogl-demos.jar in [root]
  • run jar cf Gears.java * to end up with a .jar file with the same structure as jogl-demos.jar
  • put it on a server, along with jogl-demos-utils.jar, jogl.jar and jogl-natives-win32.jar
  • modify Gears.jnlp and upload it.
  • upload an html page linking to the jnlp file.

The .jnlp file looks as follows:


<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="http://www.bbvh.nl/remco/" href="Gears.jnlp">
  <information>
    <title>Gears Java Test</title>
    <vendor>BBVH Architecten</vendor>
    <homepage href="www.bbvh.nl"/>
    <description>Gears Demo</description>
    <description kind="short">Gears description</description>
    <offline-allowed/>
  </information>

    <resources>
      <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
      <property name="sun.java2d.noddraw" value="true"/>
      <jar href="Gears.jar" main="true"/>
      <jar href="jogl-demos-util.jar" />
      <extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp" />
    </resources>

  <application-desc main-class="demos.gears.Gears"/>
</jnlp>

Can anyone tell me what I’m doing wrong?

Thanks in advance.

What is the stack trace from the exception?

If you’re using the extension name="jogl" ... tag then you don’t need jogl.jar or jogl-natives-*.jar on your web server. They’re pulled down from download.java.net.

I don’t see anything obviously wrong with your JNLP file. Please also post the output of jar tvf Gears.jar.

Hm. I don’t know what changed, but now other computers don’t even give the exception warning anymore, they just remain in “Starting application” forever.

This is getting annoying.
I take the official jogl-demos.jar, extract it, remove all folders except demos/gears and META-INF, put those in a new jar file, upload, and it works on all computers.
I replace the three class files in demos/gears (Gears.class, Gears$1.class and Gears$2.class) with the ones I get from compiling Gears.java (from the JOGL CVS), jar it, upload, and it only works on my own computer. Others hang at starting application.
(Note: when compiling it myself I get a Gears$1$1.class instead of a Gears$2.class, but I recon this is due to me using javac instead of Ant)
I download a decompiler, decompile the official Gears.class, fix the errors (replace utils with util in “import com.sun.opengl.utils.Animator;”, put final in front of “Animator animator = new Animator(glcanvas);” and comment out the two “super();” statements) the compiler throws at me, jar, upload, same thing.

If even the decompiled official code doesn’t work I’m starting to run out of ideas.

Anyone?

Post the full stacktrace and the jar-output of your rebundled gears-file…

jar output Gears.jar with official class files:


     0 Mon Feb 13 09:43:12 CET 2006 META-INF/
    71 Mon Feb 13 09:43:12 CET 2006 META-INF/MANIFEST.MF
     0 Mon Feb 13 09:43:02 CET 2006 demos/
     0 Mon Feb 13 09:42:52 CET 2006 demos/gears/
   747 Mon Feb 13 09:42:52 CET 2006 demos/gears/Gears$1.class
   637 Mon Feb 13 09:42:52 CET 2006 demos/gears/Gears$2.class
  7241 Mon Feb 13 09:42:52 CET 2006 demos/gears/Gears.class

jar output Gears.jar with own class files:


     0 Mon Feb 13 10:16:04 CET 2006 META-INF/
    71 Mon Feb 13 10:16:04 CET 2006 META-INF/MANIFEST.MF
     0 Mon Feb 13 09:52:50 CET 2006 demos/
     0 Mon Feb 13 09:52:50 CET 2006 demos/gears/
   681 Mon Feb 13 10:15:40 CET 2006 demos/gears/Gears$1$1.class
   698 Mon Feb 13 10:15:40 CET 2006 demos/gears/Gears$1.class
  7261 Mon Feb 13 10:15:40 CET 2006 demos/gears/Gears.class

As for the stack trace: I’m not what you’d call a Java expert, so can someone tell me how to get one? The info I’ve found about it says to press ctrl+\ at the console, which doesn’t work with a web start app. Tried setting tracelevel to 5 and enabling logging in the Java console, but neither gave any info.
When I click the link to the jnlp file java.exe and javaws.exe start up, then soon after java gets closed and after a while javaws quits too.

A stack trace is the output followed an exception (in your case the InvocationTargetException) and looks somewhat like this:


java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key MNEMONIC_Ü
	at java.util.ResourceBundle.getObject(ResourceBundle.java:326)
	at java.util.ResourceBundle.getString(ResourceBundle.java:286)
	at org.openide.awt.Mnemonics.getLatinKeycode(Mnemonics.java:159)
	at org.openide.awt.Mnemonics.setLocalizedText2(Mnemonics.java:72)
	at org.openide.awt.Mnemonics.setLocalizedText(Mnemonics.java:93)
	at org.openide.awt.Actions.setMenuText(Actions.java:251)
	at org.openide.awt.Actions$MenuBridge.updateState(Actions.java:801)
	at org.openide.awt.Actions.connect(Actions.java:131)
	at org.openide.awt.Actions.connect(Actions.java:116)

it may be necessary to activate the java console in the java webstart manager. To do so start the javaws application in the /bin folder on the machine where the exception occurs and select the “Show Java Console” option under the “Advanced” tab present in the “Preferences Dialog”, which can be invoked from the “File” Menu (or “Edit”? I have a german desktop right now :-/).

This is what I got when I turned on log to file (console itself didn’t show anything):


Java Web Start 1.4.2 Console, started Mon Feb 13 13:55:37 CET 2006
Java 2 Runtime Environment: Version 1.4.2 by Sun Microsystems Inc.
Logging to file: C:\java.txt
java.lang.UnsupportedClassVersionError: demos/gears/Gears (Unsupported major.minor version 49.0)
	at java.lang.ClassLoader.defineClass0(Native Method)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at com.sun.jnlp.JNLPClassLoader.defineClass(Unknown Source)
	at com.sun.jnlp.JNLPClassLoader.access$100(Unknown Source)
	at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
	at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
	at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
	at com.sun.javaws.Launcher.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

This helps :wink:

The class version “49.0” specifies classes that are compiled for java version 1.5, so you can’t execute them with a 1.4 jdk. You have to change the language-support-level to version 1.4 in your IDE or compile manually, since this defaults to version 1.3 language level.

See javac options for details.

Right, recompiled for 1.4 and that solved the problem of nothing happening.

Now I’m back to an error similar to what I had before, although it no longer says TargetInvocationError


An error occurred while launching/running the application.

Title: Gears Java Test
Vendor: BBVH Architecten
Category: Unexpected Error

com/sun/opengl/util/Animator


java.lang.NoClassDefFoundError: com/sun/opengl/util/Animator

	at demos.gears.Gears.main(Gears.java:26)

	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.continueLaunch(Unknown Source)

	at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)

	at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)

	at com.sun.javaws.Launcher.run(Unknown Source)

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

Check in the javaws application, if the jogl extension is properly installed. Lookout for some old jogl.jars in the PATH or somewhere beneath the JRE installation folder.

You are compiling your application with the wrong jogl version and may have the old jogl version somewhere in the JRE or on your systems PATH environment.

this is wrong:

com/sun/opengl/util/Animator

it should be:

com/sun/opengl/utils/Animator

Correct your compile and runtime environment and try again. I know there are several places that advise to put the jogl.jar in the lib/ext folder of the JRE, but one really shouldn’t, since it leads to strange bugs like this.

When I replace util with utils, I get a “package does not exist error”. This is most likely due to having jogl.jar under jdk1.5.0_06/bin/ext and jre1.5.0_06/bin/ext. Could you tell me/give me a link explaining what the correct locations are for the various files? (jogl.jar and the 3 dll files). When I installed java and jogl most information I found was out of date (referred to java.games.opengl.net, had only 2 out of 3 dll files, etc.)

Preparation

  • download the latest jogl release
  • create a jogl folder somewhere (eg. “C:/development/libraries/jogl”)
  • put the jogl.jar and the unzipped jogl native libraries into it

In your IDE

  • add the jogl.jar to your project’s compile and run classpath
  • set the execution working dir to the jogl folder

That’s it

Optional
If you want to create a standalone double clickable version of your app (not via webstart), create a “manifest.mf” with the following content:


Manifest-Version: 1.0
Created-By: Me
Main-Class: my.apps.package.MyMainClass
Class-Path: jogl.jar

and add it to your jar-command (-m)

copy the content of your jogl folder along with your apps jar, so you have


MyAppsExecutable.jar
jogl.jar
jogl.dll
jogl_awt.dll
jogl_cg.dll (if you use NVidia CG)

double click “MyAppsExecutable.jar”
done

The issue with util vs. utils is a problem with the current JOGL release build. Since JSR-231 beta 2 we renamed the package com.sun.opengl.utils to com.sun.opengl.util. You need to make sure you’re building and running with the same version of JOGL. Sorry about the confusion in this area; it should be cleared up in JSR-231 beta 3.

Have removed all jogl-related files from my c drive and now I get the same problem on my development machine as well. Using utils gives me a critical error, util gives an InvocationTargetException.

Directory structure:


jogl
    jar
        demos
            gears
                Gears$1$1.class
                Gears$1.class
                Gears.class
        META-INF
            MANIFEST.MF
        Gears.jar
    source
        Gears.java
    compile.bat
    jar.bat
    jogl.dll
    jogl.jar
    jogl_awt.dll
    jogl_cg.dll
    run.bar

compile.bat:


cd\
cd jogl
javac -target 1.4 -source 1.4 -d jar -classpath jogl.jar source\Gears.java
pause

jar.bat:


cd\
cd jogl
cd jar
jar cf Gears.jar *
pause

run.bat:


cd\
cd jogl
java -classpath jogl.jar;jar\Gears.jar demos.gears.Gears
pause

Gears.java:
from official site.

When I run it locally with run.bat it works as expected. When I upload the jar file and run it via webstart I get the invocationtargetexception.

ftp structure:


remco
    Gears.jar
    Gears.jnlp
    index.html
    jogl-demos-util.jar

Gears.jnlp:


<?xml version="1.0" encoding="utf-8"?>
<jnlp codebase="http://www.bbvh.nl/remco/" href="Gears.jnlp">
  <information>
    <title>Gears Java Test</title>
    <vendor>BBVH Architecten</vendor>
    <homepage href="www.bbvh.nl"/>
    <description>Gears Demo</description>
    <description kind="short">Gears description</description>
    <offline-allowed/>
  </information>

    <resources>
      <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
      <property name="sun.java2d.noddraw" value="true"/>
      <jar href="Gears.jar" main="true"/>
      <jar href="jogl-demos-util.jar" />
      <extension name="jogl" href="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp" />
    </resources>

  <application-desc main-class="demos.gears.Gears"/>
</jnlp>

As Ken points out, they renamed “utils” to “util”. The jar you use for development seems to be the new one (nightly build?), so you can only compile your sources using the “util” package. The jar referenced in the webstart jogl extension however is the “older” beta2 release, so it’s the version with “utils” in it. The only way to overcome this problem is either to use the older beta2 version for building or to wait for the beta3 release to be available as webstart extension.

You can download the beta2 here

Aha. Thanks for the explanation.

Tried downloading the beta2 jogl.jar and jogl-demo-utils.jar and putting the in the project folder. Compiling goes fine, but trying to run gives a


Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: glGenLists
        at com.sun.opengl.impl.GLImpl.glGenLists(Native Method)
        at demos.gears.Gears.init(Gears.java:71)
        at com.sun.opengl.impl.GLDrawableHelper.init(GLDrawableHelper.java:71)
        at javax.media.opengl.GLCanvas$InitAction.run(GLCanvas.java:242)
        at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:123)
        at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:236)
        at javax.media.opengl.GLCanvas.display(GLCanvas.java:127)
        at javax.media.opengl.GLCanvas.paint(GLCanvas.java:139)
        at sun.awt.RepaintArea.paintComponent(Unknown Source)
        at sun.awt.RepaintArea.paint(Unknown Source)
        at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

Is there an ETA for beta3 yet?

I guess you haven’t also downloaded the native libraries, do you?

Doh :slight_smile:

Finally got it working locally and via web start. I want to thank you all very much for all your help. Now to port the whole application over to Java :slight_smile: