Can't Initialize!

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't Initialize!

Chris
Hi,
I've set up a JOGL test app based on the tutorial, eg.

public class Test {
    public static void main(String[] args)
    {
        GLProfile.initSingleton(true);
        GLProfile glp = GLProfile.getDefault();
        GLCapabilities caps = new GLCapabilities(glp);
        GLCanvas canvas = new GLCanvas(caps);
        ...

However, when I execute this I just get the exception below. Does anyone have any idea what I'm doing wrong?

Thanks,
Chris

Exception in thread "main" java.lang.NullPointerException
        at javax.media.opengl.GLContext.getAvailableGLVersionsSet(GLContext.java:588)
        at javax.media.opengl.GLProfile.initProfilesForDevice(GLProfile.java:1218)
        at javax.media.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1192)
        at javax.media.opengl.GLProfile.access$000(GLProfile.java:66)
        at javax.media.opengl.GLProfile$1.run(GLProfile.java:111)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.media.opengl.GLProfile.initSingleton(GLProfile.java:109)
        at javax.media.opengl.GLProfile.validateInitialization(GLProfile.java:1338)
        at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:1489)
        at javax.media.opengl.GLProfile.get(GLProfile.java:548)
        at javax.media.opengl.GLProfile.getDefault(GLProfile.java:446)
        at javax.media.opengl.GLProfile.getDefault(GLProfile.java:452)
        at sim.Test.main(Test.java:15)
Exception in thread "Thread-2" java.lang.NoClassDefFoundError: Could not initialize class javax.media.opengl.GLDrawableFactory
        at javax.media.opengl.GLDrawableFactory$2.run(GLDrawableFactory.java:171)
        at java.lang.Thread.run(Unknown Source)
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

Chris
Problem solved - was missing a native library.

Would it be possible to have a more detailed/useful error message?

Cheers,
Chris.
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

François Coupal
Which library exactly? I'm having the exact same problem and I'm unable to pinpoint which one.

Is it in nativewindow? Is it in jogl-natives? I'm having an extremely long time having to guess by trial and error which library is dependant on which other in the download section?

I have space requirements and I can't just use them all, if possible...
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

François Coupal
Just to clarify, I currently have the following libraries in my build path (in Eclipse)
jogl_desktop
jogl_es1
jogl_es2
nativewindow_awt
nativewindow_x11

They all have the "lib*.so" wrappers, as I am on Linux (i386). Is there any more that are required to launch JOGL? My sample code is this:

import javax.media.opengl.GLProfile;
public class testJOGL2 {
        public static void main(String[] args) {
                System.loadLibrary("jogl_desktop");
                System.loadLibrary("jogl_es1");
                System.loadLibrary("jogl_es2");
                GLProfile.initSingleton(true);
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

Michael Bien
Hi Francois,

a few remarks:
1. don't load any library explicitly, in fact thats what GLProfile.initSingleton or any other call into the api does
2. take a look at http://jogamp.org/jogl/doc/deployment/JOGL-DEPLOYMENT.html
some libs are optional... so it all depends what parts you want to use

hope that helps,

michael

On 01/14/2011 08:41 PM, François Coupal [via jogamp] wrote:
Just to clarify, I currently have the following libraries in my build path (in Eclipse)
jogl_desktop
jogl_es1
jogl_es2
nativewindow_awt
nativewindow_x11

They all have the "lib*.so" wrappers, as I am on Linux (i386). Is there any more that are required to launch JOGL? My sample code is this:

import javax.media.opengl.GLProfile;
public class testJOGL2 {
        public static void main(String[] args) {
                System.loadLibrary("jogl_desktop");
                System.loadLibrary("jogl_es1");
                System.loadLibrary("jogl_es2");
                GLProfile.initSingleton(true);
        }
}


View message @ http://jogamp.762907.n3.nabble.com/Can-t-Initialize-tp2112742p2257924.html
To start a new topic under jogamp, email [hidden email]
To unsubscribe from jogamp, click here.

-- 
http://michael-bien.com/
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

Wade Walker
Administrator
In reply to this post by François Coupal
Hi François,

I've got detailed instructions on how to set up a JOGL 2 project in Eclipse using RCP at http://wadeawalker.wordpress.com/2010/10/09/tutorial-a-cross-platform-workbench-program-using-java-opengl-and-eclipse/.

Or, if you're not making an RCP application, here's what you need to do:

- Right-click your Eclipse project, select Properties
- Select "Java Build Path", then click the Libraries tab
- Click "Add JARs..." (if your JARs and .so files are in your project directory), or click "Add External JARs..." (if your JARs and .so files are outside your project directory)
- Add gluegen-rt.jar, jogl.all.jar, nativewindow.all.jar, and newt.all.jar this way
- For each JAR in your list, click the arrow to expand it, select "Native library location" inside it, click "Edit...", and set the "location path" to the directory that contains all your .so files. There should be 7 *.so files in the directory (libgluegen-rt.so, libjogl_desktop.so, libjogl_es1.so, libjogl_es2.so, libnativewindow_awt.so, libnativewindow_x11.so, libnewt.so)

Once this works properly, you can try removing the JARs and .so files one at a time to find the minimum you need
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

Wade Walker
Administrator
In reply to this post by François Coupal
I forgot to mention, you should follow Michael's advice too  Don't try to load the libraries like you're doing, that's handled for you automatically. Here are some simple example programs that show how to use JOGL with various windowing systems:

AWT: https://github.com/sgothel/jogl/blob/master/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsAWT.java

AWT with GLJPanel: https://github.com/sgothel/jogl/blob/master/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/gears/TestGearsGLJPanelAWT.java

SWT: http://jogamp.762907.n3.nabble.com/Render-problems-for-custom-context-menu-in-OpenGL-SWT-td2255271.html#a2256353

-w
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

François Coupal
Thanks for the replys.

I removed the manual library loads, and tested again. If I remember well, loading multiple times the same library should not impact the JVM. I could be wrong in this case, so I just deleted the lines. Same result, unfortunately. All i'm sure is that these libraries can load manually, ergo the native library path is working correctly in my setup.

From Michael, I see that the following libraries (or their equivalent in other OSes) are availiable:

Gluegen native libraries:
    * libgluegen-rt.so
NativeWindow native libraries
    * libnativewindow_awt.so
    * libnativewindow_jvm.so
    * libnativewindow_x11.so
JOGL native libraries
    * libjogl_desktop.so
    * libjogl_gl2es12.so
    * libjogl_es1.so
    * libjogl_es2.so
    * libjogl_cg.so
NEWT native libraries
    * libnewt.so

Of these, the following are needed. The others are probably extra. Good thing because I did not found them anywhere I looked on this website.

    * libgluegen-rt.so
    * libnativewindow_awt.so
    * libnativewindow_x11.so
    * libjogl_desktop.so
    * libjogl_es1.so
    * libjogl_es2.so
    * libnewt.so

I should mention that I used the JOGL 1.1.1a until very recently. In effect, these tests were the first after a refactoring to integrate JOGL 2 in a large project. I did not list them in my second post, but I had the gluegen library and the newt one as well. NEWT I did not use, but I wanted to make sure so I included it.

So far I got the same problem. I even tested it on a Windows 7 computer (I have an ANT script which detects the OS and architecture and install the native librairies in the same directory). I use Eclipse IDE to run my projects.

Of course, these libraries cannot run without their Java counterparts. Last I checked, I have the following ones:

gluegen-rt.jar
jogl.awt.jar
jogl.core.jar
jogl.util.awt.jar
jogl.util.gldesktop.jar
jogl.util.jar
nativewindow.all.jar

As you can see, I did not use the jogl.all.jar because it's size is much greater than the combined size of the five "jogl.*.jar" files I listed. I will do tests later on (next monday) with the jogl.all.jar to see if the problem could stem from there. But I doubt it since it seems the problem is the native libraries. My code compiles with the aforementioned JARs.

Thanks for the examples, but since I'm using JOGL for the last 4 years, I made a few of my own as test cases since then :-) None of them works now though...
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

Wade Walker
Administrator
Sorry for my basic-level replies François, I didn't realize you were a JOGL expert from version 1.1.1a

Have you tried testing JOGL 2 all by itself, without any of your own code? This will make it clear whether the problem is your code/setup, or JOGL 2 itself on your platform. Try something like this:

java -cp gluegen-rt.jar:nativewindow.all.jar:jogl.all.jar:newt.all.jar:jogl.test.jar:junit.jar:ant.jar:ant-junit.jar -Djava.library.path=lib com.jogamp.opengl.test.junit.jogl.demos.gl2.gears.TestGearsAWT

You'll have to adjust the paths to the JARs and libraries, of course. This will launch the Gears demo directly from the JOGL 2 installation files. If this works, you know the problem is in your setup somewhere
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

François Coupal
Yeah, that's probably what I'll do to make sure of everything. Safest road then plucking things one by one to make sure everything works fine until the wanted configuration. This is time consuming and I was hoping for a solution less about trial and error. I'll let you know how it turns out.

Whatever the results, if I may, I have a few propositions to makes things a bit easier in the same situation:
- As was stated above, a more comprehensive error message would help greatly (such as which library is missed or malfunctionning).
- A page that explains which files in the download section contains which java packages. I spent quite some time downloading many files just to see which one contained what packages (I download about 6 just to find the one containing the GLUT methods). As I said, it's not always the solution to use the "*.all.*" packages. A schema explaining how they are split would help big time.
- I was unable to read those file not ending with "*.gz". For example, I could not read the "jogl.util.jar", not even with a package browser (Ubuntu) and Java was unable to read them as well. I had to download the "jogl.util.jar.gz" file and extract the JAR from it. Not all JARs are broken that way. JARed native library files were OK.
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

François Coupal
Ok. The test runs as intended. Both from command line and Eclipse launcher using a fresh project. I'll work it from here to pinpoint the problem and share the exact breaking point once I find it (and publicly execute it...)

Thanks for the help. Much appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

Wade Walker
Administrator
Hi François,

Here are links to new wiki pages that hopefully will help address some of your concerns:

https://jogamp.org/wiki/index.php/Downloading_and_installing_JOGL
https://jogamp.org/wiki/index.php/Setting_up_an_Eclipse_project_that_uses_JOGL
https://jogamp.org/wiki/index.php/Setting_up_an_IntelliJ_IDEA_project_that_uses_JOGL

I agree that the download process is needlessly complicated right now  I mention the .gz problem you encountered on the wiki page, but hopefully that will be fixed soon.

I'm not an expert on trimming down the JOGL installation size... all my apps are desktop apps  But if you have some info on that, please post it here and I'll put it on the wiki. Right now I'm focusing on added more "getting started" stuff for entry-level users.
Reply | Threaded
Open this post in threaded view
|

Re: Can't Initialize!

François Coupal
In reply to this post by François Coupal
It was faster than I anticipated, but I got the culprit. It was not a native library thing actually: it was a missing class. I don't know which one exactly, but I do know which package it was part of.

For those interrested, I managed to run the simple program above (whithout the duplicate system loading of native libraries), which is simply to execute the "GLProfile.iniSingleton(boolean)" method, with the following files:

Java modules:
gluegen-rt.jar
jogl.core.jar
jogl.gldesktop.jar (this was the missing file that caused the NullPointerException)
jogl.os.x11.jar
nativewindows.core.jar
nativewindows.os.x11.jar

Native libraries:
libgluegen-rt.so
libjogl_desktop.so
libnativewindows_awt.so
libnativewindows_x11.so

Total size: 1.1 MB

You can probably use NEWT instead of AWT to achieve the same effect. You'll have to vary the packages for different OSes, both native and java.

In any case, this is the absolute minimal file config I could initialize JOGL 2 on Ubuntu. I'll add libraries to these for my big project until it works.

Again, thanks for the help. See ya on another thread :-)