14

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!

Lii
  • 11,553
  • 8
  • 64
  • 88
Anand
  • 2,329
  • 4
  • 19
  • 25

4 Answers4

20

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.

tkotisis
  • 3,442
  • 25
  • 30
  • Thanks tkotisis. I was able to remote debug with your help, and found out that the issue was because of a file write that we were doing from within the plug-in. FileWriter threw an access denied error in the production environment, which didn't happen in our development systems. I was able to figure this out only by remote debugging. Thanks again! – Anand Nov 11 '12 at 18:50
3

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

Jawher
  • 6,937
  • 1
  • 17
  • 12
  • Thanks for the response Jawher. The issue in this case was in code, which I figured after remote debugging. – Anand Nov 11 '12 at 18:58
0

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.

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
  • Thanks Chris. I understand how the regular debugging works. And when I do what you've mentioned above, all the functionalities in my plug-in works as expected. I have set-up a maven/jenkins based CI system, which creates an update site for me. When my colleague uses this update site to install my plug-in, and starts using the plug-in functionality, I see a lot of exceptions (those which I'm mentioned in my original question). I didn't encounter these issues when I debug it in my development environment. How do I figure out the problem in the production environment? – Anand Nov 11 '12 at 07:39
  • 1
    The two most likely causes of those exceptions are hard-coded file paths and resources (e.g. config files and icons) that didn't get built into the plugin jar. For the latter, look at the build tab on your plugin.xml editor and make sure every necessary file is selected for inclusion. As for exceptions in general, how do you know that you're getting exceptions? Are you using the logging support in your plugin's Activator class that can write messages to the Error Log view? – Chris Gerken Nov 11 '12 at 14:23
  • Thanks for the details Chris. This was an issue in code, which I figured after remote debugging. – Anand Nov 11 '12 at 18:57
0

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

Stuart Cardall
  • 2,099
  • 24
  • 18