Debugging Eclipse plug-ins - eclipse

This is my first attempt at creating an Eclipse plug-in. I've created one, along with a feature and update site. I set the target platform as my local Eclipse installation. When I run/debug the plugin from within the development environment everything works fine.
Now, my colleague installed the plug-in from the update site that I hosted. When he starts using any of the functionality exposed by my plugin he gets runtime exceptions.
He sees null pointer exceptions which didn't occur when I ran my plug-in project from my development environment.
I have a wizard that's part of my plug-in. When he close it he gets a "Unhandled event loop exception", and the wizard doesn't close. I didn't have this issue when I was running/debugging my plugin in my development environment.
Now I'm confused as to why the same plug-in is behaving differently in the production environment, as against the dev environment and when I was debugging it from my IDE. The target platform in both cases is the same Eclipse version. What could be the reasons?
And how do I debug the plug-in in a production environment? Is there a remote debugging capability for debugging the plug-ins on the production environment?
Any suggestions would be really useful!

To remote debug your plug-in, first add debug arguments to your target Eclipse .ini file
-vmargs
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044
before launching it.
Then open another Eclipse instance with a workspace containing your plug-in project.
Open Run > Debug Configurations..., select Remote Java Application and create a new configuration.
As Project, browse and select your plug-in project.
Also fill in your connection properties (host of target Eclipse and port 1044).
Launching the newly created debug configuration allows you to debug your plug-in the same way you debug locally.

Now I'm confused as to why the same plug-in is behaving differently in
the production environment, as against the dev environment and when I
was debugging it from my IDE. The target platform in both cases is the
same eclipse version. What could be the reasons?
This is a classic: Eclipse plugins and RCP applications do indeed behave differently between PDT (the Eclipse IDE) and the exported product.
In your case, a NullPointerException thrown from the exported version but not from Eclipse is 9 times out of 10 an image or other resource files (properties, etc.) that is loaded by your code but is not listed in the build.properties of your plugin.
Anyway, you'll need to check the logs to retrieve the stacktrace and hunt down its cause. Such logs could be found in your friend's workspace under le .metadata/.log file

From your development workspace as it stands now, use the "Debug As -> Eclipse Application" menu item to startup a test workspace. When it starts up, you'll have two workspaces running: the original development workspace and the new test workspace. You can set breakpoints in your plugin code in the development workspace and run your plugin in the test workspace.
When your plugin execution in the test workspace gets to one of your breakpoints, execution will pause and you can use the Debug view in your development workspace to look at variables, set more breakpoints or anything else you want to do to debuf your plugin.

See the Apache Wiki for Developing with Eclipse.
Under Windows 10 with Tomcat running as a windows service I started:
tomcat8.5\bin\Tomcat8w.exe
& added in the Java tab as the first entry in Java Options to enable remote debugging:
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n

Related

Eclipse with WAS fast deployment setup

Which version of Eclipse should I use for WAS9?
What are the steps to enable development with WAS9 on Eclipse?
What configuration should I have to see changes taking effect as I save the files?
1. WebSphere Developer Tools only works on Eclipse versions up to (and including) 2020-06
2. Only the before mentioned plugin has to be installed to enable Eclipse to add WAS9 server and to enable publishing to/debugging it from Eclipse.
The plugin's official page: https://marketplace.eclipse.org/content/ibm-websphere-application-server-v9x-developer-tools
I installed by: Help, Install software, Add: http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/updates/wdt/2020-03_comp/
If you downloaded the WebSphere development tools from the marketplace, then added a server, it should be enough, setting WebSphere JRE is not needed but WDT works best with the JRE that is shipped with WAS (located in /java)
3. To achieve fast deployment, for test driven development I use the following setup:
WAS server options
Publishing: Never Publish
Publishing settings...
Run server with resources within the workspace
Minimize and Auto publish options checked.
Project/Build automatically: checked
This way as I save a java or FE file, it is immediately served by the WAS server.
Official, full details for the WAS publishing settings are here: https://www.ibm.com/docs/en/wasdtfe?topic=server-publishing-settings-websphere-application-traditional
Misc
If there are bigger modifications that would require a publish then my project usually fails to start and I have to do a stop server, full clean build and then start again. Because of this I chose not to do any automatic publishing as the resources updated in Eclipse are already provided from the server and a publish event would trigger the reinstallation of the application that takes a lot of time and in my case fails without full clean install.
Probably you won't need these additional settings in eclipse.ini to load Eclipse with some exta jars that I do load libEclipse directory {com.ibm.ws.orb.jar, com.ibm.msg.client.provider.jar, com.ibm.msg.client.jms.jar, com.ibm.msg.client.jms.internal.jar}
-Djava.endorsed.dirs=C:\DEV\libEclipse\
-Dcom.ibm.websphere.thinclient=true

Using intellij to debug eclipse plugins

I am currently working on eclipse plug-in that involves many modules, and I would like to debug and run this eclipse plug-in from IntelliJ.I open this project in IntelliJ to edit code but when I have to run/debug this project I have to open eclipse IDE and start it from there. How can I use IntelliJ to do this?
I haven't actually tried this ... but you could try launching the RCP application stand alone but with the remote debug parameters specified for in your application's .ini file.
Then just point IntelliJ to the appropriate source and attach it's debugger to the running app.
Why do you want to do that? Eclipse has multiple tools for the plugin development that you will miss in IntelliJ. Also you need to build your plugin as product headless and then attach a debugger to it.
In my opinion it doesn't worth the effort. I would install Eclipse and devolop with eclipse.

Debugging an eclipse within another eclipse - Eclipse Trader

According to this link
It seems easy to setup the environment. Into the last paragraph:
Setup the Run Configuration
There should be a misterious EclipseTrader run configuration appearing from nowhere !!
Obviously there is no such thing !!
The question is, how can I debug an eclipse within another elipse ?? Is it possibile ?
If you don't have the Eclipse application entry in the available debug configurations then you should probably be running an Eclipse which does not have the plug-in development environment (PDE) installed.
You can either download the Eclipse classic package which already contains PDE from the download page or install the PDE plug-ins in your current Eclipse platfom from the Eclipse update sites.

Unable to debug Eclipse Application because of missing classes

I have written an DSL plug-in using Xtext 2.2.1. After upgrading to Xtext 2.3.0, I cannot debug the related Eclipse Application (i.e. I'm using a launch config which is labeled "Eclipse Application" to start an instance with my DSL plug-in from within Eclipse) because of this error:
Error instantiating builder 'org.eclipse.xtext.ui.shared.xtextBuilder'.
Plug-in org.eclipse.xtext.ui.shared was unable to load class org.eclipse.xtext.ui.shared.internal.ExecutableExtensionFactory.
org/eclipse/xtext/ui/guice/AbstractGuiceAwareExecutableExtensionFactory
What I tried:
I deselected all bundles from the target platform in the launch configuration, clicked "Add Required Plug-ins", tried again, same error.
I made sure that org.eclipse.xtext.ui and org.eclipse.xtext.ui.shared version 2.3.0 are available in the plug-ins list and both are enabled.
When I install the plug-in into my IDE, it works perfectly. I just can't launch an Eclipse Application from within the IDE.
"Validate Plug-ins" doesn't show any problems.
Any ideas how I can fix this?
While this is neither an answer to the question, why the launcher stopped working, nor a way to fix the existing launcher, you should at least be able to get back to work by creating a new launcher. To do this, just select Run As > Eclipse Application from the context menu of the XText project. This way, Eclipse should handle the creation and configuration of the launcher for you.
Be sure that Eclipse actually creates a new launcher! If Eclipse finds an existing Eclipse Application launcher, it might use that one instead. You should at least rename the old launcher, so you can tell which one is used (shown at the top of the Console View). The new launcher will by default have the name "Eclipse Application". If Eclipse still uses the old launcher you may have to remove that launcher first.
If you want to find out what was wrong with the old launcher, or if that launcher was specifically configured and you want to preserve that configuration, this may help: Eclipse stores the launcher configurations in the directory .metadata/.plugins/org.eclipse.debug.core/.launches/ located in the workspace, so you could back up the old launcher and then compare it to the newly created one using some diff tool.

Execute a function before debug in Eclipse

Does anyone know if it's possible in Eclipse, to execute a script/function/anything right before launching my app in debug? There only seems to be a few options - after clean, during a clean, during manual builds, during auto-builds
I want to execute an external tool (rsync) so I can make sure my assets are up to date before running.
Cheers,
Shane
Eclipse CDT provides special launch configuration type (Launch Group), which you can use to group several launch configurations (included External Tools) to be executed either sequentially, parallel or mixed. The drawback is that you need to have CDT installed in your Eclipse.
Update: There is similar question, which deals with launching multiple launch configurations.
If you want to add the "Launch Group" feature onto an existing, not necessarily CDT, eclipse install, you can install just the plugin called "C/C++ Remote Launch". (org.eclipse.cdt.launch.remote) - it is not C/C++ specific.