[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: NoClassDefException exception thrown when Bundle.loadClass()
|
- From: "Dara Meinhard" <dara@xxxxxxxx>
- Date: Mon, 06 Jun 2005 23:38:28 +0200
- Newsgroups: eclipse.platform.rcp
- Organization: EclipseCorner
- User-agent: Opera M2/8.0 (Win32, build 7561)
Hi,
I don't know if I have understand your problem.
I think you would like to get a class instance of the IInputCommand
which the plugin extending yout extesion point has implemented
(in your code below it should be "AboutCommand").
Under assumption you have already looked up your extension in the
extension registry and have created the IConfigurationElement
(should be your object named "extension" in your code below) try the
following
to get an instance of "AboutCommand":
// The name of your attribute in your extension tag (command) which
references
// to the class
String EXTENSION_TAG_ATTRIBUTE_CLASS = "class" ;
// Get an instance
IInputCommand command = (IInputCommand)
configElement.createExecutableExtension(EXTENSION_TAG_ATTRIBUTE_CLASS);
Hope this helps,
Dara Meinhard
On Mon, 06 Jun 2005 15:30:07 +0200, Winters Mi <winters.mi@xxxxxxxxx>
wrote:
Hi Everyone,
Now I am developing a RCP software using Eclipse 3.1M7. I got some
problem when invoking Bundle.loadClass(), here is the situation.
I declared an extension point in my core plugin, named extension
point "command" and defined the interface that the extension class must
implement. Then I implemented that extension point in the other plugin,
called "helper", like
<extension
id="basiccommand"
point="com.xerdoc.lifebox.commands">
<command
class="com.xerdoc.lifebox.helper.AboutCommand"
command="about"
name="About Xerdoc"/>
</extension>
and the class implemented the interface, say IInputCommand which defined
in core plugin and all class extend the point must implement it.
In core plugin, I look up the extension registry for the command and
cooresponding class information. And I want to new an instance of that
class in core plugin.
// look up in the extension registry
....
// new instance
String symbolName = extension.getNamespace();
Bundle bundle = Platform.getBundle(symbolName);
Class klass = null;
try {
klass = bundle.loadClass(className);
IInputCommand command = (IInputCommand)klass.newInstance();
.....
But I caught the NoClassDefException: com/xerdoc/lifebox/IInputCommand
when
klass = bundle.loadClass(className);
I do not know why. I have added the core plugin into the dependency into
helper plugin's manifest file (plugin.xml). Sounds like that bundle's
class loader cannot find the core jar in his classpath.
Can you guys help me with that?
I know IPluginDescriptor has been deprecated in 3.1, so I am trying
using OSGi.Bundle, can you guys give me some solution for such problem?
Thanks a lot!
Regards,
Winters Mi
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/