Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Eclipse plug-ins

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.

  1. He sees null pointer exceptions which didn't occur when I ran my plug-in project from my development environment.
  2. 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!

like image 274
Anand Avatar asked Nov 10 '12 18:11

Anand


People also ask

How do I get debug view in Eclipse?

2.4. When we start the program in debug mode, Eclipse will prompt with an option to switch to the Debug perspective. The Debug perspective is a collection of some useful views that help us visualize and interact with the debugger. We can also switch to the Debug perspective manually at any time.


2 Answers

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.

like image 191
tkotisis Avatar answered Sep 30 '22 15:09

tkotisis


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

like image 35
Jawher Avatar answered Sep 30 '22 15:09

Jawher