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.
Related
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
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 )
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
Environment: WinXP.
RAD: Version: 7.5.3 (Eclipse 3.4.2)
Websphere 6.1
I have two web projects on my local RAD environment and 4 or 5 sub jar projects. When I change classes in debug and regular start mode, the files don't get copied to the server for runtime.
So, normally I have to restart the server completely or add/remove the project all together.
I may make a change to Servlet.java
When I do "publish", the ear/application seems to restart, but my changes are not there. So I normally restart the server. This is a productivity killer.
Additional settings:
* Publish automatically turned off.
* Minimize resources. Use workspace.
What can I do to make sure that the classes get copied over.
My theories:
I have parent_first/application for the class loader/war settings. Is that an issue?
Maybe I should remove the ear and add it back to websphere
I did a clean on the server?
Delete your application from the server.
Restart the server
Go to the admin console and ensure the application is not listed in the list of applications, if it is then delete it.
Restart the server
Deploy/publish again.
Unfortunatelly, RAD with WebSphere are very unstable environment.
From my experience, debug mode is causing a lot of problems. It's mainly what you describe, changes not being seen after republish, additionally very quick memory depletion. I'm using debug mode as last report.
In normal mode everything should (read: in most cases) work correctly. You add/change some classes and make 'republish'. Sometimes it's necessary to do clean on project before republishing it.
But when the Websphere is running longer together with RAD, I observe that often something get stuck. You have there clean option on the server, with is expected to clean the cache (which included also compiled classes). You should also observe memory usage. If it's nearing the limits of JVM (memory leaks are heavy) Websphere stops to function correctly, and you must restart it.
However, I sometimes get serious issues where the clean isn't helping, and then it's necessary to remove all applications, stop the websphere (close all projects and open then again) and then start Websphere and add all applications, restarting RAD in the meanwhile. But it's not everyday, maybe every month or so...
If you are really unlucky, RAD can break your workspace, which will force you to delete all project, delete project files (or do a fresh checkout) and import everything once again, or even start a new workspace (happens also with 'normal' Eclipse, ~1-2 years).
You are using the latest RAD so do I... here is my guide for solving this issue:
Enable the error log to see if you get intuitive info on internal RAD errors, in 7.5 it is available on "Show views"
If your changes are not deployed Clean project
If your changes are not deployed yet Rebuild project
If your changes are not deployed yet Redeploy project
If your changes are not deployed yet Clean server
If your changes are not deployed yet Restart server
Or:
- Use ant or maven to make deployments straighforward and ignore the pain due to websphere and eclipse having internal bugs (which you may see in the error log if it is fully enabled).
Regards.
Are your JSPs copied correctly? That is, when you make a change in one JSP, can you see change immediately upon browser refresh? If this works, then I see no reason why classes aren't also published. JSP auto refresh should work in normal and debug modes.
Now, is "build automatically" enabled? If no, your classes won't get compiled and transferred. Parent_first/application for class loading shouldn't be an issue.
Is the local app. server running in development mode? If not, it should be.
While developing, use debug mode. Hot deploy will assure changes to your methods are seen immediately. Changes in classes won't be seen (i.e. adding a method will require application restart).
Is your app. server using global security? I have it turned off and auto redeploy works without problems.
Class reloading has always been a problem while developing Java EE applications. Try do erase that ear file from your WAS and redeploy it again.
If all else fails, try JRebel.
I used to run Tomcat separately on my machine. I had an Ant script that would rebuild my project, deploy it locally, and restart Tomcat. That all worked ok, but I wasn't able to debug the web app inside Eclipse.
So I learned how to setup Tomcat inside Eclipse and got my web app running. Now the problem is that I don't understand fully how to manage it this way. Eclipse is set to automatically build my project on changes, but those changes don't seem to always be reflected in the web app. Sometimes I have to manually build the project and manually "clean" the server for the changes to be reflected.
Are there rules somewhere about how to manage this setup? For instance, if I only change a JSP then will it automatically be synchronized? If I change a servlet class, then I need to manually rebuild the project? Are these rules consistent, or should I just manually rebuild and clean every time?
I would really appreciate it if someone could give me the best practice rules or point me to a good resource to learn how to manage this environment.
PS. I am using Eclipse 3.4.1 Java EE package and Tomcat v5.5
You can use Eclipse and Tomcat in the way you mention. First the basics of how to set it up:
In the Servers view setup a new Tomcat server pointing to your TOMCAT_HOME
Make sure your project is an Eclipse "web project". You may need to create a dummy one and copy over some of the files in .settings (look at the wst files).
Deploy your project to Tomcat by right clicking on the server in the Servers view and "Add and Remove Projects..." to add your project to the server.
You can run your server and test it out just like you were running Tomcat outside of Eclipse. If you run the server in Debug mode you can set breakpoints and step through the code.
As for when you will need to restart the server Eclipse is usually pretty good about auto-deploying the changes. You will pretty much never need to restart for changes to jsp pages. If you change a class it will auto-deploy the change (usually) if you change the body of a method. If you change the signature of a class (add or remove a method or change args for it) you will almost always need to restart. Any changes to configuration files (web.xml or similar) will also almost always require a restart.
To restart just click on the "Debug" or "Run" button in the Server view. All your changes will be redeployed into Tomcat.
One thing to watch out for is that in the default configuration your "webapp" directory in TOMCAT_HOME will not be used. Instead it will use a folder under your Eclipse workspace directory (WORKSPACE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0).
Normally you should republish the application to get latest changes, don't forget to synchronize with file system first in case your files modified extrernally.
You can specify that your application is automatically reloaded when modified, look for Auto-reload attribute in server.xml of your server configuration project. When set to true, tomcat will automatically reload your application. It's not always a good idea by the way.
Modified JSP's should work automatically, no need to restart the applciation.
If you change the structure of a class that has already been loaded and used (add/remove members, change method signature etc.) your code changes will not be reflected. This is not an eclipse issue but a JVM issue. If you make simple code changes, like logic changes inside an existing method, your changes will take effect after the class is compiled and re-deployed.
Regardless of that, if you change a public constant, you have to rebuild your project(s).
I found two things important to understand:
Eclipse does not automatically realize if files were changed outside of Eclipse. clicking Refresh on a project does that, so does F5. You can also change a setting to refresh automatically, which, however, does not detect changes instantly (my gut feeling says up to 10 secs delay)
Working with servers has the concept of "Publishing" files to Tomcat. This normally happens automatically within a second after any change. Changing many classes can cause many server reloads, which can be a drag if a context reload takes some time (as complex Spring apps certainly do). So I changed a setting to not publish automatically (double-click Server instance)