THIS PIECE OF CODE SUDDENLY STARTED FAILING FOR SOME IMAGES, IT USED TO WORK FINE. THE IMAGES ARE AVAILABLE, AND THE SAME STUFF WORKS PERFECTLY WHEN ACCESSED FROM A REMOTE BOX.
AT FIRST I SUSPECTED ON MISSING JAR, SO I CHECKED MY CLASSPATH MANY TIMES, BUT NO, IT FAILS ONLY FOR A FEW IMAGES - YET I COULD NOT SEE ANY DIFFERENCE BETWEEN UNSUCCESSFUL AND SUCCESFUL IMAGES - AGAIN, EVERYTHING WORKED SMOOTHLY TILL YESTERDAY.
private java.awt.Image loadImage(String name){
try {
DPUtility.println("DPDataSelection -- loadImage 1"); // SB
java.net.URL url = getClass().getResource(name);
DPUtility.println("DPDataSelection -- loadImage 2"); // SB
return createImage((java.awt.image.ImageProducer)url.getContent());
}
catch(Exception eLoadImage){
DPUtility.println("DSB :\t ERROR :> DevPro - Image could not be loaded: " + name);
eLoadImage.printStackTrace(); // SB
return null;
}
}
HERE FOLLOWS THE OUTPUT:
DPDataSelection -- loadImage 1
DPDataSelection -- loadImage 2
DSB : ERROR :> DevPro - Image could not be loaded: trying.gif
java.lang.NullPointerException
at devpro.beans.DPDataSelection.loadImage(DPDataSelection.java:286)
at devpro.beans.DPDataSelection.<init>(DPDataSelection.java:226)
at DPRFTApplet.<init>(DPRFTApplet.java:435)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at devpro.beans.DPDataSelection.<init>(DPDataSelection.java:226)
at DPRFTApplet.<init>(DPRFTApplet.java:435)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
AT FIRST I SUSPECTED ON MISSING JAR, SO I CHECKED MY CLASSPATH MANY TIMES, BUT NO, IT FAILS ONLY FOR A FEW IMAGES - YET I COULD NOT SEE ANY DIFFERENCE BETWEEN UNSUCCESSFUL AND SUCCESFUL IMAGES - AGAIN, EVERYTHING WORKED SMOOTHLY TILL YESTERDAY.
private java.awt.Image loadImage(String name){
try {
DPUtility.println("DPDataSelection -- loadImage 1"); // SB
java.net.URL url = getClass().getResource(name);
DPUtility.println("DPDataSelection -- loadImage 2"); // SB
return createImage((java.awt.image.ImageProducer)url.getContent());
}
catch(Exception eLoadImage){
DPUtility.println("DSB :\t ERROR :> DevPro - Image could not be loaded: " + name);
eLoadImage.printStackTrace(); // SB
return null;
}
}
HERE FOLLOWS THE OUTPUT:
DPDataSelection -- loadImage 1
DPDataSelection -- loadImage 2
DSB : ERROR :> DevPro - Image could not be loaded: trying.gif
java.lang.NullPointerException
at devpro.beans.DPDataSelection.loadImage(DPDataSelection.java:286)
at devpro.beans.DPDataSelection.<init>(DPDataSelection.java:226)
at DPRFTApplet.<init>(DPRFTApplet.java:435)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at devpro.beans.DPDataSelection.<init>(DPDataSelection.java:226)
at DPRFTApplet.<init>(DPRFTApplet.java:435)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)