Developing a plugin using 3M8 - the new view is working fine - and now
trying to add a preferences page.

Whenever I try to open my preferences page, which is properly listed
under Windows|Preferences, I get an "unable to instantiate" message for
my preferences page when I run the plugin in the Run-time Workbench.

To check my work, I created a completely new "test" plug-in project
using the view wizard template, then used the New Extension point wizard
to add a sample extension to org.eclipse.ui.preferencePages

When I run that, I get the same error dialog with same message (only the
name of the plug-in is different):

Gerald B. Rosenberg schrieb:
> To check my work, I created a completely new "test" plug-in project
> using the view wizard template, then used the New Extension point wizard
> to add a sample extension to org.eclipse.ui.preferencePages
>
> When I run that, I get the same error dialog with same message (only the
> name of the plug-in is different):
>
> Plug-in "test" was unable to instantiate class
> "test.preferences.SamplePreferencePage".

I assume you forgot to provide the default values for your preferences
in the preference store. At least that was the reason for me getting the
same error during development of some plugins. :)

> Developing a plugin using 3M8 - the new view is working fine - and now
> trying to add a preferences page.
>
> Whenever I try to open my preferences page, which is properly listed
> under Windows|Preferences, I get an "unable to instantiate" message for
> my preferences page when I run the plugin in the Run-time Workbench.
>
> To check my work, I created a completely new "test" plug-in project
> using the view wizard template, then used the New Extension point wizard
> to add a sample extension to org.eclipse.ui.preferencePages
>
> When I run that, I get the same error dialog with same message (only the
> name of the plug-in is different):
>
> Plug-in "test" was unable to instantiate class
> "test.preferences.SamplePreferencePage".
>
> What more do I have to do to enable the plug-in to instantiate the
> preference page class?
>
> Thanks,
> Gerald
>
Hi,

i think any error in the init of preference page would cause this message.
So i would like set a breakpoint at the begin of any implements method by
you. Then start the runtime-workbench for debug mode.
Maybe you have forgotten a dependency of your plugin, then the needed
import could not be found and the object could not be instanciate. Or you
have really a NullPointer in your methods...
To create a preference page you need:
1) implements extention point
2) create a class wich is subclass of PreferencePage and implements
IWorkbenchPreferencePage
3) implements the methods init(Workbench), createContents(Composite)

In article <c6ieus$5to$1@eclipse.org>, michael.keppler@gmx.de says...
> Gerald B. Rosenberg schrieb:
> > To check my work, I created a completely new "test" plug-in project
> > using the view wizard template, then used the New Extension point wizard
> > to add a sample extension to org.eclipse.ui.preferencePages
> >
> > When I run that, I get the same error dialog with same message (only the
> > name of the plug-in is different):
> >
> > Plug-in "test" was unable to instantiate class
> > "test.preferences.SamplePreferencePage".
>
> I assume you forgot to provide the default values for your preferences
> in the preference store. At least that was the reason for me getting the
> same error during development of some plugins. :)
>
> Have a look at
> http://www.eclipse.org/articles/Article-Preferences/preferen ces.htm
> and concentrate on the section "The Preference Store and the Plug-in" of
> that article to set default values.
>
> Ciao, Michael.
>

Yes, I did not have the defaults set. Unfortunately, correcting that
did not solve my problem (but it may have solved my next problem).

In article <pan.2004.04.27.12.56.57.138029@gmx.net>, th.michel@gmx.net
says...
>
> i think any error in the init of preference page would cause this message.
> So i would like set a breakpoint at the begin of any implements method by
> you. Then start the runtime-workbench for debug mode.
> Maybe you have forgotten a dependency of your plugin, then the needed
> import could not be found and the object could not be instanciate. Or you
> have really a NullPointer in your methods...
> To create a preference page you need:
> 1) implements extention point
> 2) create a class wich is subclass of PreferencePage and implements
> IWorkbenchPreferencePage
> 3) implements the methods init(Workbench), createContents(Composite)
>
> I hope it was usefull Thomas
>

Comments helped trace the problems to a NPE. My preference page
constructor follows the standard pattern, but fails at the point of
trying to retrieve the preferenceStore. Here is the actual code:

The DocPrecisionPlugin.getDefault() method does run, but the breakpoint
on the DocPrecisionPlugin class constructor -- which is where the value
returned by the getDefault method is set -- is never caught by the
debugger.

Meaning that the DocPrecisionPlugin class is not being instantiated
before the workbench tries to instantiate my preferences page? Is there
something I need to do/set to have my DocPrecisionPlugin class
instantiated automatically?

FWIW, turns out to have been the mere existance of the wizard generated
meta-inf/Manifest.mf file. Simply removing that file allowed my nascent
plugin preference pages to run without any problem.

Anyone know what the manifest is for and why it would, as generated,
prevent my main plugin class from being instantiated prior to the
preference page from being called?

Thanks to Michael and Thomas.

In article <MPG.1af80f88b34f5414989683@news.eclipse.org>, no@ddress.here
says...
> In article <pan.2004.04.27.12.56.57.138029@gmx.net>, th.michel@gmx.net
> says...
> >
> > i think any error in the init of preference page would cause this message.
> > So i would like set a breakpoint at the begin of any implements method by
> > you. Then start the runtime-workbench for debug mode.
> > Maybe you have forgotten a dependency of your plugin, then the needed
> > import could not be found and the object could not be instanciate. Or you
> > have really a NullPointer in your methods...
> > To create a preference page you need:
> > 1) implements extention point
> > 2) create a class wich is subclass of PreferencePage and implements
> > IWorkbenchPreferencePage
> > 3) implements the methods init(Workbench), createContents(Composite)
> >
> > I hope it was usefull Thomas
> >
>
> Comments helped trace the problems to a NPE. My preference page
> constructor follows the standard pattern, but fails at the point of
> trying to retrieve the preferenceStore. Here is the actual code:
>
> public class PreferencePage extends FieldEditorPreferencePage implements
> IWorkbenchPreferencePage {
>
> public static final String SAVE_STUFF = "savestuff";
>
> public PreferencePage() {
> super(GRID);
> DocPrecisionPlugin x = DocPrecisionPlugin.getDefault();
> // !!!! At this point x is null !!!!!
> setPreferenceStore(DocPrecisionPlugin
> .getDefault().getPreferenceStore());
> setDescription("Construction Helper");
> initializeDefaults();
> }
> ....
>
> The DocPrecisionPlugin.getDefault() method does run, but the breakpoint
> on the DocPrecisionPlugin class constructor -- which is where the value
> returned by the getDefault method is set -- is never caught by the
> debugger.
>
> Meaning that the DocPrecisionPlugin class is not being instantiated
> before the workbench tries to instantiate my preferences page? Is there
> something I need to do/set to have my DocPrecisionPlugin class
> instantiated automatically?
>
> Thanks,
> Gerald
>