It should be registered via <source /> or <resource /> entry in your .gwt.xml ?

1,567 views
Skip to first unread message

Ed

unread,
Mar 4, 2015, 5:44:55 PM3/4/15
to google-we...@googlegroups.com
I include a background image in a css file through a @sprite annotation and do get a warning (see subject and below) that it should be included in the gwt.xml gwt file.
How should this be done? The documentation still describes it like I use it below that results in a warning.
Details:

Css file:
@sprite .Bla {
  gwt
-sprite: "quickCheck";
}

And in the ClienBundle class it's included as:
 @Source("quickCheck.jpg")
 
ImageResource quickCheck();


And get the following console warning:

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



Thomas Broyer

unread,
Mar 5, 2015, 5:18:50 AM3/5/15
to google-we...@googlegroups.com
Doesn't it start with "Resource '…quickCheck.jpg' was located via ClassLoader" ?

That happens when the resource is not available from the "ResourceOracle", but is in the classpath. Do you have include/exclude/skip patterns in your <source/> ?
Also, do you get this warning in DevMode or when compiling? (or both)

Christian Walczyk

unread,
Mar 5, 2015, 12:18:50 PM3/5/15
to google-we...@googlegroups.com
I got rid of this warning by removing the @Source annotation completely and placing the image file into the same package. The image file must have the same name and ends with .png or .gif

Ed

unread,
Mar 6, 2015, 4:21:41 AM3/6/15
to google-we...@googlegroups.com
I just noticed that I made a really stupid mistake. 
The jpg file it was looking for was "quickcheck.jpg" and the one present is "quickCheck.jpg" (with Capital "C").
So the original code:

@Source("quickcheck.jpg")
ImageResource quickCheck();

I just noticed this isn't the same as the code that I posted above, which surprised me. No idea why, maybe wrong copy/paste during changing or typed it wrong, can't remember.

Only the gwt error in the console is a bit misleading (and that it could find the file anyway, on a Mac).
Thanks for the help, sorry for the stupid mistake (after correcting the file name, the error message disappeared).

MacWiz

unread,
Mar 24, 2015, 11:14:30 AM3/24/15
to google-we...@googlegroups.com
Since upgrading to GWT 2.7.0, we continue to struggle with how to eliminate these warnings.  We get 10 warnings like the following:

     [java]             Preparing method appEdir
     [java]                [WARN] Resource 'org/kablink/teaming/gwt/public/images/LdapBrowser/eDir.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

with the 10th warning following by the following:

     [java]                [WARN] Suppressing further ClassLoader resource load warnings.

I'm guessing we'd see this for ALL the images defined in our classes that extend ClientBundle as all are defined in a similar way.  All of our images are defined using the following pattern:

@ImageOptions(repeatStyle = RepeatStyle.Both)
@Source("org/kablink/teaming/gwt/public/images/LdapBrowser/eDir.png")
public ImageResource appEdir();

(this ImageResource corresponds to the warning listed above.)

We've tried several different ways of adding <source> and <resource> tags to our module XML with no success in eliminating these warnings.  Can anybody suggest how a <source> (or <resource>) tag should be structured in our module XML to eliminate them?  Note that at this point, this is purely a cosmetic issue in that everything works (all the images load and display correctly.)  We'd simply like to eliminate the compilation warnings (and be ready to move to future versions of GWT as they become available.

Thanks!

Thomas Broyer

unread,
Mar 24, 2015, 11:34:36 AM3/24/15
to google-we...@googlegroups.com
2 things:

  • is there a reason for having your images in your "public path" (assuming your module is rooted in org.kablink.teaming.gwt, then org/kablink/teaming/gwt/public would be the default value for the "public path"), as you're using them in a ClientBundle? if not, then move them out of the public path and in the source path (common practice is to put them next to the ClientBundle interface)
  • assuming your module is in org.kablink.teaming.gwt, it should be either <source path="public"/> or <resource path="public"/>. You can find an example in com.google.gwt.uibinder.UiBinder: https://gwt.googlesource.com/gwt/+/2.7.0/user/src/com/google/gwt/uibinder/UiBinder.gwt.xml (FYI, the <public/> is useless and was added mechanically when adding -enforceStrictResources)
 

MacWiz

unread,
Mar 24, 2015, 1:58:01 PM3/24/15
to google-we...@googlegroups.com
Thanks Thomas.  Adding a <resource path="public" /> fixed these.  I thought I had tried that, but apparently not.  As far as the location of the images, we are discussing moving them, as you suggest.  They've been in our public area since the beginning of our GWT based work many years ago (starting with GWT v1.3, I believe.)

cellepo

unread,
Dec 30, 2015, 6:45:11 PM12/30/15
to GWT Users
It doesn't look like <resource /> is a possible Element type in GWT 2.7?

I can add <source />, but when I add a <resource />...
The content of element type "module" must match "(inherits|source|public|super-source|entry-point|stylesheet|
 script|servlet|replace-with|generate-with|define-property|extend-property|set-property|set-property-fallback|
 clear-configuration-property|define-configuration-property|extend-configuration-property|set-configuration-
 property|property-provider|define-linker|add-linker|collapse-all-properties|collapse-property)*".
 
Unless I'm missing it, I don't see resource in that list, which seems to be why I can't add a <resource \>.  Unless I'm missing something? 

Thomas Broyer

unread,
Dec 30, 2015, 7:22:44 PM12/30/15
to GWT Users


On Thursday, December 31, 2015 at 12:45:11 AM UTC+1, cellepo wrote:
It doesn't look like <resource /> is a possible Element type in GWT 2.7?

I can add <source />, but when I add a <resource />...
The content of element type "module" must match "(inherits|source|public|super-source|entry-point|stylesheet|
 script|servlet|replace-with|generate-with|define-property|extend-property|set-property|set-property-fallback|
 clear-configuration-property|define-configuration-property|extend-configuration-property|set-configuration-
 property|property-provider|define-linker|add-linker|collapse-all-properties|collapse-property)*".
 
Unless I'm missing it, I don't see resource in that list, which seems to be why I can't add a <resource \>.  Unless I'm missing something? 

GWT doesn't validate the XML (using a DTD or schema); so this error message doesn't come from GWT.
…and yes the DTD is out of date. Patch welcome (real "schema" is defined in ModuleDefSchema class)

Brandon Donnelson

unread,
Dec 31, 2015, 1:20:11 PM12/31/15
to GWT Users
Reply all
Reply to author
Forward
0 new messages