简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM