Need help with Can't create ICOFile: Can't read bytes: 4 while creating ClientBundle

45 views
Skip to first unread message

andy_p1

unread,
May 19, 2013, 1:40:40 PM5/19/13
to google-we...@googlegroups.com
I have been trying to figure out this error for past two days but I have no idea what is happening. I am totally lost. I have stripped out everything from the project and still no lock. Here is what I have:

1. 
package test.webclient.widget;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;

public interface ImageResourceBundle extends ClientBundle{
    public static final ImageResourceBundle INSTANCE = GWT.create(ImageResourceBundle.class);
    @Source("rtick.gif") 
    ImageResource rtick(); 
}

In my Eclipse, I have put rtick.gif file in src/test/webclient/widget folder. If I don't put it here, then Eclipse shows a red squiggly underline under     @Source("rtick.gif")  so I know it is looking for it at this location.

However, when I do Google -> Compile on the project, I get the following exception:

Can't create ICOFile: Can't read bytes: 4
   Computing all possible rebind results for 'test.webclient.widget.ImageResourceBundle'
      Rebinding test.webclient.widget.ImageResourceBundle
         Invoking generator com.google.gwt.resources.rebind.context.InlineClientBundleGenerator
            [ERROR] Generator 'com.google.gwt.resources.rebind.context.InlineClientBundleGenerator' threw an exception while rebinding 'test.webclient.widget.ImageResourceBundle'
java.lang.NullPointerException
at com.google.gwt.resources.rg.ImageResourceGenerator$BundledImage.addImage(ImageResourceGenerator.java:99)


I have put this rtick.gif pretty much everywhere in the project. So I don't know where is it looking for this file?
If I don't create the ImageResourceBundle, the project compiles file and works well in the dev mode as well. Everything works. Except this ImageResourceBundle thing.

I also tried adding a new ClientBundle using the wizard. But that same error happens to that as well. 

Please please please help!

thank you for reading.

Jens

unread,
May 19, 2013, 2:28:54 PM5/19/13
to google-we...@googlegroups.com
Hm you are providing a gif file but Java (ImageIO) tries to read an ico file? Thats the first thing I would think about. Maybe your file has a wrong extension or is somehow corrupted?
What kind of libraries does your application use? Maybe one of your libraries alters the behavior of Java's ImageIO? 
Does the stack trace contain any caused by exceptions?

You could also set a breakpoint in ImageResourceGenerator.addImage() and start debugging GWT's DevMode to see whats going on.

When you have @Source("rtick.gif") then the image must be in the same package as the client bundle.

-- J.

andy_p1

unread,
May 19, 2013, 5:07:53 PM5/19/13
to google-we...@googlegroups.com
Thank you for your reply, Jens.

Yes, I think I am putting the image in the same package/location where my clientbundle class is. Otherwise, Eclipse shows error.

Regarding ICO, you are right. I thought the same and so just to make sure I created a fresh gif and png and tried with those. But it shows the same message. I don't know why it says ICOFile in the message ("Can't create ICOFile: Can't read bytes: 1") but I am pretty sure that it is not an ico file. BTW, the number of bytes in the message seems random. I have seen it say Can't read bytes: 2 as well as ICOFile: Can't read bytes: 4.

Another thing is, when I use the same gif and png in style sheet, it works fine. i.e. when I set the following style for a label , it shows up fine:

.testStyle{
    background-image: url("rtick.gif");
    background-repeat: no-repeat;
    padding-left: 15px;
    border:none;
}

Of course, I had to put it in another location for the style, but it worked. So the image file itselfs seems to be ok.

Regarding breakpoint, that's a good suggestion but I am not sure how to do that because the error is coming at compile time itself!  I get the error when I do Google ->GWT Compile. Can you please tell me how to do the compilation in debug mode?

thank you.

Reply all
Reply to author
Forward
0 new messages