Is a HotSwap possible with Spring MVC and Spring Security? - java

Currently I'm developing a Web App with Spring MVC and Spring Security using Maven to build the application and Tomcat as a webserver.
When I'm making changes in my JSP files, I can immediately see the changes (when the application is running) when I do a reload in my webbrowser.
However, when I make changes in my Java files (for instance in a Controller class), I have to redeploy the application (which takes 10 to 15 seconds) to get the changes working.
So my question is: Is there a way how to NOT do a redeploy every time when I perform changes in my Java classes?
Thank you very much!

We call what you would like to achive is Hot Deploy.
There are many different way to apply Hot Deploy, so the best way is to google for it.
If you use IntelliJ + Tomcat then this article can help you:
Intellij IDEA – Auto reload a web application (hot deploy)
If you use Eclipse IDE this can help: How to configure hot deploy in
Eclipse
You can find some info here as well: how to enable hot deploy in
tomcat

Thanks for your responses. I tried some more options and this is working fine for me:
Go to Run / Edit Configurations / “Deployment” tab, clicks + icon / select an “exploded artifact”
Select “Server” tab, update the following options :
On ‘Update’ action -> Update classes and resources
On frame deactivation -> Update classes and resources
Run web application in Debug mode. Try to modify some codes or resources (Java files, ...), the modified classes and resources will be reloaded automatically without any redeploy or something like that.

You can do a hot deploy using this plugin JRebel but if your build is only 10-15 seconds I think that a hot deploy is overkilling

Related

JSP debugging in IntelliJ with spring-boot

I want to be able to debug jsp templates in IntelliJ.
I'm using Spring-Boot
Project is without web.xml file. Made with Annotations.
I'm launching app via Spring Boot run Configuration in IntelliJ
When I launch the app, breakpoints become gray crossed circles, indicating that no class associated with it.
Jsp location is /webapp/WEB-INF/jsp
Now, before I get marked for duplicate:
This question is quite old and only suggest using web.xml + Tomcat and plugin. Pluggin doesn't seem to work and switching to web.xml is going to be a real pain in the bottom. Would be nice to stay with annotations and not include web.xml
Tried launching via maven command as suggested in this answer, but for unknown reason, after launching, the process detaches from intellij and I'm not able to launch it again (have to destroy process in the process task first) and it doesn't resolve the issue either.
Other answers, suggesting launching Tomcat directly fail as it won't launch without web.xml.
How can I keep an ease and speed of launching Spring-Boot application, have an ability to hot-swap the code, debug java and jsp templates while avoiding web.xml configuration all at the same time?

Change in Jsp/Html page in War file deployed on online web logic server without re-deployment?

I am working on online web logic server which is running on specific link.I have already deployed my Ear/War file on it but I want to make some changes in html/jsp page of deployed application.
If I follow regular approach of deployment then it will take 20 minutes to deploy it.
Is it possible to make changes without redeploying the application or is there any way to resolve this problem ?*
If possible share your explanation .
Instead of the usual "delete"/"install" steps to redeploy an application, you can instead use the "update" button. This updates the deployment while the old version is still running. This works fine for simple webapps.
For more sophisticated solutions refer to the Redeployment Section of the Documentation (here is the 12.1.1 Documentation https://docs.oracle.com/cd/E24329_01/web.1211/e24443/redeploy.htm#DEPGD288 )

Instant update JSP / HTML without the need to redeploy

Working with JSPs design / HTML is a problem because one should always redeploy the application when a change is made. Application redeployment is time consuming, it would be better if I can make some changes to JSP / HTML, refresh the browser and wholaaa !. In Idea intellij there update resource / update resources and classes is there something like this in Eclipse ?
I am using glassfish server for my application deployment and J2EE.
In Eclipse you can republish your Application. It's still a little bit time consuming, but you haven't to redeploy the whole Application. Additionally it's possible to change some settings in the way, that Eclipse republishing your App automaticaly after you've saved some changes. Admitedly I don't know if this is a native Eclipse functionality or if you need a plugin for that.

Difference between Hot redeploy in Play and automatic restart in Spring Boot

If I take a look at Hot redeploy in Play and Automatic restart in Spring Boot, it seems very similar. Is there any principal difference between implementation of these features in these projects?
In Play it's out of the box, while in Spring Boot you have to install the Dev-tools.
In Play you have to hit the reload button of your browser in order to reload but there is an awesome plugin made by James Ward which triggers a reload when you make changes to a file.
Warning personal opinion:
Working on both frameworks, using both plugins, the Play version is much cleaner and works better, save changes, see how the browser refreshes, immense productivity boost.
Also in performance, if your Spring application is a little bit bigger than usual, it takes a little bit longer, while in Play it's always fast.
They are essentially the same in terms of implementation in that they both create a new application classloader to load in the new changes and discard the previous one.
Note that here are a couple of options for running a Play application to trigger reload:-
The following will trigger a rebuild and reload of classloader when a new request is received by the application, namely when you hit refresh in your browser. James Ward's plugin just saves you have to hit refresh.
activator run
The following will monitor your source directories for changes and will automatically re-compile any modified source on the fly. Although the server has recompiled the source and setup a new classloader you still need to do a refresh in your browser to see the changes (or use an extension like James Ward's).
activator ~run

How to redeploy an EJB Project without restarting the server

I'm new to JBoss Seam and Java web app development in general. One thing that I cannot figure out while going through a few tutorials is how to redeploy beans that I've made changes to in an EJB project without having to restart the JBoss Application Server (6.0) that is hosting the JBoss Seam web project which uses the beans. The JBoss AS takes about 2 mins to start up, and it is painful making changes to the project and redeploying at present.
Some suggestions that I've read on the web include:
Using the jmx-console eg. go to http://localhost:8080/jmx-console/ ... ok, but how? What do I do exactly?
creating a build.xml file for ant, and get some sort of autodeploy thing going... are there any good examples around?
How do the rest of you more experienced JBoss Seam web app developers deploy your projects more rapidly?
Any help much appreciated, thanks.
This can be due to a number of reasons:
An application attempting to maintain state.
The new deployed application having a different classloader than the old one.
Other random causes. In our case, the jboss-classloading.xml configuration was not correct and this caused the hot deployment not to work.
Did you make any changes to your JBoss configuration? This can also lead to hot deployment issues.
Good luck.
Use JBoss hot redeploy feature: just remove your EAR (WAR) from deploy directory and copy there your new version.
Start JBoss in debug mode from your IDE (Eclipse). Then some code changes can be hot swapped directly into the JVM. If the hot swap fails, then do 1. hot redeploy.
Try great JRebel plugin. Much more powerful than 2. JVM hot swapping. You can combine Jrebel with 1. hot redeploys - when JRebel plugin fails, then do hot redeploy.
Just beware, hot redeploying may reveal memory leaks in some libraries (e.g. Jasperreports). If so, do restart your server. But you need to restart JBoss very rarely.
Another option that I have been told is to use the "Touch Descriptors" button (which is like a "quick redeploy" option) in JBoss.
Dev Studio 4.0 has it, not sure about earlier versions though. Apparently it creates a new timestamp on the server and forces the web.xml file to be re-read, thus redeploying.

Categories

Resources