[SOLVED] Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME

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

[SOLVED] Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME

Djak
This post was updated on .
Hi :)
I'd like to migrate an engine from JOGL 2.0 to 2.3.1 and I have some difficulties so I tried the base test code of OneTrianleAWT:

----
package gengine2d.jogl;

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;

public class MainOneTriangleAWT {
       
         protected static void setup( GL2 gl2, int width, int height ) {
                gl2.glMatrixMode( GL2.GL_PROJECTION );
                gl2.glLoadIdentity();

                // coordinate system origin at lower left with width and height same as the window
                GLU glu = new GLU();
                glu.gluOrtho2D( 0.0f, width, 0.0f, height );

                gl2.glMatrixMode( GL2.GL_MODELVIEW );
                gl2.glLoadIdentity();

                gl2.glViewport( 0, 0, width, height );
            }

            protected static void render( GL2 gl2, int width, int height ) {
                gl2.glClear( GL.GL_COLOR_BUFFER_BIT );

                // draw a triangle filling the window
                gl2.glLoadIdentity();
                gl2.glBegin( GL.GL_TRIANGLES );
                gl2.glColor3f( 1, 0, 0 );
                gl2.glVertex2f( 0, 0 );
                gl2.glColor3f( 0, 1, 0 );
                gl2.glVertex2f( width, 0 );
                gl2.glColor3f( 0, 0, 1 );
                gl2.glVertex2f( width / 2, height );
                gl2.glEnd();
            }
       
          public static void main( String [] args ) {
                GLProfile glprofile = GLProfile.getDefault();
                GLCapabilities glcapabilities = new GLCapabilities( glprofile );
                final GLCanvas glcanvas = new GLCanvas( glcapabilities );

                glcanvas.addGLEventListener( new GLEventListener() {
                   
                    @Override
                    public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {
                    setup( glautodrawable.getGL().getGL2(), width, height );
                    }
                   
                    @Override
                    public void init( GLAutoDrawable glautodrawable ) {
                    }
                   
                    @Override
                    public void dispose( GLAutoDrawable glautodrawable ) {
                    }
                   
                    @Override
                    public void display( GLAutoDrawable glautodrawable ) {
                        render( glautodrawable.getGL().getGL2(), glautodrawable.getSurfaceWidth(), glautodrawable.getSurfaceHeight() );
                    }
                });

                final Frame frame = new Frame( "One Triangle AWT" );
                frame.add( glcanvas );
                frame.addWindowListener( new WindowAdapter() {
                    public void windowClosing( WindowEvent windowevent ) {
                        frame.remove( glcanvas );
                        frame.dispose();
                        System.exit( 0 );
                    }
                });

                frame.setSize( 640, 480 );
                frame.setVisible( true );
            }
}
-----

With this code I have this exception when running the application (using Java 7 and Windows 32bit):

---
Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME
        at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:209)
        at com.jogamp.opengl.GLProfile.getProfileMap(GLProfile.java:2272)
        at com.jogamp.opengl.GLProfile.get(GLProfile.java:987)
        at com.jogamp.opengl.GLProfile.getDefault(GLProfile.java:721)
        at com.jogamp.opengl.GLProfile.getDefault(GLProfile.java:732)
        at gengine2d.jogl.MainOneTriangleAWT.main(MainOneTriangleAWT.java:48)
---


Here is what I linked to the project:
jogamp-all-platforms\jar\gluegen.jar
jogamp-all-platforms\jar\jogl-all.jar

and the natives library path for both jars:
jogamp-all-platforms\jar


I also tried gluegen-rt.jar instead of gluegen.jar but got the same exception.
(Could also anyone tell me the difference between gluegen-rt.jar and gluegen.jar ?)

Thank you in advance.
Djak


[EDIT] If I use my original code that I want to migrate :

---
MainTextsConsole jogl = new MainTextsConsole(new JOGLFixedPipelineRenderer2d(new GLCanvas()));
---

I get this error:

----
Exception in thread "main" java.lang.VerifyError: (class: com/jogamp/opengl/awt/GLCanvas, method: getContext signature: ()Lcom/jogamp/opengl/GLContext;) Wrong return type in function
        at gengine2d.base.MainTextsConsole.main(MainTextsConsole.java:310)
---

due to "new GLCanvas()" call.



Reply | Threaded
Open this post in threaded view
|

Re: Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME

elect
Hi Djak,

you shouldn't use deprecated OpenGL, if you want, here is a modern Hello Triangle
Reply | Threaded
Open this post in threaded view
|

Re: Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME

Djak
This post was updated on .
Hi elect,
thanks for your advice but I also need to use fixed pipeline on some targets :) therefore I have multi renderer implementations.

About my problem, I really don't understand the "java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME" error. I decompiled com.jogamp.common.util.ReflectionUtil.class of the gluegen-rt.jar that I use to be sure, and the field is well present and public :/

[EDIT]
I also just tested to put:
---
  System.out.println("MainOneTriangleAWT.main(): " + ReflectionUtil.DEBUG);
  System.out.println("MainOneTriangleAWT.main(): " + ReflectionUtil.DEBUG_STATS_FORNAME);
---  

in the main but I have this output:

---
MainOneTriangleAWT.main(): false
Exception in thread "main"
java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME
        at gengine2d.jogl.MainOneTriangleAWT.main(MainOneTriangleAWT.java:51)
---
Reply | Threaded
Open this post in threaded view
|

Re: Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME

jmaasing
Then maybe you have wrong version of JOGL in your ext/lib directory. It happens on Mac since Apple distributed an old JOGL version.
Reply | Threaded
Open this post in threaded view
|

[SOLVED] Re: Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME

Djak
This post was updated on .
Thanks for the tip :) I was looking for something like that too because I saw that ReflectionUtil.DEBUG_STATS_FORNAME field doesn't exist in JOGL 2.0.
Actually I launch the code from Eclipse using a User Library I named JOGL2.3.1.
My old user library was named JOGL2.0.
For unknown reason it seems that when I link the user library JOGL2.3.1 to a project, when launching it, the JOGL2.3.1\jogl-all.jar is used but the JOGL2.0\gluegen-rt.jar is used.I even tested to run "eclipse -clean", etc.
The solution I found is to rename the real directory of JOGL2.0 user library so that Eclipse doesn't find it.
It looks like a bug of Eclipse but I do not understand it. Another workaround may be to delete the old user library.
All work fine now!
Thank you for reading and help.

[EDIT] more precisions :)
My test Eclipse project used some other required projects that used user library JOGL2.0 leading to the behavior explained above.