Play Framework 2.1 Java/Eclipse: Auto-Reload not working - java

The Problem/s:
Views are being compiled but hitting refresh in a browser won't show the changes without restarting the server manually.
Changes to controllers compile automatically using ~run but only a manual server restart will update the content on the server.
Changes to routes under conf are only shown after manually restarting the server.
Background:
running on OSX 10.8.3
using Eclipse Juno 4.2.2
Server is launched using play ~run
Only restarting the server will show changes to views, controllers, routes
To be able to make changes without having to restart the server each time I tried (without success):
in the console: clean -> eclipse -> ~run
in the console: clean -> compile -> ~run
shutdown/restart the computer
Tick Refresh using native hooks or polling -> remove classes_managed from Referenced Libraries and add it manually
Questions:
How can the Auto-Reload functionality be restored?
How can this problem be solved on IDEs besides Eclipse?
Further information:
Playframework reload not working Mac OSX
Auto-reloading with Play framework on a network filesystem
Both of them point to JNotify as the cause for auto-reloading not to work. One of the answers (not enough rep to write a comment) mentions how one could "hack Play framework's sbt plugin to make the PlayReloader trait behave as if JNotify wasn't available." How could one achieve this?

The following got Play's auto-reload to working with Eclipse:
In Eclipse Preferences go to General → Workspace. Uncheck Build automatically.
Restart OS X.
For whatever reason, I had to restart OS X to get akim's suggestion to take hold.

I got around this problem by changing the project configuration in Eclipse. I unchecked the "Allow output folders for source folders" option, which means that Eclipse will compile classes to the "bin" folder. This prevents the Eclipse compilation from interfering with the Play compilation. The only downside is that you have to remember to redo it if you ever do play eclipse again.

Following akim's suggestion, disabling Build automatically under General\Workspace in the Eclipse Preferences solves the problem and re-enables Play!'s auto-reload functionality in all of the above problem cases.

Related

Eclipse plugin hot deploy

I'm developing an Eclipse plugin, and I test it launching a secondary Eclipse instance using Run As -> Eclipse Application in my project.
So far so good. However, every time I make a source code change (in Java) I need to close this secondary Eclipse instance and start it again to see my code changes being run.
Do you know of any hot deploy option for an Eclipse plugin? It would save me time since Eclipse is slow to load back again and again.
I guess I got used to Tomcat that implements hot deploy. The moment you save your Java source file Tomcat automatically deploys it behind the scenes. It doesn't deploy the whole application, but just the modified class -- something that takes just a few milliseconds.
Using "Debug" instead of "Run" should be enough.
If this doesn't work, check in the Preferences in Java > Debug that "Enable hot code replace" is on.
Also make sure that "Build Automatically" is selected in the "Project" menu. (Or manually invoke "Build" after saving)

Changes in my java code in eclipse not show in application , even after liferay restart

I have a problem in Eclipse 4.7 (Oxygen) and Liferay IDE 3.1 When I alter my source code, my changes have no effect .
Earlier it was working if I restart liferay (was using liferay 2.6 and eclipse Mars and java7) from eclipse but now each time I have to do a dev ant-rebuild and then after starting server the changes reflect.
Have tried solution provided in other links like (Project -> Build Automatically)
add project in Server but nothing seems to work.
Based off your answer to the previous comments I have determined that you are expecting to see something that is no supposed to happen. If your server is running and you make a change to your Java files (any file ending in .java) you will not see the changes in your browser (on the GUI) until your save, compile, and deploy your changes.
So without any additional tools you will need to do the following for ever .java change.
Save changes
Run the ant compile target
Run the ant direct deploy target
You should see the deployment happen in the console and you can now refresh the page and view your changes. It is important to note that depending on your change you may need to restart the application container and clear temporary files.
There are a few exceptions to this.
JSP changes. You can view changes in your JSP automatically.
JRebel. For 6.2 development I cannot stress this product enough. Get a copy of My JRebel. With JRebel you can save your Java changes and see them immediately. This is a 3rd party tool though which traditionally costed 500usd. It is now free though
Sorry, this was too long for a comment. In the thrust of Olaf's comment though, you need to give more detail. Here are some shots in the dasrk and a question:
Upgrade to Liferay 3.1.1 if you haven't.
Do you see messages like the below ones in the log when you save an edited file? How about when you drag the project onto the running server (the server is running, right)?
21:28:01,514 INFO [pool-10-thread-2][BundleStartStopLogger:38] STOPPED com.liferay.docs.guestbook.service_1.0.0 [562]
21:28:01,588 INFO [Refresh Thread: Equinox Container: 40aeefb4-a286-0017-134c-c19af18a2252][BundleStartStopLogger:38] STOPPED com.liferay.docs.guestbook.portlet_1.0.0 [563]
21:28:01,661 INFO [pool-10-thread-3][BundleStartStopLogger:35] STARTED com.liferay.docs.guestbook.portlet_1.0.0 [563]
21:28:01,672 INFO [pool-10-thread-3][BundleStartStopLogger:35] STARTED com.liferay.docs.guestbook.service_1.0.0 [562]
Have you tried restarting eclipse?

Why I can't remove this Eclipse plugin after failed installation?

I am using Eclipse Mars and I have the following problem.
After the installation of a plugin, the Adoe Flash Builder plugin, it is a plugin that is installed outside Eclipse (executing an installer and selecting the Eclipse folder) I have some problem.
The plugin installation failed (because this plugin is supported only on the 32 bit version of Eclipse). So the plugin was not completly installed.
When I start Eclipse I obtain a lot of error messages caused by this failed installation and it is impossible to me work.
So I have tried to disinstall this plugin but it doesn't give me the possibility to uninstall it (the Uninstall button is disabled).
Here the screenshot where you can see that, selecting the plugin that I want to uninstall, the Uninstall button is disabled:
Why? Can I manually delete this plugin in some way? (I have not directory related to it into my Eclipse folder). It seems that in some way Eclipse have the information of this plugin but that this is not effectively present. How can I remove it? Or is faster reinstall and configure again my environment (Eclipse + SVN plugin + project configuration)
I have tried sometimes to get rid of "messed up" eclipse configurations.
In the end, it just didn't work out. I always ended up throwing away everything.
Besides: Eclipse Neon R2a was released already; so just download that and say goodbye to Mars.
And the real answer (in my opinionated eyes): I decided at some point to enable myself to install eclipse "from scratch" as quickly as possible (for example by having automation where possible; and "checklists" to follow where manual interaction is required). Simply because "installing from scratch" helps avoiding a lot of problems over time.
And while we are talking about eclipse best practices: if your OS is Linux, consider to switch to git-svn instead of SVN. Your machine still talks SVN to the remote SVN server, but you can enjoy the full beauty of git locally. No more SVN plugins, no more hours of waiting for that SVN plugin doing refresh ... I can't tell you how much time that simply change saved for me.

Spring boot devtools - Static content reloading does not work in IntelliJ

When building my first Spring Boot app, I discovered that I need to restart my app every time I make a change to a Javascript file in /resources/static/some-file.js
This is very time consuming.
When I move the files to the /webapps/ folder, it works as expected, but the files are not packaged in a JAR. The docs mention this, so I cannot continue this way.
I read all about spring-boot-devtools, and have installed it in my POM, but the hotswapping doesn't seam to be working. I still need to restart the entire app to see a Javascript or CSS file change.
When the app starts, I can see the line LiveReload server is running on port 35729, so spring-boot-devtools must be doing something...
What would be the steps to further investigate what is going wrong?
My guess is that when IntelliJ runs the app, the files are copied, so when I make a change, I'm actually changing the original files and not the ones used by the running app.
PS: I'm using Maven, IntelliJ IDEA 15 and Spring Boot 1.3.3 with the embedded Tomcat server. I'm not sure what command IntelliJ runs to start the app. The IDE is handling this "automatically". Perhaps I need to change my run configuration?
You need to turn on a couple of features in IntelliJ to make this work.
First, there's a project specific setting which you would need to apply on any project you want to use devtools in. Go to Preferences > Compiler and enable "Make project automatically."
The next setting is an IDEA registry setting that applies to all projects.
In macOS (OSX), press Shift+Command+A (Shift+Ctrl+A in Windows)
Type "Registry" in the search box that appears, and select the registry to open it.
Lookup compiler.automake.allow.when.app.running and enable it.
After that, restart your app. You will notice that the project keeps rebuilding with every change you make. When you check out the result in the browser, you will see both static files and code have been updated.
For Windows users the steps are:
1) Go to File->Settings, then to "Build,Execution,Deployment"->Compiler and enable the "Make project automatically" flag.
2) Press Ctrl-Alt-Shift-/ and select "Registry" from the menu that appears. Enable compiler.automake.allow.when.app.running flag.
3) Start/restart the app and observe static content reloading.
For IntelliJ 2021.2 version or above below are steps that you need to follow
Add spring-boot-devtools dependency if not already added.
Enable Build project automatically as shown below
Enable option in Advanced Settings as shown below
On Linux, press:
Ctrl-Alt-Shift-/
For mac users I had to press Command + Shift + A
And restart INTELLIJ after Step1 and Step2 without which the registry option was not appearing.
You can user like bellow:
First Open Preferences.../Settings... -> Build, Execution, Deployment -> Compiler and allow Build project automatically. Image will look like
Second, we change Registry configuration. Press command+shift+A for macOS or if you are using Windows press Ctrl+Shift+A, and search for Registry. enable compiler.automake.allow.when.app.running.Images look like bellow
Registry image look like..
compiler.automake.allow.when.app.running enable image look like
Then Enjoy..
The option is now in Advanced settings:

How can I disable "Initialize Java Tooling" on Eclipse startup?

In our application which is a Eclipse plugin, when Eclipse starts it takes long time and the users are seeing "Initialize Java tooling" message on the left down corner of application. Because our users don't have anything to do with java, I wonder if it is possible to disable Initialize Java tooling.
Another question: What is Initialize Java tooling?
Try to terminate eclipse then backup and delete the folder
.metadata/.plugins/org.eclipse.core.resources/.history
Restarting eclipse will not hang the Java Tooling process.
from Command prompt just type
eclipse.exe -clean
The java-tooling implement a Java IDE supporting the development of any Java application, including Eclipse plug-ins. It adds a Java project nature and Java perspective to the Eclipse Workbench as well as a number of views, editors, wizards, builders, and code merging and refactoring tools. The Java-tooling provides a development environment to developer.
how to disable plugin at startup
you can try disabling the java-tooling while launching the application.I am giving you a snapshot.
go find perspective as Window->Preferences->Run&Launching->java Application-> and make debug an run combobox to none value.
Hope this can solve your problem.
In case of Eclipse Oxygen, this settings can be found at:
Eclipse > Preferences > Run/Debug > Launching > Perspectives > Java Application > Eclipse JDT Launcher
There will be a folder .metadata in your project workspace directory. Just delete the .log files in it and restart eclipse.
Just uncheck "Build Automatically" and force quit Eclipse. Then start it again.
Project>Build Automatically - uncheck
-force quit
-start Eclipse
I know kind of late advice but because I have this issue 3 days now and I am very very frustrated....just have a copy of your eclipse IDE "virgin" as much possible to rerun it. And any plugin you want to have just do it on a direct copied version of this "virgin" eclipse. This is the only way to get away with clumsy plugins and staff under the hood that you cannot control.
It's devastating to import the projects all the time from the start or deleting the metadata folders....
Is to remove or rename the .projects folder in .metadata/.plugins/org.eclipse.core.resources in the workspace folder. This doesn’t seem to affect any project and the .project folder will be recreated when Eclipse restarts

Categories