Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » ClassCastException when accessing with another plugin object
ClassCastException when accessing with another plugin object [message #256204] Sun, 27 June 2004 23:38 Go to next message
Eclipse UserFriend
Originally posted by: gtoor.pervasive.com

We are developing a RCP based application using 3.0 RC2. It consists of two
plugins (a viewer and an editor). The editor plugin uses the
ObjectContribution extension point to add a menu item to the viewer popup
menu. The menu item is displayed fine when a TableElement object is
selected in the viewer. However, I get a ClassCastException in the
selectionChanged() method when the action is invoked (See code below). When
I use the debugger and inspect the selection.getFirstElement(), it seems I
have a valid TableElement object (the object contains the class elements and
has the name of the table I need to edit). So why am I getting a
ClassCastException when casting in my method.

The TableElement class is defined in the viewer plugin which I am building
into a .jar file for use with the editor. The .jar file is specified using
the "library name" tag in the editor plugin.xml. Could this be a deployment
issue?

Any help will be greatly appreciated.
Gagan.

public class EditTableAction implements IObjectActionDelegate {


/* (non-Javadoc)
* @see
org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action. IAction)
*/
public void run(IAction action) {
....
}
public void selectionChanged(IAction action, ISelection tableSelection)
{
com.pervasive.pem.TableElement element;
if (tableSelection instanceof IStructuredSelection) {
selection = (IStructuredSelection) tableSelection;
// if ( selection.getFirstElement() instanceof TableElement)
element = (com.pervasive.pem.TableElement)
selection.getFirstElement(); // exception thrown here

}
}
}
!ENTRY org.eclipse.ui 4 4 Jun 27, 2004 22:32:28.306

!MESSAGE Could not create action delegate for id:
com.pervasive.utilities.tableeditor.actions.EditTableAction

Could not create action delegate for id:
com.pervasive.utilities.tableeditor.actions.EditTableAction

Reason:

!ENTRY org.eclipse.ui 4 4 Jun 27, 2004 22:32:28.306

!MESSAGE Internal plug-in action delegate error on creation.

!STACK 0

java.lang.ClassCastException

at
com.pervasive.utilities.tableeditor.actions.EditTableAction. selectionChanged
(EditTableAction.java:102)

at
org.eclipse.ui.internal.PluginAction.refreshEnablement(Plugi nAction.java:230
)

at
org.eclipse.ui.internal.PluginAction.createDelegate(PluginAc tion.java:117)

at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginActi on.java:247)

at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(Action
ContributionItem.java:915)

at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionI
tem.java:866)

at
org.eclipse.jface.action.ActionContributionItem$7.handleEven t(ActionContribu
tionItem.java:785)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :82)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2716)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2382)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1363)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1334)

at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:253)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:141)

at com.pervasive.utilities.pem.PemApplication.run(PemApplicatio n.java:27)

at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.
java:334)

at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:273)

at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:128)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39
)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl
..java:25)

at java.lang.reflect.Method.invoke(Method.java:324)

at org.eclipse.core.launcher.Main.basicRun(Main.java:185)

at org.eclipse.core.launcher.Main.run(Main.java:638)

at org.eclipse.core.launcher.Main.main(Main.java:622)

Internal plug-in action delegate error on creation.
Re: ClassCastException when accessing with another plugin object [message #256225 is a reply to message #256204] Mon, 28 June 2004 03:30 Go to previous message
Eclipse UserFriend
Originally posted by: newsserver_mails.bodden.de

Gagan Toor wrote:
> The TableElement class is defined in the viewer plugin which I am building
> into a .jar file for use with the editor. The .jar file is specified using
> the "library name" tag in the editor plugin.xml. Could this be a deployment
> issue?

Yes, it could indeed be. Note that each Plugin has its own classloader.
Also each class of a Java program is actually fully qualified by
<Classloader>+<PackageFragement>+<ClassName>. Usually the first bit is
the same for all classes in the application. Not so here, cause your one
plugin creates a class of type
<EditorPlugin>+com.pervasive.pem.TableElement and the other one expects
one of <ViewPlugin>+com.pervasive.pem.TableElement. I guess that could
be your problem.

A factory in one of the plugins could help solving that problem.

Eric

--
Eric Bodden, ICQ: 12656220, http://www.bodden.de, PGP: BB465582
Previous Topic:Can't run Eclipse 3.0
Next Topic:javaw.exe not found at launch, eclipse 2.1.3
Goto Forum:
  


Current Time: Wed Nov 05 18:36:41 EST 2025

Powered by FUDForum. Page generated in 0.03659 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top