Kelly Ellis
Kelly Ellis

Reputation: 1101

How do I resolve a dependency in an Eclipse plug-in I didn't write?

I'm trying to use a relatively new Eclipse plug-in (http://uqbar-tomcat-xt.sourceforge.net/download.html). It doesn't have an update site, so I can't install it through the UI in Eclipse, which usually resolves dependencies. All that's available for download is a single .jar, and the instructions on the website say to just drop it in eclipse/plugins. When I do that, it seems to work, in the sense that I get the new options in Window -> Show View that the plug-in should add. However, when I try to use either of those views, I get the following error:

org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter$TerminatingClassNotFoundException: An error occurred while automatically activating bundle org.uqbar.eclipse.tomcat.xt (304).
    at org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:125)
    at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:211)
...snip...
Caused by: org.osgi.framework.BundleException: The activator org.uqbar.eclipse.tomcat.xt.UqbarSydeoXtActivator for bundle org.uqbar.eclipse.tomcat.xt is invalid
    at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:157)
...snip...
Caused by: java.lang.Error: Unresolved compilation problems: 
    The import com.thoughtworks cannot be resolved
    XStream cannot be resolved to a type
    XStream cannot be resolved to a type
    XStream cannot be resolved to a type

The dependencies page of the above site lists several dependencies, including XStream. I tried downloading those .jars separately and dropping them into the eclipse/plugins directory as well, but that didn't resolve the error. When I look at the manifest in the jar, I see:

Bundle-ClassPath: .,commons-logging-1.0.4.jar,xpp3_min-1.1.4c.jar,xstr
 eam-1.3.jar,xstream-benchmark-1.3.jar

But obviously the xstream jars aren't available on the classpath (which is where?). I'm not sure where I can put them so that they're recognized by the plug-in.

I've tried contacting the developers and got no response, so I'm turning to SO. Is there anything I can do, or is the plug-in packaged incorrectly?

Update: Apparently the error is in the Activator, not the plugin itself. I tried importing the plugin as a source project, but the src/ directory is empty. The plugin doesn't appear in the list of available deployable plugins when I try to export it. So this is still unsolved.

Upvotes: 2

Views: 4704

Answers (2)

SteveD
SteveD

Reputation: 5405

Rich Seller's fix will work, though the real problem is a crappy plug-in which specifies a bunch of 3rd-party libraries on the Bundle-ClassPath, but doesn't actually include them! The Bundle-ClassPath is the classpath internal to the bundle, so any referenced libraries should be inside the bundle.

Since the source code is included, you could re-build the plug-in with the missing dependencies (license allowing), though I think all of those third-party dependencies should be external - but that's an entirely different discussion about how to write OSGi bundles/Eclipse plug-ins.

Upvotes: 1

Rich Seller
Rich Seller

Reputation: 84028

You can define an Eclipse fragment with the missing dependency on its classpath (normally in the lib directory of the fragment and specified on the classpath in the manifest).

A fragment is a special type of plugin that is attached to a target plugin. The fragment is merged with the target plugin at runtime, so the classes in the plugin will have access to the jar.

See this question for some pointers on creating a fragment.

Upvotes: 2

Related Questions