Eclipse JEE Mars.2 Inspect not working - java

I was previously using Jboss Dev Studio (based on an older version of Eclipse) in Windows and was able to execute selected code using the shortcut Ctrl+Shift+I (when I hit a breakpoint in debug mode). A popup would appear with the result of the execution, which was extremely helpful.
I just setup Mars.2 JavaEE (4.5.2) to start a different project and am finding that this command no longer works. Under preferences->general->keys I definitely have the same shortcut (Inspect = Ctrl+Shift+i) but when I use that command, it simply obliterates the selected code and replaces it with a space! Has anyone else encountered this?
Thanks in advance.

Related

How to hot reload Tomcat server in VSCode

I'm migrating from Eclipse IDE (+ VSCode for coding Java servlets and HTML/CSS/JS webpages, respectively) to only Visual Studio Code for its lightweight.
I have several Java extensions installed for VSCode:
Language Support for Java(TM) by Red Hat
Tomcat for Java
Debugger for Java
Eclipse has a series of settings for hot reloading:
- Automatically publish when resources change
- Refresh using native hooks or polling
while VSCode doesn't seem to have any for me.
A few things I've try to reload my Java and web code:
Restart Tomcat server
Delete and re-adding Tomcat server
Delete and regenerate .war package (not sure if this does anything, it can run well without a .war package)
Good news...
It works automatically now. With Tomcat for Java Extension (And the rest of the Java Extension Pack):
https://marketplace.visualstudio.com/items?itemName=adashen.vscode-tomcat
Just make sure your settings are like this (search for "java.autobuild" to get those two in the first results):
Very important is, that you wont see any logs in the console on the HCR (Hot Code Replacement) like it happens in Eclipse ... but you in fact will see the replaced code behavior. Just debug over the piece of code you changed, and you will see it in fact changed in the running server.
UPDATE: I've found it works better with the 'manual'(default) setting. Just clicking once in the lightning icon. (Testing in Ubuntu 18.04 LTS)
[I say it works better because if I added lines to a Class' code with the 'auto' setting it will not add that code ... only if I change code in the existing lines. But with the manual setting I just save the file, and then click the lightning icon wait ~3 seconds myself and debug over the new code ... and everything goes well!!
... This solves my coding needs(lightweight Editor/IDE with Hot-Code-Replacement in Tomcat)]
Enjoy !
This article may be helpful, I migrate from other IDE to Vscode.
According to the article, if you install Debugger for Java, it enabled Hot code replacement(HCR) and then :
You can start a debugging session and change a Java file in your development environment, and the debugger will replace the code in the JVM running your code.
Hot code replacement for java comes to visual studio code
Install “Tomcat for java” extension in VScode.
Configure the Path of Tomcat in the above extension.
Now you should be able to run tomcat in usual build -> deploy mode. Now install DCEVM, By using “java -jar installer-light.jar”. (Select “Install DCEVM as altjvm”)
Place HotSwap Agent Jar in directory of your choice.
Now In VScode right-click the Tomcat server you have created. (The one from Step 3 ) And select “Customise JVM Options”.
In the file opened, Place “-XXaltjvm=dcevm
-javaagent:/[your_directory]/hotswap-agent-1.3.1-SNAPSHOT.jar” Now Right-click the tomcat server in VScode and select “Debug WAR package”, And select the WAR file.
If everything goes well, The WAR will be start in TOMCAT in debug mode with text “HOTSWAP AGENT” in the log.
Now your every save to your file will trigger Hot Reloading.
https://medium.com/#manoj_makkuboy/hot-reload-java-8-tomcat-server-in-vscode-ba6233d632e?

Unit tests terminated in Debug mode

I'm using IntelliJ IDEA 15.0.2 (Community Edition) under Windows 7 and Windows 10 Pro, Gradle 2.9, JDK 1.7.0_65. Operating systems installed as guests under VMware Workstation 11.1.3
I have created Android Gradle application with single empty activity and wanted to check how unit test support works. There is a single unit test module ApplicationTest.java created by IDE, it contains only constructor. Right-clicking on [java] folder I created 'All in Module' JUnit3 test configuration.
Tests complete successfully when I Run them, however fail if I Debug the configuration. Failure reason says 'Terminated' (screenshot, IDEA log) which explained in the documentation as 'Test terminated. This status is assigned to tests that were cancelled by clicking the Stop button'. Just want to confirm that I didn't click the Stop button.
Logcat logs don't report any failures, IDE log reports 2 tests passed too. However problem remains as IntelliJ still reports a termination.
Sometimes I also getting 'Test framework quit unexpectedly' error and no tests succeed.
I've done some research and found similar questions, no real solutions mentioned. Have strong suspicion that this is a configuration issue.
What do I do wrong?
Gabor's suggestion seemed to fix this issue for me. On a Mac (and I presume on a Windows machine, but with a different route to get there) go to Preferences:
From the menu bar at the top Android Studio → Preferences
or
Hit ⌘ and , to jump straight to it.
Then in the menu search box type "instant". Uncheck the box that says "Enable instant run..", which looks like the image below.
That fixed it for me; didn't even need to restart/kill ADB.
It seems to be enabled by default, and I use it often to hot-swap changes during development, so I didn't think to turn it off when running Espresso tests.
In my situation, the problem is solved by setting in the test's run configuration:
Shorten command line -> JAR manifest.
To get rid of unit test problems in debug mode, I deleted all test folders in android studio explorer, then I commented three test implementation lines in build.gradle(module) file. Then I changed the combobox in android studio menu (top of the IDE) from "all in app" to "app".
https://i.stack.imgur.com/alPrS.png
In our case the fix (that may not be required in newer Android-versions) was to:
Open Edit Configuration... for All tests (or what ever you renamed it into).
Switch to Debugger tab.
And finally, in Debug mode combo-box, select the Java option, because:
Although we have lots of Native codes,
Android-studio 3.2.1 (which we were using) does not seem to support debugging both (but Java only mode works fine).

Hot code swap is not working, why?

When I'm trying to write a simple one class console app - there is no problem. I can change code in a method when debugging.
The problem is with my web apps on Jetty. It's not working nor just in usual debug mode(pressing a debug button in eclipse) nor in remote debug mode described here. I can debug but can't change even usual not static methods, like adding sysout for example, I mean I can change it but after saving it's not updated and it works the same as before.
Also, I talked to my colleagues, it works for them but they use Spring Tool Suite version of eclipse, I tried and concluded that it works in the latest version STS out of the box in usual debug mode and it doesn't work in the latest version of Eclipse.
What can be a reason?
Answer based on my comments to the question (as suggested by OP):
Strange Eclipse behaviour can happen when your workspace or project metadata are corrupted. This can happen for example when you upgrade Eclipse version and use workspace created by the old version.
You should try to re-create your workspace and setup fresh project checkout. If the problem goes away, you know there was something fishy in the workspace metadata.
You would have to use hot swap proxy for swapping classes in EE container like jRebel.
Check it out.

Eclipse skipping breakpoints

My issue isn't a new one, and I found several threads about it, yet no one was helpful for me.
I hope this one will.
I can't debug with eclipse. It recognizes breakpoints, switches to debug view, but somehow it gets out of sync and I can't debug my code. Sometimes It works, but after a while It happens again.
I work with JDK 1.6.0_24, Glassfish 3.1, eclipse INDIGO (but it also happens on HELIOS).
I tried (as I found in this site) to set eclipse to use Parallel GC. I tried put it in the eclipse.ini file, I tried to put in the glassfish VM arguments itself, and I tried to put it at eclipse JDK additional VM arguments (preference -> installed JRE-> JDK -> etc). Nothing seem to work for me. I also tried them all together.
Help me please..
Thank you all from advance,
Ido
EDIT:
OK, I noticed few more things:
On the Debug view, in my stck trace, I found the exact class with the breakpoint is paused and it had this comment: "(Suspended breakpoint at line XX)". When I clicked the line, suddenly the green line appeared. Yet, as soon as I clicked F6 to continue, It went out of sync again, just the next line became suspended. Weird.
I checked the processes running on my computer and found that there are several "java.exe" processes running at the same time. (eclipse runs on javaw.exe). Maybe this is why glassfish and eclipse refuse to work together.
I checked the build path and found that this is my output folder: project-name/target/classes. Is this good?
Any thoughts?
Ido
So, I couldn't fix this but I found a workaround that completely solves this - FINALLY!.
I just stopped using glassfish WTP for debugging and set a remote debug to my local glassfish. it works perfectly with few minor annoying things - but breakpoints finally noticed.
Set remote debug
Go to your glassfish admin console and set your glassfish to work on debug mode.
Click on configuration --> server-config --> JVM settings, and check debug enabled check box.
Restart server
In eclipse - start server on normal mode (not debug - it is useless).
Go to Debug configurations and locate "Remote Java Application"
Create a new Remote java app debug config
Enter name (lets say Glassfish-Debug)
Choose project to debug
Enter your own IP address in the host section and set the port to 9009
This is optional but it is more comfortable to work with:
Go to "Common" tab, and check the Debug check box. This will make this Glassfish remote debugging configuration constant on your debug menu.
That's it. Now all you have to do is always start your Glassfish in normal mode and then go to Debug configurations and run This Glassfish remote debugging you just set.
And now I'm getting to the annoying part: After rebuild your project, sometimes you might get again out of sync. You just need to disconnect the remote debugging session and run it again. Small price to pay.
I hope it helps..
I had faced similar issues, But it turned out to be a simpler problem of multiple versions of JREs/JDKs installed.
Try Debug -> Run Configuration -> JRE -> Alternate JRE -> select JDK 1.6.0_24.
Also check for project build paths if correct Jars are been used.
Hope this helps.

How to uninstall plugins in Eclipse 3.4.X or higher

The GUI for managing plugins in Eclipse got a bit of an overhaul in version 3.4.0.
This GUI is accessed via the "Software Updates..." option in the Help menu.
The option to remove the selected Mylyn plugin is greyed out. In fact, this is true of virtually every installed plugin. I know that the Mylyn plugins are optional, so why amn't I provided with an option to remove them?
The following text is quoted from the Eclipse help docs:
The Uninstall wizard allows you to review and uninstall items in your configuration. This wizard is shown when you select items and press Uninstall... from the Installed Software page. To uninstall software from your system:
Click Help > About and then click Installation Details... to open a dialog showing pages that provide more detail about your installation.
Click the Installed Software tab to see a list of the software items that you have installed into your system.
Select the items that you wish to uninstall.
Click Uninstall...
The Uninstall Details page will show you a list of the items that will be uninstalled. Expanding each item will show what additional items (if any) will be uninstalled as a result of your choice.
If you change your mind about which items should be uninstalled, you may click Back to see a checkmark list of the items you selected before. You may check and uncheck different items in the list, and click Next when you are ready to continue.
Click Finish to start the uninstall.
Once all of the software is uninstalled successfully, you will be prompted to restart for the Workbench. Click Yes when asked to exit and restart the Workbench for the changes to take effect.
And just to update it for Helios - Eclipse 3.6
Help->Install New Software at the bottom of dialog there is link What is already installed once you click on that you will get list of installed plugins and Uninstal... button
eclipse 3.5(Galieo)
Help>> Install New Software >> Already Installed Plugins >> select Plugins >> Uninstall works charm.
There are distributions of Eclipse that come packaged with certain plugins that can't be mix-and-matched. That is the case with Mylyn, that went from a student's thesis project to an integral part of Eclipse. If you want to actually get rid of Mylyn, you may want to install Eclipse classic instead of the distribution you have, and then install the stuff you need.
The standard Eclipse distributions come with Myln.
BTW, Eclipser 3.5 completely changes all these screens :(
If you are using Windows, make sure you are running Eclipse as administrator. Without administrator privileges, some options may be grayed-out in "Installed Software".
In eclipse Helios (version 3.6), to uninstall a plugin:
Go to Help->Install New Software...
Click on "What is already installed?" link at the bottom right side of the dialog
In the Installed Software tab choose the software you want to uninstall
Click on the "Uninstall..." button at the bottom
Click 'Finish' on the Uninstall Details dialog
Observe the 'Uninstalling Software %' status at the bottom status bar of eclipse
Click 'Restart Now' when prompted to do so.
Eclipse restarts. Choose the workspace. Now when you go again to the Installed Software window , you do not find the uninstalled software.
In Eclipse 3.6 Helios, the interface has changed again. Go to "About Eclipse", and then click the "Installation Details" button in the about box.
While Help → About Eclipse IDE [or wherever it was in the past or will be in the future] → Installation Details → Installed Software → Uninstall... is the official and preferred way there are features/plugins the latter button of which is disabled.
Remember also that there aren't only plugins but features too. In my case I wanted to remove Mylyn and Wild Web Developer from a rather fresh Eclipse IDE for Enterprise Java and Web Developers package. I did the following.
But first a:
DISCLAIMER
Enter ECLIPSE_HOME at your own risk. Mistakes like typos might be in the following, too. I take no responsibility for whatsoever.
Created the directories features.DISABLED and plugins.DISABLED in Eclipse's home dir.
Moved *mylyn* from ECLIPSE_HOME/features to ECLIPSE_HOME/features.DISABLED
Moved *wildwebdeveloper* from ECLIPSE_HOME/features to ECLIPSE_HOME/features.DISABLED
Moved *mylyn* from ECLIPSE_HOME/plugins to ECLIPSE_HOME/plugins.DISABLED
Moved *wildwebdeveloper* from ECLIPSE_HOME/plugins to ECLIPSE_HOME/plugins.DISABLED
After starting Eclipse there were about a dozen "not found" errors in Eclipse's Error Log view. If you double-click on each of them you can see which dependency plugin JAR(s) haven't been found.
Set the Error Log view's filter to just display errors and warnings.
Moved the dependency plugin *.jars mentioned in the errors from ECLIPSE_HOME/plugins.DISABLED back to ECLIPSE_HOME/plugins one by one (with Eclipse restart after each) until no "not found" error appeared in the view any longer. It were nine *mylyn*.jars in the end.:
*.mylyn.commons.core_*
*.mylyn.commons.net_*
*.mylyn.commons.notifications.core_*
*.mylyn.commons.notifications.ui_*
*.mylyn.commons.screenshots.ui_*
*.mylyn.commons.ui_*
*.mylyn.commons.workbench_*
*.mylyn.commons.wikitext.markdown_*
*.mylyn.commons.wikitext.*
Note that this applies to a rather fresh Eclipse 2021-03 (4.19.0) installation. It might be different from one – even patch – version to the other.
Furthermore:
Keep Eclipse's Error Log view open for a while. The underlying OSGi activates bundles (plugins) on the fly if they are referenced from an other bundle (plugin) for the first time. And if one isn't there then...
Check the Error Log view especially after installing new features/plugins. They might rely on plugins/JARs you moved to .DISABLED. If that's the case move the according JAR(s) back to ECLIPSE_HOME/plugins and/or ECLIPSE_HOME/features.
If something doesn't work as it did in the past once in the future remember what you did and ... → Error Log view.
I'm running (a relatively fresh copy of) 3.4.1. I was able to select the same plug-in shown in your screen shot (Mylyn Bridge: Java Development) to get an enabled "Uninstall..." button. I'd suggest getting the latest updates and trying again.
It sure looks like there's no way to do this.
I just had exactly this problem with a fresh download of the Eclipse Java IDE (Ganymede SR2). I didn't want Mylyn, but I didn't want "Eclipse Classic", either, because the download was twice the size, I presume because it includes source.
The apparent solution was to update everything and restart Eclipse, after which the "Uninstall..." button became enabled for the Mylyn plugins. Unfortunately, this only uninstalled the most recent, updated version (3.0.11 IIRC), reverting to the un-uninstallable 3.0.5.
I just don't know what the hell these Eclipse developers are thinking! Removing plug-ins from Eclipse became a pain in the ass since Helios!
I hear you pal... I just went through the whole day trying to figure out as no one seems to give an straight answer like "do this, that, done."
Man I'd rather be programming instead....
Found, in the middle of my evening that it is possible to uninstall pretty much everything. The issue is that the damn thing is hidden in the "HELP->ABOUT". Who would guess after going over and over through the "Help->Install New Software" or "Help->Check for updates" and never finding anything like "remove" or "reinstall" or "force reinstall".
Seriouly, I'd rather go back to 1990 when we had Microsoft, Borland and Watcom.. you picked your platform and you'd be with 1/3 of the world of developers with you.. ok, perhaps Watcom didn't hit that mark but you get the point.
So... to uninstall any plugin from Eclipse Helios (Service Release 1) or Springsource 3.5.2 (or 3.6.1 I 'm using), do this:
close all your projects (just to be on the safe side);
Hit menu "HELP-->ABOUT" (yeah.. help, about);
Hit "Installation Details" button and you get the list with all plugins;
Click on the one you want to remove; hit uninstall;
If want to remove more than one, just apply the change without restart;
Goto to 4) as needed
Finally, restart Eclipse and reinstall what you need !
It was hard to find, but it worked very well for me.

Categories

Resources