I am working on a GWT project. After having made changes server-side and compiled it useing GWT Compile, the changes are not reflected when I deploy the application on Tomcat Server. But if I run the application in dev.mode in Eclipse, the changes are reflected!
Any idea how to make the compiler use the latest code?
I have deleted all compiled filed, build and cleaned the project tons of times - none of it working.
This is typical if your cache settings aren't correct. Your broswer doesn't download the changed files because it has the old ones in cache and doesn't know they changed.
Try erasing the browser cache and/or pressing ctrl-f5 in your browser.
On production systems, you need to properly configure you web server to explicitly cache GWT files matching *.cache.*, and explicitly NOT caching *.nocache.*.
See this for a server filter example that takes care of the cache configuration (i.e., as geert3 explained so your server does not let your browser cache an obsolete version, search for section with requestURI.contains(".nocache.")) and to make your app crawlable as well.
Related
How to configure Tomcat server in debug mode for Eclipse to support hot deployment? Hot swap or hot code replace without restarting the Server, which can speed up the development.
We can make some changes in tomcat to support hot deploy, there can be different ways to achieve that.
One of the simplest way is making change in tomcat setting in eclipse/STS,
Double click on the Tomcat plugin, refer to publishing tab, make sure "Automatically publish when resources change" is selected.
In the Tomcat Plugin page, click on the Module view, make sure Auto Reload is Disabled. Default is enabled.
**NOTE: **
This is applicable in case of debug mode only
Only method code changes is supported, new added method,class, database script,tomcat is required to be restarted.
Reference:
Click here for mkyong.com link
I'm not sure that it is possible without redeploy and without external tools. For case to update only updated classes/resources I use HotSwapAgent tool
But this tool have some limitations and I wouldn't recommend it for prod.
Hot swap will change the modified class byte code on disk, which will trigger tomcat redeploy. Also hot swap supports only simple changes within method body.
So hot swapping on tomcat is not working out of the box.
There are third party solutions for this, like JRebel.
I am starting to learn GWT.
I've picked up newest version (2.7.0).
I have wrote Entry point class to display start page and to call rpc to server to execute some function.
Every change I made in client side source code in Entry point class, cause auto recompile (hot swap), so I can see immediatly changes, that I've apply.
My problem is that it works only for client side code.
It dosen't work for server side code. To see changes in server side code, I have to stop server and console, and run it again, which is very very annoiyng.
So my question is:
Is it normal behaviour of gwt app server in SuperDevMode in 2.7.0 version? Or am I doing something wrong?
How should I deal with that?
Please give me your thougths about it.
By the way: I use GWT with eclipse and Google plugin.
EDIT
I wonder what about Maven GWT projects? How to deal with them?
What you describe is normal behavior.
There are several ways to reload the server side code when refreshing without restarting your server:
The built in web server does support hot swapping code, but only if you do not modify method or class signatures. If you do change them (or add a class or method), a server restart is required.
You might need to configure your Eclipse to auto re-publish any code changes to your web server.
There are 3rd Party Eclipse plugins which improve the hot code reloading mechanism, for example JRebel, which allows hot code replacement even if you change method or class signatures.
There's a "reload webapp" button in DevMode. It's in the "Jetty" tab when using "bare" DevMode, and a yellow double spinning arrow in the Eclipse view when using the GPE. It'll restart the web app just as if you redeployed it in a standalone server.
I found this solution:
https://github.com/jbarop/gwt-hotdeployment
It seems to do the job for developer.
But it is quite old.
Recently I started to use Super Dev Mode to get look&feel of it. It took me couple of hours to get it up but I didn't find out how and actually can you use SDM for faster development using hot swapping.
Using Dev Mode all I had to do is save my changes in IDE and refresh the browser page. Now my code changes needs to get transferred to the code server to be recompiled? Am I right or am I missing something obvious?
All you have to do is click the DevMode On bookmarklet and Compile button. This is for client-side code only though.
For server-side code, whereas DevMode can serve your webapp and you can reload it with a single click to get your changes in, CodeServer only deals with the client side, so you have to deploy your webapp to a server (that said, you can use DevMode if you want). You then need to re-deploy your webapp when you make changes to your server-side code.
See https://stackoverflow.com/a/18333050/116472 for a detailed step-by-step howto.
I'm developing a web application with jsp pages in Eclipse 3.7.2 and testing it with Tomcat v6.0.
I've almost the perfect environment as all changes to my jsp or java code are immediately available in the browser within Eclipse, so I can directly test any change.
But... I also use jQuery, who isn't ;-), and changes in my javascript files are not immediately active. Looks like they are cached or copied once and don't get replaced. Even after rebuilding or restarting the tomcat, the old files keep being used.
Any ideas on how to solve this?
Thanks a lot,
Frank
If you are using firebug in your browser, you can switch off the caching by default without adding code to your page:
click the arrow on the right side of the Networking button and select the disable browser cache option.
The files are probably cached by the browser.
ctrl-F5 might help but if you can configure the server to set no cache for js and css that should also help.
Another solution is to load all such files through a loader,
/load.<site extension, ex php>?file=myscript.js
And have that "proxy" set no cache.
We use that along with e-tag to be able to use build number as e-tag, vith every build a new version is forced to clients but then cached until next build.
I'm using Google AppEngine with their built in web server. My development goes about in a simple way: I make changes to my .java sources or .jsp and compile using ant and to see the changes I have to restart the development server.
I'm wondering if there's a way I can avoid this last step of restarting my development server - somehow refresh the cached classes context of my web-server. The options provided by Google on this dev server are quite limited and am wondering if there's a better way.
I would like to avoid using something like JRebel which I could buy, but for this simple project I'm just wondering if I can remove the burden of restarting my web-server... otherwise I'll live with it.
I realized that you can just touch
appengine-web.xml to force server context reload. Also loading the
page under /_ah/reloadwebapp will reload the servers context - even if
it gives you a 404, it will still reload the context.
In debug mode, the JVM can perform some hot swapping - I know and Intellij IDEA does it, i m sure other debuggers in other IDE's does it too.
Start the app server with the debug flag (-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8000 for example), then connect the debugger to the app server.
Then, make a change to the source that is not a method signature or class field change. Recompile, and voila, the debugger hot swapped the class into the jvm being debugged!
This only really works semi-well. But it may just be enough.