DirectByteBuffer ClassCastException in MacOSXOnscreenGLDrawable.lockSurface

Hello,

I’m trying to compile a java application in Mac OS X (It works in Windows).
When I run the program from the Eclipse environment, the JOGL pane fails to show up and
I get this exception:

Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: java.nio.DirectByteBuffer
at com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable.lockSurface(MacOSXOnscreenGLDrawable.java:180)
at com.sun.opengl.impl.macosx.MacOSXOnscreenGLContext.makeCurrentImpl(MacOSXOnscreenGLContext.java:57)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:134)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:265)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
at sun.awt.RepaintArea.paint(RepaintArea.java:241)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:268)
at java.awt.Component.dispatchEventImpl(Component.java:4144)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

I am using the latest released JARs and JNILIBs, specific for Mac OS X…

Any ideas?..

Regards,
Aaron Stewart
BYU chemistry software developer / student

I get the same exception under somewhat different circumstances.

I am converting from a Java Web Start application to a desktop application. The Web Start application works fine! I extracted all the jar files from the Web Start download libraries and packaged them in my install program, which installs my program nicely. On the command line, the desktop application gives me the stack trace:

dyn-25-251:PathwayEditorWebIndependent workbenchdev$ java -classpath . -jar PathwayEditorWebIndependent.jar

Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException:
java.nio.DirectByteBuffer
at
com.sun.opengl.impl.macosx.MacOSXOnscreenGLDrawable.lockSurface(MacOSXOnscreenGLDrawable.java:177)
at
com.sun.opengl.impl.macosx.MacOSXOnscreenGLContext.makeCurrentImpl(MacOSXOnscreenGLContext.java:57)
at com.sun.opengl.impl.GLContextImpl.makeCurrent(GLContextImpl.java:127)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:182)
at
javax.media.opengl.GLCanvas.maybeDoSingleThreadedWorkaround(GLCanvas.java:258)
at javax.media.opengl.GLCanvas.display(GLCanvas.java:130)
at javax.media.opengl.GLCanvas.paint(GLCanvas.java:142)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
at sun.awt.RepaintArea.paint(RepaintArea.java:241)
at apple.awt.ComponentModel.handleEvent(ComponentModel.java:268)
at java.awt.Component.dispatchEventImpl(Component.java:4144)
at java.awt.Component.dispatchEvent(Component.java:3903)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

All the jnilib files were extracted from the May 22, 2008 releases of jar files contained in http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/

FYI, the classpath in the manifest file in the PathwayEditorWebIndependent.jar file is:

Class-Path: . jogl.dll jogl_awt.dll jogl_cg.dll jogl.jar gluegen-rt.jar libgluegen-rt.jnilib libjogl.jnilib libjogl_awt.jnilib libjogl_cg.jnilib

(The installer program works on both Windows and Mac OS X)

The main window for the application displays as it should, but I can’t draw on the display panel.

I just now downloaded jogl-1.1.1-rc8-macosx-universal.zip and tried it.

The problem is gone.

–JavaBob