GWT 2.7 Resource was located via ClassLoader. It should be registered via <source /> or <resource /> entry in your .gwt.xml

1.6k views Asked by At

I am migrating a project from gwt 2.6.1 to gwt 2.7.0, The compilation succeeded but it displays stange warning messages during the compilation

[WARN] Resource 'images/home.png' was located via ClassLoader. As a result changes in that resource will not be reflected in per-file recompiles. It should be registered via <source /> or <resource /> entry in your .gwt.xml. In a future version of GWT, we will remove this fallback and your application will stop compiling

I have an interface which extends ClientBundle

public interface HomeResources extends ClientBundle {

    @Source("images/home.png")
    ImageResource home();

}

and the path of the image file home.png is src/main/resources/images/home.png

It works well with gwt 2.6.1, but according to this warning message it won't compile anymore with the next gwt version 2.8.0.

I tried to add these tags <source /> or <resource /> in my Module.gwt.xml file but it doesn't seem to work, any suggestion to fix this behavior ?

Finally I created the folder src/main/resources/<same_package_ClientBundle>/images and placed the image in this folder, the warning message disappears

5

There are 5 answers

0
Koponkin On

In GWT your resources that you wont to use in ClientBundle should be located near the ClientBundle class. For your example:

package com.somepackage.client

public interface HomeResources extends ClientBundle {
    @Source("images/home.png")
    ImageResource home();
}

your resources should be located inside this package: com.somepackage.client.images

1
Youssef Lahoud On

The image file should be located in the source path, so if it's not the case move the image into the source path for example in a package called "Resources" in the Client package.

Otherwise try this in the gwt.xml file:

<resource path="imagefolder" />
0
Benjamin Francisoud On

I got that same warning message. Turns out there was a typo in the filename.

@Source("img/icons_actions/icon_down.png")
ImageResource iconDown();

But the actual file was: .../img/icons_actions/icon_down.PNG

Just case sensitive. Make sure it's spell exactly the same.

0
Finn On

Check the filename and resource name.

filename resource name ssLogo.png | ssLOGO(); => you've got warning.
ssLOGO.png | ssLOGO(); => Spelling check. No warning. That's it.

0
ms_rahman On

GWT compiler warning says what we need to do.

"It should be registered via or entry in your .gwt.xml."

But it doesn't say much about how to specify the path location of the image files directory. The directory path location is the relative path from .gwt.xml file.

For example

<resource path="relative/path/to/images/directory/from/current/location"/>