Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Unable to instantiate class?
Unable to instantiate class? [message #246287] Tue, 18 November 2008 21:33 Go to next message
Eclipse UserFriend
Originally posted by: el01120.mail.ntua.gr

Hello,

I am writing a plugin using GEF. It is something like the Shapes example. I was using Eclipse 3.2 but when I upgraded to 3.4 I have this strange problem:

!SESSION 2008-11-18 22:21:35.008 -----------------------------------------------
eclipse.buildId=M20080911-1700
java.fullversion=J2RE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460-20080816_22093 (JIT enabled, AOT enabled)
J9VM - 20080816_022093_LHdSMr
JIT - r9_20080721_1330ifx2
GC - 20080724_AA
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data /home/christos/runtime-EclipseApplication -dev file:/home/christos/workspace/.metadata/.plugins/org.eclipse .pde.core/Eclipse Application/dev.properties -os linux -ws gtk -arch x86_64 -consoleLog

!ENTRY org.eclipse.ui 4 4 2008-11-18 22:21:38.275
!MESSAGE Unable to create editor contributor: thesis.SimpleSequencingEditor

!ENTRY org.eclipse.equinox.registry 4 1 2008-11-18 22:21:38.276
!MESSAGE Plug-in "thesis" was unable to instantiate class "editor.SimpleSequencingEditorActionBarContributor".
!STACK 0
java.lang.InstantiationException: editor.SimpleSequencingEditorActionBarContributor
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1325)
at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:170)
at org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:867)
at org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(Work benchPlugin.java:259)
at org.eclipse.ui.internal.registry.EditorDescriptor.createActi onBarContributor(EditorDescriptor.java:195)
at org.eclipse.ui.internal.EditorManager.createEditorActionBars (EditorManager.java:320)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManag er.java:791)
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:643)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:428)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:594)
at org.eclipse.ui.internal.EditorAreaHelper.setVisibleEditor(Ed itorAreaHelper.java:263)
at org.eclipse.ui.internal.EditorManager.setVisibleEditor(Edito rManager.java:1410)
at org.eclipse.ui.internal.EditorManager$5.runWithException(Edi torManager.java:944)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:133)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3378)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3036)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(Work benchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$27.runWithException(Workbe nch.java:1361)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run (StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:133)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3378)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3036)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2293)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:386)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
------------------------------------------------------------ ------------------------------------------------------------ ------------

SimpleSequencingEditorActionBarContributor.java is a simple class

package editor;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.gef.ui.actions.ActionBarContributor;
import org.eclipse.gef.ui.actions.DeleteRetargetAction;
import org.eclipse.gef.ui.actions.RedoRetargetAction;
import org.eclipse.gef.ui.actions.UndoRetargetAction;
import actions.CreateSSAction;

public class SimpleSequencingEditorActionBarContributor extends ActionBarContributor {
IWorkbenchPart editor;

public SimpleSequencingEditorActionBarContributor(IWorkbenchPart editor) {
super();
this.editor = editor;
}

protected void buildActions() {
addRetargetAction(new DeleteRetargetAction());
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
addAction(new CreateSSAction(editor));
}

public void contributeToToolBar(IToolBarManager toolBarManager) {
toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
toolBarManager.add(getAction(ActionFactory.REDO.getId()));
toolBarManager.add(new Separator());
toolBarManager.add(getAction(CreateSSAction.OUTPUT));
}

protected void declareGlobalActionKeys() {
}
}

I don't know what other information would be relevant.
At compile time I get no errors, only few warnings like:
No required execution environment has been set (in MANIFEST.MF)
Class is a raw type. References to generic type Class<T> should be parameterized (in SimpleSequencingEditor.java)
Re: Unable to instantiate class? [message #246304 is a reply to message #246287] Wed, 19 November 2008 09:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: modica.cs.tu-berlin.deNOSPAM

Christos Gitsis schrieb:
> Hello,
>
> I am writing a plugin using GEF. It is something like the Shapes example. I was using Eclipse 3.2 but when I upgraded to 3.4 I have this strange problem:
> java.lang.InstantiationException: editor.SimpleSequencingEditorActionBarContributor
> at java.lang.J9VMInternals.newInstanceImpl(Native Method)
> at java.lang.Class.newInstance(Class.java:1325)
> ------------------------------------------------------------ ------------------------------------------------------------ ------------
>
> SimpleSequencingEditorActionBarContributor.java is a simple class
Hi Christos,

looking at the javadoc of Class.newInstance(Class.java:1325) I see
"InstantiationException - if this Class represents an abstract class, an
interface, an array class, a primitive type, or void; or if the class
has no nullary constructor".

I think you must put the nullary constructor explicitly in your class if
you implemented one with parameters (what do you need this for btw?).

> public class SimpleSequencingEditorActionBarContributor extends ActionBarContributor {
> IWorkbenchPart editor;
>
> public SimpleSequencingEditorActionBarContributor(IWorkbenchPart editor) {
> super();
> this.editor = editor;
> }
>
> I don't know what other information would be relevant.
> At compile time I get no errors, only few warnings like:
> No required execution environment has been set (in MANIFEST.MF)
> Class is a raw type. References to generic type Class<T> should be parameterized (in SimpleSequencingEditor.java)
>


Cheers,

Tony
Re: Unable to instantiate class? [message #246390 is a reply to message #246304] Thu, 27 November 2008 20:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: el01120.mail.ntua.gr

Στις Wed, 19 Nov 2008 10:10:56 +0100
Ο/Η Tony Modica <modica@cs.tu-berlin.deNOSPAM> έγραψε:

> Christos Gitsis schrieb:
> > Hello,
> >
> > I am writing a plugin using GEF. It is something like the Shapes
> > example. I was using Eclipse 3.2 but when I upgraded to 3.4 I have
> > this strange problem: java.lang.InstantiationException:
> > editor.SimpleSequencingEditorActionBarContributor at
> > java.lang.J9VMInternals.newInstanceImpl(Native Method) at
> > java.lang.Class.newInstance(Class.java:1325)
> > ------------------------------------------------------------ ------------------------------------------------------------ ------------
> >
> > SimpleSequencingEditorActionBarContributor.java is a simple class
> Hi Christos,
>
> looking at the javadoc of Class.newInstance(Class.java:1325) I see
> "InstantiationException - if this Class represents an abstract class,
> an interface, an array class, a primitive type, or void; or if the
> class has no nullary constructor".
>
> I think you must put the nullary constructor explicitly in your class
> if you implemented one with parameters (what do you need this for
> btw?).
>
> > public class SimpleSequencingEditorActionBarContributor extends
> > ActionBarContributor { IWorkbenchPart editor;
> >
> > public
> > SimpleSequencingEditorActionBarContributor(IWorkbenchPart editor)
> > { super(); this.editor = editor;
> > }
> >
> > I don't know what other information would be relevant.
> > At compile time I get no errors, only few warnings like:
> > No required execution environment has been set (in
> > MANIFEST.MF) Class is a raw type. References to generic type
> > Class<T> should be parameterized (in SimpleSequencingEditor.java)
> >
>
>
> Cheers,
>
> Tony

Thank you very much for the reply.
Your suggestion works in that I get no error message, but I would like to pass an argument to the constructor.
I want to access the editor in order to be able to access its model with ((SimpleSequencingEditor)getWorkbenchPart()).getModel(); I do this in CreateSSAction.java.
I realise that what I was trying to do was not going to work.

Another question is how would I pass an argument to the constructor of SimpleSequencingEditorActionBarContributor?
This is the relevant portion of plugin.xml
<editor
id="thesis.SimpleSequencingEditor"
name="Simple Sequencing Editor"
class="editor.SimpleSequencingEditor"
contributorClass="editor.SimpleSequencingEditorActionBarContributor "
extensions="ssq"
icon="ss_icon_2.jpg"
default="true">
</editor>
Is there a way to pass a parameter, or if not, what else could I do?
Re: Unable to instantiate class? [message #246396 is a reply to message #246390] Thu, 27 November 2008 21:41 Go to previous message
Eclipse UserFriend
Originally posted by: modica.cs.tu-berlin.deNOSPAM

Christos Gitsis wrote:
> I want to access the editor in order to be able to access its model with ((SimpleSequencingEditor)getWorkbenchPart()).getModel(); I do this in CreateSSAction.java.

Maybe you could override
ActionBarContributor.setActiveEditor(IEditorPart editor) and store the
editor in your contributor to be able to access it.

> Another question is how would I pass an argument to the constructor of SimpleSequencingEditorActionBarContributor?
> This is the relevant portion of plugin.xml
> <editor
> id="thesis.SimpleSequencingEditor"
> name="Simple Sequencing Editor"
> class="editor.SimpleSequencingEditor"
> contributorClass="editor.SimpleSequencingEditorActionBarContributor "
> extensions="ssq"
> icon="ss_icon_2.jpg"
> default="true">
> </editor>
> Is there a way to pass a parameter, or if not, what else could I do?

In your editor, you could try getEditorSite().getActionBarContributor()
and use some setters in you contributor?

Hope this helps.

Bye,
Tony
Previous Topic:The examples issue.
Next Topic:Stream file of GEF, output as XML or SVG
Goto Forum:
  


Current Time: Sat Apr 20 02:11:55 GMT 2024

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

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

Back to the top