Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exception in initializer error in java when using Netbeans

Tags:

java

binding

pack

I am using Netbeans. I did some things with bindings and now whenever I start my program, before it even initializes the form, it gives me an error

The exception in thread main is occuring before the form is even an initialized object yet. The form is not even an object yet. Every line in my main() causes an exception. Random stuff. I don't understand it at all.

Here is the error.

    Exception in thread "main" java.lang.ExceptionInInitializerError         at obd2ner.main(obd2ner.java:26) Caused by: java.lang.ClassCastException         at java.lang.Class.cast(Class.java:2990)         at org.jdesktop.beansbinding.Binding.convertForward(Binding.java:1312)         at org.jdesktop.beansbinding.Binding.getSourceValueForTarget(Binding.java:844)         at org.jdesktop.beansbinding.Binding.refreshUnmanaged(Binding.java:1222)         at org.jdesktop.beansbinding.Binding.refresh(Binding.java:1207)         at org.jdesktop.beansbinding.AutoBinding.tryRefreshThenSave(AutoBinding.java:162)         at org.jdesktop.beansbinding.AutoBinding.bindImpl(AutoBinding.java:199)         at org.jdesktop.beansbinding.Binding.bindUnmanaged(Binding.java:959)         at org.jdesktop.beansbinding.Binding.bind(Binding.java:944)         at org.jdesktop.beansbinding.BindingGroup.bind(BindingGroup.java:143)         at OBD2nerForm.initComponents(OBD2nerForm.java:731)         at OBD2nerForm.<init>(OBD2nerForm.java:75)         at Status.<clinit>(Status.java:41)         ... 1 more Java Result: 1 

OBD2nerForm line 731 is bindingGroup.bind(); sometimes it errors out on pack();

the exception in main() does not even seem relevant because it occurs as soon as the program is run and every time I comment out a line it jumps to the next

        public void actionPerformed(ActionEvent evt) {             jFormattedTextField2ActionPerformed(evt);         }     });      jLabel8.setText("Data In Que:");      jLabel9.setFont(new Font("DejaVu Sans", 0, 14));     jLabel9.setText("FFFFFFFFFFFFFFFFFFFF");      GroupLayout jPanel5Layout = new GroupLayout(jPanel5);     jPanel5.setLayout(jPanel5Layout);     jPanel5Layout.setHorizontalGroup(         jPanel5Layout.createParallelGroup(GroupLayout.LEADING)         .add(jPanel5Layout.createSequentialGroup()             .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                 .add(jPanel5Layout.createSequentialGroup()                     .add(19, 19, 19)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jLabel7)                         .add(jLabel5)                         .add(jLabel6))                     .add(18, 18, 18)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                         .add(GroupLayout.TRAILING, jFormattedTextField1, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(GroupLayout.TRAILING, jCheckBox1)                         .add(GroupLayout.TRAILING, jCheckBox11))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField2, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox12)                         .add(jCheckBox2))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField3, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox13)                         .add(jCheckBox3))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField4, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox14)                         .add(jCheckBox4))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField5, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox15)                         .add(jCheckBox5))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField6, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox16)                         .add(jCheckBox6))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField7, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox17)                         .add(jCheckBox7))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jFormattedTextField8, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(jCheckBox18)                         .add(jCheckBox8))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                         .add(GroupLayout.TRAILING, jFormattedTextField9, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)                         .add(GroupLayout.TRAILING, jCheckBox19)                         .add(GroupLayout.TRAILING, jCheckBox9))                     .addPreferredGap(LayoutStyle.RELATED)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                         .add(jCheckBox20)                         .add(jCheckBox10)                         .add(jFormattedTextField10, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)))                 .add(jPanel5Layout.createSequentialGroup()                     .add(4, 4, 4)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                         .add(jPanel5Layout.createSequentialGroup()                             .add(jLabel8)                             .addPreferredGap(LayoutStyle.RELATED)                             .add(jLabel9, GroupLayout.PREFERRED_SIZE, 256, GroupLayout.PREFERRED_SIZE))                         .add(jSeparator1, GroupLayout.PREFERRED_SIZE, 474, GroupLayout.PREFERRED_SIZE))))             .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))         .add(GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()             .addContainerGap(346, Short.MAX_VALUE)             .add(jToggleButton3, GroupLayout.PREFERRED_SIZE, 132, GroupLayout.PREFERRED_SIZE)             .addContainerGap())     );     jPanel5Layout.setVerticalGroup(         jPanel5Layout.createParallelGroup(GroupLayout.LEADING)         .add(jPanel5Layout.createSequentialGroup()             .addContainerGap()             .add(jPanel5Layout.createParallelGroup(GroupLayout.BASELINE)                 .add(jLabel5)                 .add(jFormattedTextField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)                 .add(jFormattedTextField10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))             .addPreferredGap(LayoutStyle.RELATED)             .add(jSeparator1, GroupLayout.PREFERRED_SIZE, 0, GroupLayout.PREFERRED_SIZE)             .addPreferredGap(LayoutStyle.RELATED)             .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                 .add(jCheckBox3)                 .add(jCheckBox1)                 .add(jCheckBox2)                 .add(jCheckBox4)                 .add(jCheckBox5)                 .add(jCheckBox6)                 .add(jCheckBox7)                 .add(jCheckBox8)                 .add(jCheckBox9)                 .add(jLabel6)                 .add(jCheckBox10))             .addPreferredGap(LayoutStyle.RELATED)             .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                 .add(jPanel5Layout.createParallelGroup(GroupLayout.LEADING)                     .add(jLabel7)                     .add(jPanel5Layout.createParallelGroup(GroupLayout.TRAILING)                         .add(jCheckBox13)                         .add(jCheckBox12)                         .add(jCheckBox11)                         .add(jCheckBox14)                         .add(jCheckBox15)                         .add(jCheckBox16)                         .add(jCheckBox17)                         .add(jCheckBox18)                         .add(jCheckBox19)))                 .add(jCheckBox20))             .addPreferredGap(LayoutStyle.RELATED, 42, Short.MAX_VALUE)             .add(jPanel5Layout.createParallelGroup(GroupLayout.BASELINE)                 .add(jToggleButton3)                 .add(jLabel8)                 .add(jLabel9))             .addContainerGap())     );      jTabbedPane1.addTab("tab6", jPanel5);      add(jTabbedPane1, BorderLayout.CENTER);      bindingGroup.bind();      pack(); }// </editor-fold>        

Help, I do not understand. What information do you need from me?

Edit: It seems to all be code which I cannot touch. I should probably add that this started with Netbeans adding about 200 invalid imports import jCheckbox1 which I deleted.

like image 892
Adam Outler Avatar asked Jul 30 '10 22:07

Adam Outler


People also ask

How do I resolve exception initializer?

How to handle the ExceptionInInitializerError Error. To avoid this error, simply ensure that: static initializers of classes do not throw any unchecked exception, and that. static class variable initializations do not throw any unchecked exceptions.

What is exception in initializer error?

An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable. As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism.

How do I fix Java Lang ExceptionInInitializerError null?

We can resolve the java. lang. ExceptionInInitializerError by ensuring that static initializer block of classes does not throw any Runtime Exception. We can resolve also resolve this exception by ensuring that the initializing static variable of classes also doesn't throw any Runtime Exception.

Which exception is thrown when JVM tries to initialize a static variable?

The ExceptionInInitializerError indicates that an unexpected exception has occurred in a static initializer. Basically, when we see this exception, we should know that Java failed to evaluate a static initializer block or to instantiate a static variable.


1 Answers

You get an ExceptionInInitializerError if something goes wrong in the static initializer block.

class C {   static   {      // if something does wrong -> ExceptionInInitializerError   } } 

Because static variables are initialized in static blocks there are a source of these errors too. An example:

class C {   static int v = D.foo(); } 

=>

class C {   static int v;    static   {     v = D.foo();   } } 

So if foo() goes wild, you get a ExceptionInInitializerError.

like image 148
Christian Ullenboom Avatar answered Oct 16 '22 21:10

Christian Ullenboom