Everytimes, I change the java coding in java class under Eclipse. I click the run-as, it requires to restart the embedded Tomcat server in order to make the change effective. How can I test the change without the need to restart the Tomcat server. Because it is very time-consuming, if I need to restart the embedded Tomcat server whenever I change some coding. It will spend one minute for testing a little change.
Thanks
What you need is a hot deploy:
Hot-deployable services are those which can be added to or removed
from the running server. It is the ability to change ON-THE-FLY what’s
currently deployed without redeploying it.
Hot deployment is VERY hot for development. The time savings realized
when your developers can simply run their build and have the new code
auto-deploy instead of build, shutdown, startup is massive.
And good news there is a hot deploy in Eclipse. Just Follow the Eclipse tutorial for this
This process is called hot swap or also hot deploy. There are tools that do this process for you. One open source tool that you can check is HotSwapAgent. One paid alternative would be JRebel.
Obviously goes without saying that these two are far from comparable in terms of features and efficiency. But if it is just for testing purposes the open source alternative is just fine. In industry, not that much(we have tried it in my company and didn't fit our expectations).
If i am not wrong there is a option to do that. I am pretty sure that you have seen that.
Related
I'm currently looking into what better ways there are for deploying/setting up webapps locally after code changes and database changes.
So far I've seen the following tools/ways come by, and attempted each of them:
ANT build target that compiles, makes a jar, a war file and deploys that to the tomcat folder
Gradle build in combination with the tomcat plugin, which already does a bit of a better job than option #1
Good ol' fashioned command line
Setup run configuration within Intellij to do the deployment for you
Write shell script and call this via command line (haven't tried this)
To be honest I'm not finding each of these the ideal solution. I find option #4 the easiest as it allows me to, via a short-cut, easily deploy my changes and continue. This has however not given me an option for database changes yet, probably just me that missed it.
My question is mainly what tools/ways are you guys using in order to achieve an easy and maintainable development environment? What considerations come with those?
Well, let me tell you what I do for local web app setup.
In your favorite IDE(eclipse in my case) i'll configure the application server plugin(tomcat or webpshere) from Eclipse marketplace.
This setup will help to auto publish code changes to the server whenever I make a change in the application. I use Maven build tool for the application packaging. However I'm not sure about the database side.
For the people that were wondering how I ended up doing and found the best to work for me.
I currently have configured my IntelliJ IDE in such a way that the tomcat instance is linked and can be properly controlled and deployed, including debug, from within IntelliJ itself. This allows me to, via an easy shortcut, instantly populate any resources changes (css, javascript, front end) or redeploy or even restart the server. Especially with a small application this works very well.
It is yet to be determined whether this would still work with a multi-module setup and a larger project size.
Should you want more information on how this configuration can be achieved, feel free to send me a direct message.
I've got a huge web project in eclipse using maven. After each change in any of Java classes in my daos or services or controllers when I restart tomcat the change doesn't get picked up. So I need to do maven update--restart tomcat or clean--maven install--restart tomcat to get the change picked on the next server restart. So, in other words, tomcat doesn't pick any changes on a restart. I know there might be 100 reasons for this but could anyone please share some likely causes since the productivity is quite low if I have to make maven install each time for a change to be picked? thank you
Well, mvn clean install and then tomcat restart is quite common pattern for application deployment. In theory you can speed it up a little bit with things like JRebel.
In practice most people are quite happy with some build configuration inside their favourite IDE, which will make all these build/deploy things with one button click.
On changing a single line of code or just adding a comment line, netbeans redeploys the entire project to server, which eats up lot of development/debugging time. I know, I can disable the hot deploys but I don't want that, I just want to make hot deploys work faster so that I could test changes faster on browser.
Moreover in debugging mode it is even worse in terms of time taken for deployment.
Is there something I can do about ? Or should I do hot deploys some other way ?
I dont know any way of doing it in Netbeans itself, but you can always take a look at JRebel.
This tool monitors your class folders and hotdeploys them to the application server when a file has changed. I use this in Eclipse with Tomcat and it works very good for me.
The ide used is :IBM Rational® Software Architect™ for WebSphere® Software
Version: 7.5.5.3
The app server used is Wbesphere 6.1.
I am posting this question because my server takes about 7 to 8 minutes to start.
So even if i make a small change ,i have to wait 10 minutes to test the change in my application.So is there a way where i can make changes to my java code and test them without restarting the server.
Suggestions appreciated !!!
Note:
I am not supposed to use any build tool in my environment.
There is a plugin called JRebel that let's you do changes without restarting the server.
Dynamic Code Evolution VM is open source alternative to JRebel you can try for reloading classes. It will do entire class redefinition, even reloads changes done to class hierarchy.
Theoretically reloading classes is build into the JVM, although most implementations (specifically Oracle's) only reload (hot swap) as long as you only change code inside the body of a method.
The other problem is that in Eclipse the WTP adapter has to cooperate and only deploy the changed class definition (incremental deploy). GlassFish for some reason has always been a big opponent of incremental deployments, and hence its WTP adapter restarts the server after making even the most tiny change.
JBoss used to be a proponent of incremental deployments, but after AS 7 ("everything has to be different"), they are now a follower of the "restart the server" school as well.
Yet another issue is that plain class loading is often only one part of the story. In EJB, JSF, JPA and many other frameworks classes also have to be re-registered by the framework, caches have to be cleared, etc
This all is where something like JRebel comes it. It reloads nearly all kinds of changes to classes. It also works independently from the WTP adapter thus freeing you from the whims of the server vendors regarding if restarting is hip today and lame tomorrow or exactly the other way around. JRebel also has knowledge and plugins for many frameworks.
Unfortunately JRebel is not perfect and occasionally things will just fail, but overall it works pretty well.
One other piece of advice: most modern application servers start up in a second on relative fast hardware and with a small application or a some 10 seconds for a larger app. With those and session serialization you almost don't need things like JRebel anymore.
I am having my web application deployed on Tomcat5.5 and I use it in integration with eclipse 3.2.Each time I close the eclipse and restart it, I need to republish the application even when it hasn't been modified.
Is there a way to avoid this or any step I am missing ?
Go to Preferences->Server->Launching . Remove option 'Automatically Publish When Starting Server'
I think adij.wordpress.com correctly nailed this one. If you find that you're spending a lot of time waiting for Tomcat to restart as you develop your application, consider using Jetty instead. It'll restart in a fraction of the time Tomcat does and provides a full featured alternative that is ideal for agile development.
We use Glassfish (Tomcat based) with multiple EAR files and it's dog slow for development so each EAR project contains a Jetty launcher that simply fires up for the single WAR the developer is working on at the time. If you use IntelliJ this can be made automatic so that changes at any tier of the application can be instantly reflected into the currently running application in the time it takes to click onto the browser and refresh the page.
Do eclipse 3.3 or 3.4, or later versions of WTP behave the same way for you?
As this is a quite old question and still filed under unanswered, I'd like to broaden the scope with this answer:
I assume there is a reason for you to want to cut out republishing of your application that I don't know (other than the aversion against unnecessary work being done)
The only thing I can guess is that it takes a significant amount of time. For me the publishing time has never been an issue, but if they are for you, you might think about
increasing your memory (if swapping virtual memory slows republishing) - e.g. buying new RAM
optimize dependencies in your project, e.g. prepackage dependent projects if there's a huge number of them or create subprojects and depend upon them if there's only one huge project. (This assumes, that any of these factors slows republishing. I have not measured it)
does using Tomcat6 or glassfish help?
It might be, that not publishing is your issue but startup time. You might gain a lot by controlling that very tightly, e.g. starting services on demand after the webapplication has started. I know several applications that do some heavy work during startup (before they accept their first connection and before they pass control on to the next application startup that might do the same). I hate them. Usually such services get lots of swear words and finally their own web/application server. Having to restart one of these applications should at least not make all the other applications (and their users) suffer that are written with nice startup times in mind.
If your question is still an issue and you are still looking for a solution, please comment. What is your republishing time?