GWT module may need to be (re)compiled REDUX
Asked Answered
B

8

59

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?

Bouquet answered 19/4, 2011 at 15:50 Comment(0)
K
53

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.

Kith answered 21/4, 2011 at 14:59 Comment(6)
good idea, and yes I do. I had added an additional configuration for maven-clean-plugin to delete src/main/webapp/WEB-INF/classes. After your suggestion I just added src/main/webapp/SpringGridGui as I should have from the start. deleting this working directory was the fix. Thank you Thomas!Bouquet
Much better to follow the recommendations and launch the DevMode with the target/myapp-0.0.1-SNAPSHOT/ as the "war folder" code.google.com/eclipse/docs/faq.html#gwt_with_mavenKith
Where in this link : code.google.com/eclipse/docs/faq.html#gwt_with_maven do they mention anything about setting the war directory for DevMode?Royston
See web.archive.org/web/20130619170526/https://…Kith
I don't understand where's the answer in this post. So should I delete the file? Or what am I supposed to do? (actually deleting the file rendered application non-functional)Hyposthenia
When using Maven, you shouldn't generate output into your input folders. You shouldn't create a *.nocache.js in your sources, it should only live in your "target". You shouldn't use src/main/webapp as a target of anything, it's input, not output.Kith
H
16

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!

Heathen answered 30/4, 2012 at 13:22 Comment(1)
This was so helpful, thanks for the explanation. Had this problem after following this: https://mcmap.net/q/331232/-gwt-beginner-error-quot-could-not-find-any-host-pages-in-project-39Fixer
S
5

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.

Shawn answered 18/3, 2012 at 4:13 Comment(0)
E
2

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.

Erasme answered 20/4, 2011 at 4:3 Comment(1)
The mvn package command creates the war for running compiled mode. I've opened the resulting war, and seen the mymodule.nocache.html and the *.cache.htmlBouquet
R
2

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.

Reflate answered 22/1, 2012 at 16:31 Comment(2)
Is mvn gwt:compile the same as: right-click project -> Google -> GWT Compile? I think it is? If so, then this was my solution (I wasn't running Maven package)...Greenwich
See my similar solution as this to another similar Question for more details: https://mcmap.net/q/331233/-how-to-run-gwt-in-production-modeGreenwich
K
0

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.

Kilby answered 20/9, 2013 at 14:58 Comment(0)
W
0

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 Deploy GWT maven project with eclipse deploys webapp directory instead of target/project directory
  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.

Wineglass answered 24/3, 2014 at 0:56 Comment(0)
G
0

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.

Greenwich answered 14/2, 2016 at 2:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.