Eclipse problem: NoClassDefFoundError: javax/media/opengl/GLException

Hi, I am running Eclipse 3.2 with Aviatrix3d 2.0. I am attempting to load a VRML model into a SimpleSWTCanvas. I have included the file jogl.jar in the classpath. In my code, I first create an instance of GLCapabilities and later create an instance of a SimpleSWTCanvas. When my code runs, I get the error:

java.lang.NoClassDefFoundError: javax/media/opengl/GLException

I can see the GLException class inside the jogl jar, and GLCapabilities is there. I’ve tried making sure I have the most recent JRE (1.6), but nothing works. Can anyone help?

Thanks,
Adam

Are you using a newer version of jogl? Because if you are, you also need to have gluegen-rt.jar in your class path, as well as the native libraries for both that and jogl.jar (although missing those shouldn’t cause the problem you’re having).

I’ve had no problem with eclipse 3.2 and jogl. How are you telling Eclipse your classpath?

I am using jogl 1.1.1 rc3, the newest release I found on their site. With your advice (though I wouldn’t think that would have caused the issue) I added gluegen-rt.jar to the classpath and, just to be sure, added all four provided dlls (gluegen-rt, jogl_awt, jogl_cg, and jogl) to the project and its binary build. Unfortunately, this didn’t fix the problem.

I am incorporating the jars in the project by first copying them into the root directory then adding them via the “Add…” button under the “Classpath” heading in the “Runtime” tab of the project’s plug-in file. At that point, the jar’s packages become available to me as they are automatically added to the project’s build path.

I don’t believe this really matters, but this plug-in is not a program in itself, but is called by another plug-in. All the methods used in this jar are encapsulated here, and the plug-in that calls it only instantiates the View defined in this originating plug-in. This setup works just fine with the org.eclipse.opengl and org.eclipse.swt.opengl packages, but I needed more functionality.

Let me try to understand your setup:

  • you’ve got an Eclipse project (“project1”) which uses JOGL and Aviatrix3D to do whatever rendering is needed, and that the JOGL and GlueGen JARs and DLLs are part of the project’s classpath/java.library.path respectively
  • you’ve got another Eclipse project (“project2”) which references project1 for the purposes of providing a drawing/rendering scene/area

If this is the case, maybe as well as adding the JARs to the classpath of project1, you might also need to make them visible to other projects? Try adding the JARs to the list of items that get exported in project1’s classpath: Project Properties >> Java Build Path >> Order and Export, then tick the JARs. This way project2 can add project1’s JARs to it’s own classpath.

Unless of course they’re already being exported… hmm.

Here’s what I do and it works with jogl fine: right click on your project, go down to “build path”, select “configure build path”, select the “libraries” tab and then pick “add jar” or “add external jar”. If you expand the added jar, there will be a spot to set the native library location, edit that to wherever the dlls are placed.

The jars are added there automatically when they are added to the classpath. Adding a link to the native library location didn’t work… (though I think that wasn’t a problem). Still not working.

Almost right. Project1 is the only project that will actually reference any of these classes directly. Project2 doesn’t need to know how it’s rendering. As far as this first version is concerned, project2 does nothing but instantiate the View defined in project1. This view will automatically render a model loaded from a VRML file. I did try exporting javax.media.opengl, just to see if it would change anything, but still no luck.

I still suspect this has something to do with classpaths as ‘ClassNotFoundException’ usually means that. Do you have the full stack trace available to see where the initial cause of the exception arose? Is it in the JOGL project1 or the view-instantiating project2?

Since GLException is an unchecked exception, I imagine that project1 is throwing this without your knowledge, and when project2 catches it, it goes “GLException?!?! WTF??”

The stack trace:

java.lang.NoClassDefFoundError: javax/media/opengl/GLException
	at tsi.hybridsystems.hybridgui.ThreeDimensionalViewer.init(ThreeDimensionalViewer.java:116)
	at tsi.hybridsystems.hybridgui.ThreeDimensionalViewer.createPartControl(ThreeDimensionalViewer.java:67)
	at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:332)
	at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:197)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:566)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:290)
	at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:525)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:140)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:268)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:394)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1144)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1097)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1311)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:601)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:532)
	at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:562)
	at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:244)
	at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:815)
	at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2429)
	at org.eclipse.ui.internal.WorkbenchWindow$6.run(WorkbenchWindow.java:2616)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2597)
	at org.eclipse.ui.internal.WorkbenchWindow.busyOpenPage(WorkbenchWindow.java:658)
	at org.eclipse.ui.internal.Workbench.busyOpenWorkbenchWindow(Workbench.java:795)
	at org.eclipse.ui.internal.Workbench.doOpenFirstTimeWindow(Workbench.java:1437)
	at org.eclipse.ui.internal.Workbench.openFirstTimeWindow(Workbench.java:1388)
	at org.eclipse.ui.internal.WorkbenchConfigurer.openFirstTimeWindow(WorkbenchConfigurer.java:190)
	at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:708)
	at org.eclipse.ui.internal.Workbench.init(Workbench.java:1085)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1847)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at tsi.hybridsystems.test.Application.run(Application.java:18)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	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 org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)

tsi.hybridsystems is project1, and tsi.hybridsystems.hybridgui.ThreeDimensionalViewer is the View I’m using. GLCapabilities is in the same package as GLException, but I should get an error there first since I instantiate a GLCapabilities object before I get to the line that causes this error.

It does sound exactly like a classpath issue, but I’m beginning to wonder if there’s a bug in JOGL or something else arcane in this issue…

I just had an idea. I think it might actually be that Aviatrix3d doesn’t use this version of JOGL. I have org.j3d.opengl.swt installed, but I wasn’t using it as a dependency. After reading more carefully under the system requirements on this page: http://aviatrix3d.j3d.org/setup.html, I think it’s looking for the same things in that plug-in instead (I didn’t even know they were there). I removed the JOGL/gluegen jars and added this to the list of dependencies and found the package javax.media.opengl. Now when I run it…, I get:

java.lang.NoClassDefFoundError: javax/media/opengl/GLCapabilities

This class is already on the build path by virtue of being in the org.j3d.opengl.swt plugin. I can even find the javax.media.opengl package under “Plug-in Dependencies” in the access rules of jogl.jar. What could I be forgetting now?