View Full Version : user.agent setting is ignored during gwt compilation phase

16 Dec 2011, 6:23 AM
I have two user-agents to be used during java->js compilation

<set-property name="user.agent" value="safari,gecko1_8"/>

But for some reason, there are 6 permutations take place, no matter how many user-agents is specified.

Here is my main module configuration:

<module rename-to="xxx">

<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.user.UserAgent'/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.google.gwt.inject.Inject"/>
<inherits name="com.google.gwt.editor.Editor" />

<inherits name="com.google.gwt.uibinder.GinUiBinder"/>

<inherits name="com.gwtplatform.mvp.Mvp"/>

<define-configuration-property name="gin.ginjector" is-multi-valued="false"/>
<set-configuration-property name="gin.ginjector"

<set-property name="compiler.emulatedStack" value="true"/>
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>

<inherits name="com.gwtplatform.dispatch.Dispatch"/>
<inherits name="com.gwtplatform.dispatch.DispatchShared"/>
<inherits name="com.gwtplatform.common.ClientsCommon"/>

<inherits name='com.google.code.morphia.Morphia'/>
<source path="client"/>
<source path="shared"/>

<inherits name='com.company.xxx.Model'/>
<inherits name="com.sencha.gwt.uibinder.UiBinder"/>

<super-source path="overrides"/>

<inherits name='com.sencha.gxt.ui.GXT'/>

<inherits name="net.zschech.gwt.comet.Comet"/>

<inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG"/>

<inherits name="com.allen_sauer.gwt.log.gwt-log-RemoteLogger"/>
<!--If you wish to host your GWT application on one domain and connect your Comet client to another domain
you need to use GWT's cross site linker by including the following in your project's gwt.xml -->
<!--add-linker title="xs"/-->

<!-- Specify the app entry point class. -->
<entry-point class='com.company.xxx.client.XXX'/>

<replace-with class="com.company.xxx.client.form.TreeAppearance">
<when-type-is class="com.sencha.gxt.widget.core.client.tree.Tree.TreeAppearance"/>


Colin Alworth
16 Dec 2011, 11:59 AM
A few things may be happening here. First, I think you are probably putting the set-property tag too early in your module file. Generally, when defining a module file, start with the inherits statements, making sure they are ordered correctly (the com.sencha.gwt.uibinder.UiBinder module should be after both the GWT modules and GXT itself), and you shouldn't need to list some of those modules (UserAgent, for example is included automatically in User). Then, customizing the properties defined and configured in those earlier modules, and changing the rebind rules with replace-with and generate-with, to ensure that your rules override GWT's and GXT's rules.

Next, GXT 3 has added the capability of compiling for more browers than GWT natively supports. The GXT module compresses these (using the collapse-property element) down to the basic 6 that GWT defines. Using both GXT's collapse-property elements and your set-property (with set-property being placed after the GXT module is inherited) apparently increases the number of builds, as GWT attempts to satisfy all of the conditions we have set. This is new to me, sorry to add this next level of complexity...

So the eventual fix is for you to constrain the browsers using our own set of user agents.

<set-property name="gxt.user.agent" value="safari3,safari4,safari5,chrome,air,gecko1_8,gecko1_9"/>

will cause a build that works on all supported versions of safari,chrome, air (the webkit browsers, user.agent=safari), and supported versions of firefox (user.agent=gecko1_8). Assuming you have the GXT module inherited, this will result in two permutations.

The last thing I want to point out is a question: What are you trying so solve in doing this? If you only plan on supporting a certain number of browsers, being as specific as possible will result in only code for those browser being included. If for example you only want the latest versions of safari and firefox (not chrome nor air), the line above could read

<set-property name="gxt.user.agent" value="safari5,gecko1_9"/>

If your goal is to reduce the number of permutations, there is another trick you can do, just squish all the js into one giant permutation:


http://code.google.com/p/google-web-toolkit/wiki/SoftPermutations for more info on these changes - take a look at the com.sencha.gxt.ui.GXT and com.sencha.gxt.core.Core modules for how we are wiring all of this up.

16 Dec 2011, 2:17 PM
Thanks for a such detailed answer, Colin. What I need is to restrict the number of browsers the code is generated for, just for the sake of time and simplicity. It takes too long time to compile the code. I will try you to implement suggestions, again thanks for helping!


Colin Alworth
16 Dec 2011, 3:40 PM
If the goal is just speed of compilation, you can also tell the compiler to use draft mode - this will skip many optimizations, but speed up the compile. Used in conjunection with fewer browsers, less permutations (and more ram!) you'll get the fastest build possible.


-draftCompile will skip a number of things, including breaking split points out into their own files, so be sure to test using a regular compile.

26 Mar 2013, 6:13 AM
Our application is built on GXT3 with https url, but it is rendering in all browsers except IE8. If I add the below line, it works in IE8, but limited to show only IE8. How to address the issue to show in IE8,9 and Chrome.

<!-- Mask error message -->
<set-configuration-property name="user.agent.runtimeWarning" value="false"/>

<set-property name="gxt.user.agent" value="ie8"/>

Please throw some idea on this issue.

Colin Alworth
26 Mar 2013, 4:59 PM
The set-property line explicitly instructs GWT to *only* compile for IE8, while the first says "Don't tell me if this won't work in a particular browser". This results in apps that just don't work, with no hint as to why.

Which browsers do you want to support? If you are supporting most of the browsers out there, don't set any user.agent or gxt.user.agent, and they'll all be supported automatically.

26 Mar 2013, 6:52 PM
Thanks Colin. I inherit the module User, hence I have not explicitly added setting for the browser, but IE8 is not displaying the application and running with wait cursor indefinitely. Hence, I added this setting for IE8, 9 and Chrome. Again no luck for IE8 but works for IE9 and Chrome as expected.

<inherit ...User/>

<!-- Mask error message -->
<set-configuration-property name="user.agent.runtimeWarning" value="false"/>
<set-property name="gxt.user.agent" value="ie8,ie9,chrome"/>

Besides Index.html is referring the below meta tag, Is that causing it.
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />

27 Mar 2013, 7:42 AM
I tried change browser mode using F12, and then see the application in IE8 but I noticed that there was a class added into HTML tag.

<html class=" ext-strict" style="overflow: hidden;">

Colin Alworth
27 Mar 2013, 1:36 PM
Is your IE8 loading your app in Intranet mode? That will force IE8 to behave like IE7 which can cause issues - in your case, you aren't compiling for IE7, so the app won't load at all. The meta tag for EDGE does nothing, this is just a bug in IE8 - you must set a header to get it to recognize that you do not want it in IE7 mode.

I really don't suggest setting this line:

<set-configuration-property name="user.agent.runtimeWarning" value="false"/>
It will hide errors from you, it will prevent you from seeing what browser the app thinks it is running in.

28 Mar 2013, 6:54 AM
Thanks Colin. I have not seen any error on the screen even the line was not in the *.GWT.xml. Now I added IE7 again but no luck. If I could see an error, I would go for the fix, but I am not sure what the error is.

29 Mar 2013, 7:46 PM
I set to run with default permutations of 6, and noticed while returning user.agent from each browser as follows:
Firefox: works fine
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0

chrome: works fine
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22

safari: - works fine
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2

ie8: - loading....!
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)

Here all browsers were working fine except the last browser IE8, as I dont see what kind of error it is.

Any help?

Colin Alworth
30 Mar 2013, 6:52 PM
If I could see an error, I would go for the fix, but I am not sure what the error is.
If I could debug the app, I could possibly make suggestions ;). If you can share the *full* module file and app, I could try it out and see what is wrong. Likewise if you could compile an example in PRETTY I could try launching it and see if there is any error. Better still, break the app down to something simpler - use the same module file and a simple entrypoint - if the error doesn't happen, it has nothing to do with your module, it is in the app itself. Likewise, if the error *does* happen, then it is a configuration problem, and sharing the module file might allow me to make a suggestion.

Consider opening a support ticket if you are unable to share details on the public forum. But without more than no error, I can't begin to suggest a fix.

One last thought: any chance your IE7 test machine has issues with http://sencha.com/examples/ ? If so, it could be your test machine, not the app... If not, and you can't share details, simplify until the bug goes away - start with the module, reducing it down to the bare necessities, then the entrypoint itself.

31 Mar 2013, 3:19 PM
I could see the error after I debug as you given in the reply. Here is the stack trace of the error and it reports that the gxt.user.agent property is not found. Though I was added in the entry module like the below.
<set-property name="gxt.user.agent" value="ie6,ie7,ie8,ie9,chrome"/>


[DEBUG] [dev] - Validating units:
[DEBUG] [dev] - Rebinding com.google.gwt.useragent.client.UserAgentAsserter.UserAgentProperty
[DEBUG] [dev] - Invoking generator com.google.gwt.useragent.rebind.UserAgentGenerator
[ERROR] [dev] - Unable to get value of property 'gxt.user.agent'
[ERROR] [dev] - Unable to find value for 'user.agent'
[ERROR] [dev] - Deferred binding failed for 'com.google.gwt.useragent.client.UserAgentAsserter.UserAgentProperty'; expect subsequent failures
[ERROR] [dev] - Unable to load module entry point class com.google.gwt.useragent.client.UserAgentAsserter (see associated exception for details)
[ERROR] [dev] - Failed to load module 'dev' from user agent 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C)' at

Should I need to inherit the module UserAgentAsserter.

Colin Alworth
1 Apr 2013, 9:52 AM
There is no such module, that is a class. This error is somewhat confusing, but seems to suggest that you have mixed versions of GWT on your classpath. Your error is also changing each post - this new one looks like a classpath bug, previous to that only IE8 didn't work, but when you started only IE7 didn't work.

If you can't/won't share a test case for this and a concrete series of steps to reproduce, I can't do anything for you. As has been discussed, your errors are problem configuration or setup related, and possibly something specific to your IE setup, but if I can't see the code and you won't test other apps that work for our IE test machines (like ), I can't magically come up with the answer for code I can't see in a browser I can't access.

2 Apr 2013, 4:29 AM
I agreed that I was pointed development server through eclipse might have shown different error due to class path difference in gwt versions.

3 Apr 2013, 5:28 AM
Colin, When I press F12 to change Document Mode to IE7 standards, it's displaying in IE8 browser. I am not clear on this part of document mode changes.

Colin Alworth
3 Apr 2013, 8:39 AM
IE8 running in IE7 mode does not actually behave like IE7 - this means that if we supported it, we'd need to support IE6, IE7, IE8, IE*-behaving-like-IE7, IE9, IE9-behaving-like-IE8, IE9-behaving-like-IE7, etc... So we only support browsers behaving like themselves. Deliberately asking the browser to behave somewhat like another browser is not supported, just as setting Chrome's user agent to be Firefox, or disabling images or JavaScript.

Which version of GXT 3 are you using? I believe that as of about GXT 3.0.2 or 3.0.3 we made a fix that at least allows IE8 in IE7 mode to draw some things, but it is far from perfect, and we still do not officially support it for the reasons mentioned above.

3 Apr 2013, 10:32 AM
Thanks Colin. We have GXT 3.0.1 and GXT 2.2.5 in the module, as our older applications were built using the later one. In the recent development we have started using ui binder with GXT 3.0.1.

I would try download 3.0.2 for testing in development server.

Colin Alworth
3 Apr 2013, 10:47 AM
If you are updating, remember that GXT 3.0.4 is the latest support version, and has a number of bugs fixed (see the release notes) that were not fixed in 3.0.1 or 3.0.2.

25 Oct 2013, 1:38 PM
I'm updating my application to GXT 3.0.1 (from 2.2.5) and I guess I'm having the same issue as ramgovind.
One factor that seems to be important is that I'm using GIN.
My application is run on a https environment and after the update, it doesn't work on IE8 anymore.
On dev mode, everything is OK.

Here is what I found out so far:
If I choose to do only the IE8 permutation, it works on IE8 and doesn't on all others, like expected.
I do that with <set-property name="gxt.user.agent" value="ie8" />

But if I choose to do more than one permutation, with IE8 among them, the other ones work, but IE8 doesn't. =(

Looking at the HTML sent to the browser, I notice that what makes IE8 not to work is that the following line is not present on its <head>:
<script defer="defer">myapp.onInjectionDone('myapp')</script>
When it works on IE8 (when I do a single permutation), this line is present.

I'm not sure if I made myself clear enough.
If you need any more details, or if there is any work around this, please let me know. Thanks!

Colin Alworth
27 Oct 2013, 6:20 AM
Can you verify that your app is running in standards mode? If not, IE8 might report that it is (badly) pretending to be IE7 or 6, so the IE8 permutation cannot work for it.

As above, we do not support compatibility mode or acting like another browser besides itself.

28 Oct 2013, 11:01 AM
IE8 goes compatibility mode because of its default configuration. It goes compatibility mode for intranet sites and that's my case.

It's really weird because even unsupported, when I choose to do a single IE8 permutation, it does work on compatibility mode.
<set-property name="gxt.user.agent" value="ie8" /> <!-- This works on IE8 comp mode -->
<set-property name="gxt.user.agent" value="ie8, chrome" /> <!-- This doesn't work on IE8 comp mode -->

Do you know if there is any work around this or anything else I should try?
I didn't know compatibility mode is unsuported and I'd love to upgrade my GXT but sadly the organization I work still rely on IE8. =(

And last, great job with GXT 3. We use GXT 2 for a couple years now and it's pretty good. And this upgrade really made it way better.

Colin Alworth
28 Oct 2013, 11:15 AM
When you define exactly one value for the browser, GWT won't bother checking to see if it is right, it will just try to use it. This may cause issues with the page, but since you've explicitly told the app to treat all browsers as IE9, that is what it is going to do.

With two properties, GWT has to pick one, so it runs the selection script. In any browser that doesnt match one of those two, the page will simply fail to load at all, it won't even try, since it can't guess if firefox is closer to chrome or closer to IE8.

Two options - add support for IE7, and keep using compatibility mode (where IE8 pretends it is IE7, except doesnt get it all right), or stop using compatibility mode. While IE8 will ignore the meta tag when in intranet mode, the HTTP header still works just fine, and it is how we suggest that developers solve this problem. If using J2EE, you can use a filter like this:

public class LatestIEFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
((HttpServletResponse)resp).setHeader("X-UA-Compatible", "IE=latest");
chain.doFilter(req, resp);

public void init(FilterConfig arg0) throws ServletException {
// no-op
public void destroy() {
// no-op


28 Oct 2013, 12:49 PM
My dream choice would be to make all permutations, but IE8 didn't work with GXT 3. In GXT 2.2.5 it works.

I just tried doing permutations for IE7 and IE8 only and it didn't work either.

I have the meta tag set on HTML but as you said, IE8 doesn't look that.
Doing it with HTTP response works! Thank you for that idea.

Even tho it works we decided not to change the filter. So I'll take a look on future public releases to see if that issue starts working again.

I'd like to thank you very much for the fast replies! =D>

Colin Alworth
30 Oct 2013, 9:23 PM
GXT 2.2.5 is over two years old - a lot has changed in the browser world since then. GXT 2 also supported quirks mode, among other things that GXT 3 does not, and will not support. GWT itself dropped quirks mode in about 2.2, and so newer libraries that use GWT cannot support this. This has to be part of how we move forward to support newer browsers and modes, and begin to let go of the old ones.

We do not plan on making any changes to support compatibility mode. As GWT 2.6 is dropping support for IE 6/7, and GXT 3.1 will require GWT 2.6, GXT 3.1 will also be deprecating these older browsers. For the latest version of GXT that continues to support these older browsers, look to GXT 3.0.6.

1 Nov 2013, 1:30 PM
Thank you for your reply Colin!

I completely understand GWT and GXT decision to let go older browsers and modes and move on to newer and better stuff. And I agree with it 100%!

Sadly not everyone think or act the same way in my world. So here we still have to make worse applications just for the sake of old IEs. I'm trying to change this here and hopefully soon I'll be able to use latest GXT.

Thanks again and keep up the good work! =D>