2 Replies Latest reply: Aug 23, 2011 2:45 AM by Mohan RSS

    java.lang.ExceptionInInitializerError

    Mohan
      The simplest code that I can think of to call JavaFX from Java throws thsi exception. I am a beginner.

      java.lang.ExceptionInInitializerError
           at com.pragmatic.concurrency.view.PhaseProjector.show(PhaseProjector.fx)
           at com.general.concurrency.Tumbler.causeTumble(Tumbler.java:24)
           at com.general.concurrency.test.PhaserTestCase.testPhaser(PhaserTestCase.java:18)
           at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:32)
      Caused by: java.lang.NullPointerException
           at javafx.scene.Node.<clinit>(Node.fx)
      public class PhaseProjector extends Phaseable{
      
      
        public override function show() : Void{
          javafx.scene.text.Text {
              x: 20
              y: 20
              content: "Hello, JavaFX!"
          }
        }
      }
      
              FXLocal.Context context = FXLocal.getContext();
              FXClassType fxct = context.findClass("com.pragmatic.concurrency.view.PhaseProjector");
              FXLocal.ObjectValue objectValue = (FXLocal.ObjectValue) fxct.newInstance();
              Phaseable phaseable =  ( Phaseable )objectValue.asObject();
              phaseable.show();
        • 1. Re: java.lang.ExceptionInInitializerError
          796440
          Sp what part of that is giving you trouble.

          The error message tells us:

          Caused by: java.lang.NullPointerException
          at javafx.scene.Node.<clinit>(Node.fx)


          that Node's constructor is throwing NPE, so I'd start by looking at where you're constructing a Node and what you're passing that might be null, or what other "global" value that the Node needs might be null.
          • 2. Re: java.lang.ExceptionInInitializerError
            Mohan
            I think if I use the junit ANT tag and call the java testcase then I get that exception.

            I am using the javafx.exe tool now from Intellij IDEA to call the same test case.
            java.lang.NoSuchMethodException: com.pragmatic.concurrency.view.PhaseProjector.javafx$run$(com.sun.javafx.runtime.sequence.Sequence)
                 at java.lang.Class.getMethod(Class.java:1605)
                 at com.sun.javafx.runtime.Entry.start(Entry.java:64)
                 at com.sun.javafx.runtime.Main.main(Main.java:80)
            I think I am unsure how to call java code that calls JavaFX code. The refliective approach is recommended though.

            I was basically trying to drive a JavaFX animation based on what happens in the Java code by calling JavaFX methods. Is that possible ?

            Edited by: Mohan on Aug 22, 2011 4:20 AM

            I am going to ask the JavaFX 2.0 forum. So here I am marking thsi answered.