I am used to working in Netbeans, where I can start a project in debug mode, alter some code, and hit the "Apply Code changes" button.
at the moment I am working in Eclipse (Spring Tools Suite) and I would like to do something similar.
I found This article which suggests that Eclipse does it automagically if Project -> Build automatically is set, but that is not my experience. (regarding Spring Boot projects, which is what I am currently working with)
Any help is much appreciated.
In Eclipse and in combination with the Spring Boot Devtools, you have two options to deal with this situation.
One if the ability of the JVM to swap-in code changes while you are debugging without loosing the state of the application. This works in Eclipse out-of-the-box when you have "Build Automatically" enabled and do a code change after you hit a breakpoint. Usually the JVM drops the current execution frame and continues the execution at the beginning of the current method invocation.
BUT: This works for minor code changes only (changing the implementation of a method, for example). Most changes to the source code can't be hot-swapped by the JVM. If the IDE tries to do that, you will get an error message that this is not possible with the question whether you want to restart the JVM, stop it, or continue without the code changes. This is a limitation of the JVM, not directly of the IDE.
The other option is to go with the Spring Boot Devtools. Once they are on the classpath of the app and you change a class on the classpath of the project (which happens automatically if you have the "Build Automatically" enabled), the Boot Devtools will detect those changes and re-start the boot app automatically. This doesn't cause the JVM to be restarted, just the boot app part of it. Therefore it is much faster than starting the full JVM. BUT: you are loosing the state of the application. From the debugging perspective, it is the same as if you would restart the app, it is just faster. But you can't do what while sitting on a breakpoint and expecting the app to continue with the same stack frame.
There are other tools like JRebel that allow for more sophisticated code changes to be hot-swapped into the running app and there are also plugins for Eclipse to use JRebel, for example, but that is another story.
Related
I'm using IBM RAD version 8.0 and deploying the EAR applications to IBM WebSphere 7.0. Each time I change a JSF file, I need to republish the application, otherwise the changes are not visible.
Publishing takes some time, so usually it takes minimum a minute before I'm able to see the efects of even the most minor change. In 'normal' application development it's about a few seconds, and it's crucial for someone who is no JSF coryphee and still learns and needs to experiment...
Is it possible to use the JSF ability to re-load the JSF page definition without application restarting, when working with IBM RAD and WebSphere? Or I'll be forced to create second environment with Eclipse & Tomcat, for JSF experiments only?
This is normally to be configured in server configuration. Doubleclick the desired server in Eclipse's Servers view and head to Publishing section.
Note that you should take Facelet cache into account as well, particularly when using MyFaces which caches relatively agressively. If you make sure that javax.faces.PROJECT_STAGE context parameter is set to Development, then both MyFaces and Mojarra will relax the Facelet caching strategy, causing it to recompile the Facelet file almost instantly instead of using the cached version for a rather long time.
An alternative to Publishing setting is to use JRebel. It is able to publish changes in Java classes such as managed beans and EJBs as well, saving a lot of hotdeployment time. It has an Eclipse plugin as well.
This thread is old, but I still had the same problem, using eclipse and WebSphere.
One place to check is this. If you use JSF files with the .xhtml ending, you have to make sure that changes in these do not trigger automatic republishing.
In the tab "Servers" double-click on your server.
Open the "Publishing settings for WebSphere Application Server"
Click on "Set Advanced Publishing Settings...".
In the "List of file extensions that do not trigger the server to publish ..." insert or append ", *.xhtml".
Close these settings and restart the server.
In web.xml I have also added a parameter with the name javax.faces.PROJECT_STAGE and the value Development , which may have an influence on the offending behavior.
I was given a template of a Struts project to work on, and I noticed that when I run the web project on integrated Tomcat in Eclipse and make changes to the .jsp viewpages, they don't automatically reload after a few seconds - which does happen in other projects I made myself.
So I figured this was a configuration issue and I did some research, I had a look at my Tomcat server settings:
(x) Automatically publish when resources change (1 second interval)
But because my own projects reload and I use the same server for them, I figured it must be an application specific issue.
So I looked at context.xml to see if there was anything to change here
<Context
...
reloadable="true"
...
>
Which I can only assume tells the server to indeed reload the application on changes.
So I really can't figure it out. It seems to me like everything is in order here. What am I missing?
From Apache Tomcat documentation about the Context attributes:
reloadable
Set to true if you want Catalina to monitor classes in
/WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically
reload the web application if a change is detected. This feature is
very useful during application development, but it requires
significant runtime overhead and is not recommended for use on
deployed production applications. That's why the default setting for
this attribute is false. You can use the Manager web application,
however, to trigger reloads of deployed applications on demand.
Also maybe this will be interesting for you: Using Tomcat Reload Features To Speed Up Development
I ran into the same problem, with a Java/Spring project that I imported via its Maven .pom files into Eclipse.
I found that I had to run the project with "Debug" instead of "Run" - only then, changes to my .jsp files were noticed, so that a reload of the web page would show the changes almost instantly.
I'm developing J2EE webapps in Eclipse (RAD, actually). I've always used the "Project > Build automatically" option. However, I noticed that this isn't always necessary because Eclipse seems to push out changes to my server when I save a file. This works great but I'm wondering why this would be checked by default.
I can think of a few times when it makes sense to fully build and deploy the app:
After changing a XML configuation file that gets loaded at app startup (application.xml, web.xml, bean configuration xml files, etc)
After changing a static variable on a class
Other than this, I can't think of other times when it would be crucial (or useful) to enable the build automatically option. Am I incorrect in my above assumptions? Am I just wasting a bunch of time by building automatically??
The automatic build compiles in the first-place. You can disable the automatic publishing (see screen) if you double-click on the server in the server-view. The automatic publishing has nothing to do with automatic build.
Technically I'm using Springsource Toolsuite, but I think this is a general eclipse question. My eclipse startup is now in the minutes, because on startup its running Maven Builder: FULL_BUILD and validation over all the open projects. I recently started working with a very large application, and going through the build and validation takes forever.
Is there a way to skip this at startup?
You can turn off automatic build under the Project top-level menu. Then you can explicitly control when to kick off a build. I would also ping m2eclipse guys on their forum about this issue. It sounds like there is a malfunction in their builder. It should not kick off a full build on every startup unless you workspace is significantly changed since the last Eclipse session.
I have deployed some Eclipse plugins and I want them to take effect without restarting the Eclipse environment. Is it posssible?
At a pure OSGi level, you would use
BundleContext.installBundle()and then PackageAdmin.refreshPackages(), and if necessary, perhaps Bundle.start().
How well this works in your running system will depend on how your bundle is being used by the rest of the system, and how things will react when an old version goes away and a new one appears.
Take a look at these 2 faq entries from the wiki:
How do I make my plug-in dynamic aware?
How do I make my plug-in dynamic enabled?
To do this at a higher level, you would take a look at p2.
Yes, it is. OSGi (and Eclipse is OSGi based) provides a way for dynamic bundle loading without the need to restart the environment. However, eclipse suggest a restart because it works in 100% of the cases, while it cannot guarantee that all plugins will be properly written. You have probably seen the "Apply changes" button after installing a plugin - this tries to reload it without restart.