getAWTgraphicsconfiguration() causes NPE error

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

getAWTgraphicsconfiguration() causes NPE error

Mr. Broccoli
Hi,

I was advised to search help on below on this forum.
Would anybody be able to help me with the question I placed on StackOverflow?

https://stackoverflow.com/questions/69775554/getawtgraphicsconfiguration-returns-null-error

Kind regards, Mr. B
Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

philjord
Hi,
Thanks for posting the question.

This is a config issue, which I'll see if I can give you some debug code for to find out what's happening.

In the mean time your code works fine, I've cut and paste and it runs "out of the box" for me.

You can do it in a single java file just put the main method at the bottom of tuval7 class.

Also you'll want to add the noerasebackground property to stop awt from blocking the 3d view like so:

public static void main(String[] args) {
    System.setProperty("sun.awt.noerasebackground", "true");
        new tuval7();
    }



Your bug is happening here (as you've provided)
https://github.com/hharrison/java3d-core/blob/master/src/javax/media/j3d/JoglPipeline.java#L8291
so the cause is a null coming from the config table above, either
GraphicsConfiguration gconfig is no good,
or
Canvas3D.graphicsConfigTable has nothing compatible in it


Given that you have the jogamp-fat.jar file, can you run it with java and paste the output in a reply below

So just run a command like this in the folder that jogamp-fat is in
java -jar jogamp-fat2.4.0.jar 2> output.txt

It should spew out a bunch of config settings available on your machine (or perhaps an error)

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

Mr. Broccoli
Hi Phil,

Thanks for caring! : )

Not sure if it matters, but my jogamp-fat.jar file has a bit different name ('out of a 7z') than in your command.
When I run slightly altered command it revealed version 2.4 so I suppose it's irrelevant, true?

Here's the config, no error.

output.txt

Thanks

Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

philjord
That's great, your environment is almost the same as mine.

The next step is probably to investigate Julien's suggestion on stackoverflow of checking for unexpected jar files in the load

It's not easy to get a jar listing out of Java, it depends a bit on your IDE.
I'm using Eclipse and the run configurations dialog has a "Show Command Line"

Which gives me
C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe
-Dfile.encoding=Cp1252
-classpath "E:\Java3D\workspace-1.6\test\bin;C:\Users\pjnz\.m2\repository\org\jogamp\jogl\jogl-all\2.3.2\jogl-all-2.3.2.jar;C:\Users\pjnz\.m2\repository\org\jogamp\gluegen\gluegen-rt\2.3.2\gluegen-rt-2.3.2.jar;C:\Users\pjnz\git\java3d-utils-1.6.0\bin;C:\Users\pjnz\git\java3d-core-1.6.0\bin;C:\Users\pjnz\git\vecmath-1.6.0\bin;E:\Java3D\workspace-1.6\java3d-examples\bin" _testcase.tuval7

so I notice I'm using the maven 2.3.2 version of jogl (just randomly I guess)

If the above doesn't give a clue about other jars on the classpath you could try witht eh 2.3.2 fat jar instead here:
https://jogamp.org/deployment/jogamp-current/archive/jogamp-fat-all.7z
Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

Mr. Broccoli
Hi Phil,

I couldn't find a command to list attached jars in Netbeans, but when checking project properties, classpath is listed there. I took a snippet - see attached:
libs.PNG
Is this enough to convince you no obsolete versions are taken into account on run time?

When I swap 'fat' jar with the one you gave me a link to, the error in Netbeans changes to:
new_errors.txt
Maybe this could give you a clue you need to solve this puzzle?

Since I have Eclipse already installed, I just created a new project there and the code runs, but spews a few warnings:
eclipse_warning.PNG
Are these warnings serious (I don't know what reflective access is yet)?
If it's easier to configure it properly in Eclipse and get rid of these warnings, I can switch IDEs to make it work.

Kind regards, Mr. B.


Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

philjord
Mr. B.

The Illegal reflexive access isn't currently a problem, I just it was added originally to Java3D to allow new Pipelines (like JoglPipeline) to be loaded at runtime, like code injection on application servers, and it's 100% useless now, so in a future build I'll just swap it for a simple switch case.

If it's running in Eclipse then I'm still pondering unusual jar loading (sorry to harp on).

Sometimes the extension directory can be trouble could you swap your main call to this and see what it produces?

public static void main(String[] args) {
   
    String extdir = System.getProperty("java.ext.dirs");
    System.out.println(extdir);
    String[] extdirs = extdir.split(";");
    for(String eds : extdirs) {
            File ed = new File(eds);
            System.out.println("ed "+ed);
            System.out.println(""+ed.exists());
            if(ed.exists()) {
            for(File f : ed.listFiles()) {
            System.out.println(" f: "+ f.getName());
            }    
            }    
    }
   
   
    System.setProperty("sun.awt.noerasebackground", "true");
        new tuval7();
    }



For me I get:

C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
ed C:\Program Files\Java\jdk1.8.0_25\jre\lib\ext
true
 f: access-bridge-64.jar
 f: cldrdata.jar
 f: dnsns.jar
 f: jaccess.jar
 f: jfxrt.jar
 f: localedata.jar
 f: meta-index
 f: nashorn.jar
 f: sunec.jar
 f: sunjce_provider.jar
 f: sunmscapi.jar
 f: sunpkcs11.jar
 f: zipfs.jar
ed C:\WINDOWS\Sun\Java\lib\ext
false

Thanks,
Phil.
Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

Mr. Broccoli
Phil,

It produces:

null
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.split(String)" because "extdir" is null
        at tuval1.main(tuval1.java:12)
C:\Users\PC\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\PC\AppData\Local\NetBeans\Cache\12.4\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 0 seconds)

Regards, Mr. B.
Reply | Threaded
Open this post in threaded view
|

Re: getAWTgraphicsconfiguration() causes NPE error

gouessej
Administrator
There is no extension mechanism in your version of Java, it was removed in Java 9 (no extdir property as a consequence). Check that you didn't put JARs into your JRE too.
Julien Gouesse | Personal blog | Website