|
Prev: Struts taglib html:text and dynamic values problem
Next: java.net.SocketException: No buffer space available (maximum connections reached?): recv failed
From: Daniel on 16 Jun 2005 06:46 Hello, Sometimes (not very frequent thank god) I get the following NullPointerException when i start my application. If I just restart the application (i.e no change in the code) it starts fine. As you can see it is constructors that cause this. What is strange is that on the line in EventLog that causes this is this line: private JFileChooser filec= new JFileChooser(); (and in MainWindow I have private EventLog eventLog = new EventLog(); ) So what can be the issue here? Is it something I do that I should not, or is it something I don't do that I should? I kind of feel I am actually innocent of causing this, but I may be wrong of course :) any thoughts are welcome. java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:161) at javax.swing.ImageIcon.<init>(ImageIcon.java:147) at com.sun.java.swing.plaf.windows.WindowsFileChooserUI$ShortCutPanel.<init>(WindowsFileChooserUI.java:603) at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:361) at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:130) at com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:176) at javax.swing.JComponent.setUI(JComponent.java:449) at javax.swing.JFileChooser.updateUI(JFileChooser.java:1701) at javax.swing.JFileChooser.setup(JFileChooser.java:345) at javax.swing.JFileChooser.<init>(JFileChooser.java:320) at javax.swing.JFileChooser.<init>(JFileChooser.java:273) at se.wexiodisk.service.EventLog.<init>(EventLog.java:69) at se.wexiodisk.service.MainWindow.<init>(MainWindow.java:72) at se.wexiodisk.service.Diagnosetool.<init>(Diagnosetool.java:37) at se.wexiodisk.service.Diagnosetool.main(Diagnosetool.java:53) regards Daniel
From: Daniel on 16 Jun 2005 07:07 I realize, I should probably post my java version as well. so here is the output from java -version java version "1.4.2_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06) Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode) Running on windows 2000 /daniel
From: Andrew Thompson on 16 Jun 2005 07:32 On Thu, 16 Jun 2005 12:46:52 +0200, Daniel wrote: > Hello, > Sometimes (not very frequent thank god) God does not lower Himself to bit twiddling, but I see you believe in an interprogamist God. >...I get the following > NullPointerException when i start my application. It is almost impossible to interpret a stacktrace when you cannot match the line numbers in the trace back to the code snippet. Insread I suggest an SSCCE. <http://www.physci.org/codes/sscce.jsp>. >..If I just restart > the application (i.e no change in the code) it starts fine. As you > can see it is constructors that cause this. Really? >...What is strange is that on > the line in EventLog that causes this is this line: > private JFileChooser filec= new JFileChooser(); > (and in MainWindow I have > private EventLog eventLog = new EventLog(); > ) > > So what can be the issue here? Is it something I do that I should not, > or is it something I don't do that I should? Yes. > I kind of feel I am actually innocent of causing this, but I may be > wrong of course :) You almost certainly are (wrong, that is). > any thoughts are welcome. Supply an SSCCE. But then, looking at your stack trace.. > java.lang.NullPointerException > at javax.swing.ImageIcon.<init>(ImageIcon.java:161) ...images often load asynchronously in Java. You possibly need to add a MediaTracker to the image loading. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane
From: Andrew Thompson on 16 Jun 2005 08:00 On Thu, 16 Jun 2005 13:07:01 +0200, Daniel wrote: > java version "1.4.2_01" Java versions of 1.4.2 had a security flaw that was fixed in version 1.4.2_06. You should upgrade, though upgading to 1.5.0_03 makes more sense. -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane
From: Daniel on 16 Jun 2005 08:15
>>..If I just restart >> the application (i.e no change in the code) it starts fine. As you >> can see it is constructors that cause this. > >Really? yes, just a restart and all works fine. >You almost certainly are (wrong, that is). I was afraid thatwould be the case :) >> any thoughts are welcome. > >Supply an SSCCE. >But then, looking at your stack trace.. > >> java.lang.NullPointerException >> at javax.swing.ImageIcon.<init>(ImageIcon.java:161) > >..images often load asynchronously in Java. You possibly >need to add a MediaTracker to the image loading. but also, looking in the stacktrace. it is in the JFileChooser this happens. I.e out of my control. Neither of the classes that figures in this stacktrace loads any images. (classes I have written) So I can not add a MediaTracker. I will try to see if I can reproduce the problem with an SSCCE, I have not run into this problem before. Tracing back to code lines only gives you what I wrote. i.e two calls to constructors. As I said, my feeling is that it is something going wrong when the JFileChooser loads one of it's images.. But I can of course not be sure. I will probably upgrade fairly soon though, hopefully this problem will go away then. |