GWT, Tomcat, 2 modules, JRebel: DevMode looks for nocache.js in wrong location and shows 404 not found

StackOverflow https://stackoverflow.com/questions/20630232

Frage

I'll ask my questions first and then go into details:

  1. What function hosted.html file plays in DevMode and why it is requested from page like hosted.html?<module-name> and how can I control/configure what is returned by that request? If anyone answers this question, I'll upvote & accept the answer since I've already found answers to 2nd and 3rd questions myself and they doesn't seem to be related to my problem.

  2. Are there any ways of triggering GWT cache refresh instead of plain browser Ctrl-F5? In each module I've seen generated during compilation clear.cache.gif file - does it have any relation to GWT cache? already answered by myself and doesn't seem to be of much help in this situation

  3. Did I correctly specified DevModes -war path (see below)? Should I instead specify absolute path to src/main/webapp folder? already answered by myself and doesn't seem to be of much help in this situation

  4. What is the problem with my setup and why I'm having problem described below? (optional to answer, but if answered correctly - I'll upvote & accept the answer right away :))

EDIT - details related to 1st question

So there are 2 GWT modules: login and dashboard in my webapp. The problem is that in DevMode page login.html containing only login module always loads normally, making following request

GET http://localhost:8080/login/hosted.html?login                200 OK

Which returns standard hosted.html page which is generated by GWT compiler and put into each module's folder.

But somewhy dashboard.html page containing only dashboard module doesn't load normally making following request:

GET http://localhost:8080/dashboard/hosted.html?dashboard        304 Not Modified

Cache-Control:private
Date:Tue, 17 Dec 2013 13:07:40 GMT
ETag:W/"11781-1367504122000"
Expires:Thu, 01 Jan 1970 03:00:00 EET
Last-Modified:Thu, 02 May 2013 14:15:22 GMT
Server:Apache-Coyote/1.1

Which surprisingly returns login.html page as a result and not standard hosted.html file which I would expect. Please note that this happened quite rarely during the last half a year and was solved by pressing Ctrl-F5 multiple times. But since yesterday, this happens always.

Continuing to search, who or what makes request to hosted.html?dashboard and who is responding to it with such strange response.

EDIT #2 - details related to 1st question It was found out that the problem is on the server side - somewhy response to second request (mentioned above) has status code 304 Not Modified. While debugging Catalina code it was found out that the problem is with org.zeroturnaround.javarebel.integration.fileservlet.FileServlet class which in the end serves the file. This class is from JRebel (version 5.2.2) which is launched with Tomcat using -javaagent option. If I remove -javaagent option and launch Tomcat without JRebel everything works fine and correct file is served. Will try to dig deeper and find out the problem in JRebel's class.

EDIT #3 - details related to 1st question

After upgrading to JRebel-5.4.2 the error still persists. Started topic on Zeroturnaround forum: http://zeroturnaround.com/forums/topic/gwt-devmode-tomcat-7-0-39-possible-fileservlet-bug/

Detailed description of my problem (nothing very interesting - just details :)):

I'm having a problem with Devmode of webapp running 2 modules called login and dashboard. Webapp is being deployed locally to standard tomcat installation and has directory structure like the following:

<tomcat_folder>/webapps/ROOT/login.html
<tomcat_folder>/webapps/ROOT/login/
<tomcat_folder>/webapps/ROOT/login/<single gwt.rpc file>
<tomcat_folder>/webapps/ROOT/login/<multiple .cache.html files>
<tomcat_folder>/webapps/ROOT/login/gwt/<standard files>
<tomcat_folder>/webapps/ROOT/login/clear.cache.gif
<tomcat_folder>/webapps/ROOT/login/login.nocache.js
<tomcat_folder>/webapps/ROOT/login/hosted.html

<tomcat_folder>/webapps/ROOT/dashboard.html
<tomcat_folder>/webapps/ROOT/dashboard/
<tomcat_folder>/webapps/ROOT/dashboard/<two .gwt.rpc files>
<tomcat_folder>/webapps/ROOT/dashboard/<multiple .cache.html, .cache.png, etc files>
<tomcat_folder>/webapps/ROOT/dashboard/gwt/<standard files>
<tomcat_folder>/webapps/ROOT/dashboard/clear.cache.gif
<tomcat_folder>/webapps/ROOT/dashboard/dashboard.nocache.js
<tomcat_folder>/webapps/ROOT/dashboard/hosted.html
<tomcat_folder>/webapps/ROOT/dashboard/<other css and image resources used by page>

<tomcat_folder>/webapps/ROOT/<other files of webapp>

Now, login.html contains reference to login.nocache.js file like the following:

    <script src="login/login.nocache.js" type="text/javascript" language="javascript"></script>

dashboard.html contains reference to dashboard.nocache.js file respectively:

    <script src="dashboard/dashboard.nocache.js" type="text/javascript" language="javascript"></script>

I launch the DevMode from Eclipse with the following parameters:

-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" 
-startupUrl http://localhost:8080/login.html -logLevel INFO 
-noserver -war <absolute-path-to-tomcat-folder>/webapps/ROOT 
-codeServerPort 9997 
org.yura.cases.DashboardModule org.yura.cases.LoginModule

Now, I'm working with such setup for already half a year now and everything was working fine i.e. it works flawlessly not in DevMode and, say, 95% of time I was successfully working with DevMode - debugging code, changing it in Eclipse etc.

But, the problem is (and was in the past) that, from time to time, when I open

http://localhost:8080/dashboard.html?gwt.codesvr=127.0.0.1:9997 

page is blank and I see following error in browsers console:

GET http://localhost:8080/dashboard/login/login.nocache.js/ 404 (Not Found)  hosted.html:10

When I go to hosted.html:10 file which is loaded during page load I see that this file is loaded from following URL:

http://localhost:8080/dashboard/hosted.html?dashboard

and the returned HTML file indeed contains wrong path to login.nocache.js:

<script src="login/login.nocache.js" type="text/javascript" language="javascript"></script>

(path is wrong because login/login.nocache.js' is relative path and it resolves todashboard/login/login.nocache.js`)

Till today, I bypassed this problem by simply holding Ctrl-F5 for several seconds to reload page and clear browser cache and eventually page loaded normally in DevMode. However, today, no matter how long I press Ctrl-F5 the error persists. That's why I decided to finally solve this problem once and for all.

Thanks in advance for any help!

War es hilfreich?

Lösung

Found answers to my 2nd and 3rd question, though they doesn't seem to be of much help with my problem. Anyway, sharing them here:

Question 2. Are there any ways of triggering GWT cache refresh instead of plain browser Ctrl-F5? In each module I've seen generated during compilation clear.cache.gif file - does it have any relation to GWT cache?

As per http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#launching_a_browser :

You do not need to restart development mode after modifying your source code. Instead, with Development Mode still running, edit client code or resources, save your changes, then refresh the page in your browser.

And as per GWT project directory creation by hand :

clear.cache.gif is a 1x1 cacheable image used to have a placeholder for the tag. See http://code.google.com/p/google-web-toolkit/wiki/ImageBundleDesign ("Clipping constructor for Image")

So it turns out that in my case, pressing F5 or Ctrl-F5 should totally do the trick and there are no other means of "refreshing" GWT cache at least well-declared to the public.

Question 3. Did I correctly specified DevModes -war path (see below)? Should I instead specify absolute path to src/main/webapp folder?

Yes, as per Using my own server in development mode instead of GWT's built-in Jetty instance tutorial, I've specified -war option correctly.

EDIT - found answer to 4th question (solution to my problem) Ok, so it turned out that the bug was in org.zeroturnaround.javarebel.integration.fileservlet.FileServlet class, which was incorrectly handling ETag header in rare cases. That's why it served login.html content which was returned previously by Tomcat as result of non-authenticated access to protected /dashboard/hosted.html?dashboard resource (weird but standard behaviour of Tomcat). Bugfix of JRebel should appear in today's nightly build and I'm 99% sure it will work :)

For details please refer to this discussion: http://zeroturnaround.com/forums/topic/gwt-devmode-tomcat-7-0-39-possible-fileservlet-bug/#post-39379

Really hope this helps someone else :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top