GWT module may need to be (re)compiled REDUX

GwtMaven

Gwt Problem Overview


When running in compiled mode I get this dreaded GWT Module 'mymodule' may need to be (re)compiled dialog message.

I've compiled a list of the things that others have suggested to try when given this error message by GWT running in compiled mode. I've opened the WAR file created by maven and all the files are in the right place. I confirmed this against another GWT maven project that does not get this error. However, none of the below suggestions have corrected the problem. Nor have I been able to identify what difference is missing between these two projects -- the one that works and mine that will not run in compiled mode.

What else can I try?

Gwt Solutions


Solution 1 - Gwt

Have you started the DevMode using your src/main/webapp as the "war folder"? or in other words, is there a *.nocache.js in your src/main/webapp? In that case, this file will overwrite the one produced by the GWT compiler as called by the gwt-maven-plugin.

The *.nocache.js generated by the DevMode (when no one exists, generated by a previous GWT compilation) contains only the necessary bits to launch the DevMode, and will otherwise fail with the above-mentioned error.

Solution 2 - Gwt

Look for a file called <MODULE_NAME>.nocache.js in src/main/webapp/<MODULE_NAME> and delete/rename it.

Then do your mvn package and all 'should' be fine.

This problem can occurs when you run Dev mode in Eclipse. Eclipse will generate the nocache.js file and put it under the src/main/webapp directory.

Then when you run mvn pacakge, the maven plugin create the deployment nocache.js and puts it in the right place, but then when it packages files into a war it then over-rights it's deployment nocache.js with the one Eclipse created - bummer!

Solution 3 - Gwt

I found the same issue in DevMode if there was a static link to another page in the application (i.e. myModule2.html). Because it lacked the ?gwt.codesvr=127.0.0.1:9997 string, it was interpreted as a static (already compiled) GWT app, which it was not, throwing the error code you mentioned.

enter image description here

Of course the solution is not to use hardcoded literal links, but let GWT make them for you. Hope that helps someone.

UPDATE:

This is the code that throws this error in the standard GWT *.nocache.js file.

function B() {
    var b = false;
    try {
    var c = Window.location.search;
    return (c.indexOf("gwt.hosted=") != -1 
        || (c.indexOf("gwt.codesvr=") != -1
        || Window.external && Window.external.gwtOnLoad)) 
        && c.indexOf("gwt.hybrid") == -1
    } catch (a) {}
    B = function () {
    return b
    };
    return b
}
// and later, if B() returns false, show recompile error
if (!B()) {
    try {
    alert(Pb);
    return;
    }
  ...
}

Thus, to prevent the compiler message

  • don't have gwt.hybrid in the URL
  • AND DON't have gwt.hosted=
  • OR get.codesvr=
  • OR a Window.external.getOnLoad method

So, in the case of the popup, some server code was redirecting a DevMode session url, but not adding back the "codesvr=" parameter, hence the warning was shown.

Solution 4 - Gwt

Have you compiled the source? This is a surprisingly non-obvious step. If you're using eclipse, you can compile by clicking the red toolbox icon.

Solution 5 - Gwt

You have to run mvn gwt:compile additionally to the usual mvn clean install package, as the GWT-compilation is NOT part of the maven-package-phase. This solves the annoying Javascript-(re)compile-error.

Solution 6 - Gwt

I had a similar problem. Doing mvn clean install on my GWT project got me a war file, which upon deploying in tomcat resulted in the same "GWT Module 'mymodule' may need to be (re)compiled" dialog message. I also did all the mentioned stuff in here without any success.

Doing mvn clean install -DskipTests=true did the job for me.
OR
Doing mvn clean install without invoking the generated test URL (sth. like this: http://<localIp>:53701/mymoduleJUnit.JUnit/junit-standards.html?gwt.codesvr=<localIp>:53697)

The test phase obviously did overwrite my initially created *.nocache.js via some fancy development mode url, thus packaging me a wrong *.nocache.js in the end.

Solution 7 - Gwt

My Dev mode was correctly configured and above solution didn't work. Following did solve the issue though.

Multiple steps:

  1. Update Project properties -> deployment Assembly using https://stackoverflow.com/questions/19825018/deploy-gwt-maven-project-with-eclipse-deploys-webapp-directory-instead-of-target
  2. mvn clean package
  3. mvn gwt:compile
  4. In eclipse, click on 'GWT Compile Project' -> Advacned -> Remove '-war src/main/webapp' argument and hit compile.

Output should be like this - Linking into target/project-1.0-SNAPSHOT/ModuleName

... and deployment works fine.

Solution 8 - Gwt

This could apply to all other valid Answers here too: Sometimes you may need to just do a hard/cache browser refresh (ctrl+F5) after following one of them.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJames A WilsonView Question on Stackoverflow
Solution 1 - GwtThomas BroyerView Answer on Stackoverflow
Solution 2 - GwtAdam DaviesView Answer on Stackoverflow
Solution 3 - GwtJoseph LustView Answer on Stackoverflow
Solution 4 - GwtRiley LarkView Answer on Stackoverflow
Solution 5 - GwtWolkenarchitektView Answer on Stackoverflow
Solution 6 - GwtcboppView Answer on Stackoverflow
Solution 7 - Gwttj-recessView Answer on Stackoverflow
Solution 8 - GwtcellepoView Answer on Stackoverflow