Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317930

Summary: [CommonNavigator] NPE during perspective switch after project creation
Product: [Eclipse Project] Platform Reporter: Sebastian Westemeyer <eclipse>
Component: IDEAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: aphung.work, dganit.keidar, eclipse, elaskavaia.cdt, gaad.salner, loskutov, michael.adada, mike.bernat, pierre-charles.david, sellis, troygnichols, Udo.Walker, yevshif
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Sample plugin to reproduce the Exception none

Description Sebastian Westemeyer CLA 2010-06-25 04:31:33 EDT
Build Identifier: 20100617-1415

Hi!

I have updated my Eclipse distribution to Helios and found a NullPointerException in my log-file when working with a project dialog I have created myself. I am suspecting a bug in the IDE though, as everything was fine in Galileo and the project wizard is more or less a stripped down version of the org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard.

The problem seems to only occur on switching to a perspective containing a "Properties" View. Getting the IViewPart of the "Project Explorer" fails in the constructor of org.eclipse.ui.internal.navigator.resources.workbench.TabbedPropertySheetTitleProvider which causes the NPE while trying to access the view parts adapters.

IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ProjectExplorer.VIEW_ID);
INavigatorContentService contentService = (INavigatorContentService) part.getAdapter(INavigatorContentService.class);

Adding a project explorer to my perspective solves the problem, I don't need it in my perspective, though.

The stack trace is:

!MESSAGE Plug-in "org.eclipse.ui.navigator.resources" was unable to instantiate class "org.eclipse.ui.internal.navigator.resources.workbench.TabbedPropertySheetTitleProvider".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.ui.internal.navigator.resources.workbench.TabbedPropertySheetTitleProvider.<init>(TabbedPropertySheetTitleProvider.java:44)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:184)
	at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:904)
	at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)
	at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:55)
	at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyRegistry.<init>(TabbedPropertyRegistry.java:127)
	at org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyRegistryFactory.createRegistry(TabbedPropertyRegistryFactory.java:74)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.initContributor(TabbedPropertySheetPage.java:406)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.<init>(TabbedPropertySheetPage.java:295)
	at org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage.<init>(TabbedPropertySheetPage.java:274)
	at org.eclipse.ui.internal.navigator.resources.workbench.TabbedPropertySheetAdapterFactory.getAdapter(TabbedPropertySheetAdapterFactory.java:37)
	at org.eclipse.core.internal.adapter.AdapterFactoryProxy.getAdapter(AdapterFactoryProxy.java:80)
	at org.eclipse.core.internal.runtime.AdapterManager.getAdapter(AdapterManager.java:295)
	at org.eclipse.ui.part.WorkbenchPart.getAdapter(WorkbenchPart.java:151)
	at org.eclipse.ui.navigator.CommonNavigator.getAdapter(CommonNavigator.java:453)
	at org.eclipse.ui.internal.views.ViewsPlugin.getAdapter(ViewsPlugin.java:103)
	at org.eclipse.ui.views.properties.PropertySheet.doCreatePage(PropertySheet.java:206)
	at org.eclipse.ui.part.PageBookView.createPage(PageBookView.java:408)
	at org.eclipse.ui.part.PageBookView.partActivated(PageBookView.java:751)
	at org.eclipse.ui.views.properties.PropertySheet.partActivated(PropertySheet.java:325)
	at org.eclipse.ui.part.PageBookView.showBootstrapPart(PageBookView.java:920)
	at org.eclipse.ui.part.PageBookView.createPartControl(PageBookView.java:491)
	at org.eclipse.ui.views.properties.PropertySheet.createPartControl(PropertySheet.java:156)
	at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
	at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:529)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1254)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1207)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1606)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:647)
	at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:574)
	at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:568)
	at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:272)
	at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:981)
	at org.eclipse.ui.internal.WorkbenchPage.setPerspective(WorkbenchPage.java:3614)
	at org.eclipse.ui.internal.WorkbenchPage.busySetPerspective(WorkbenchPage.java:1041)
	at org.eclipse.ui.internal.WorkbenchPage.access$16(WorkbenchPage.java:1025)
	at org.eclipse.ui.internal.WorkbenchPage$19.run(WorkbenchPage.java:3715)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.setPerspective(WorkbenchPage.java:3713)
	at org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard.replaceCurrentPerspective(BasicNewProjectResourceWizard.java:379)
	at org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard.updatePerspective(BasicNewProjectResourceWizard.java:528)
	at org.mydomain.myplugin.NewProjectWizard.updatePerspective(NewProjectWizard.java:208)
	at org.mydomain.myplugin.NewProjectWizard.performFinish(NewProjectWizard.java:188)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:811)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:430)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.ui.internal.navigator.wizards.WizardShortcutAction.run(WizardShortcutAction.java:98)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	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(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

I am going to attach a simple plugin to reproduce the error. 

Reproducible: Always

Steps to Reproduce:
1. Create new project using my own wizard
2. Yes, I want to switch to my perspective

Reset situation by closing perspective.
Comment 1 Sebastian Westemeyer CLA 2010-06-25 04:34:14 EDT
Created attachment 172724 [details]
Sample plugin to reproduce the Exception
Comment 2 Prakash Rangaraj CLA 2010-07-29 04:35:28 EDT
Sounds like CNF. 

Franics, 

  Please reassign back to inbox, if its not a CNF bug.
Comment 3 Paul Webster CLA 2010-08-10 10:29:25 EDT
*** Bug 318898 has been marked as a duplicate of this bug. ***
Comment 4 Udo Walker CLA 2012-06-05 03:40:38 EDT
I have the same problem in Indigo. I produced a product based on Helios 3.6.1 and it worked fine with the tabbed properties sheet.
At the moment I try to integrate my plugins into an Indigo IDE and it logs the above message. If I produce a RCP product without the plugins which manage a workspace for project like the common navigator, package explorer, etc. then I do not get the message in the log file. It only occurs when the common navigator plugin is also available. 

Do I miss something like disable a feature in the tabbed properties view to not ask for a reference to the navigator or do I have to register some factory or adapter to get rid of the message? I do not need the navigator at all.
Comment 5 An Phung CLA 2012-12-13 11:23:34 EST
I also have this problem in Juno.
Comment 6 Scott Ellis CLA 2013-02-25 17:48:11 EST
I have the same problem in my product based on Indigo when the Egit perspective is opened.
Comment 7 Francis Upton IV CLA 2013-05-21 03:02:25 EDT
I think this is a dup of bug 406903 which was just fixed in 4.3 RC1, can you give it a try there and let me know?
Comment 8 Michael Adada CLA 2013-08-21 12:36:34 EDT
Hi Francis,
Sorry, but this is still reproducible in the official Kepler release...
Comment 9 Gad Salner CLA 2014-01-19 09:48:38 EST
you could prevent NPE by checking the retrieved part:
if (part == null){
WorkbenchNavigatorPlugin.log(
	"Could not acquire INavigatorContentService. No part found", null);//$NON-NLS-1$
return;
		}
Comment 10 Udo Walker CLA 2017-01-27 04:21:59 EST
Something happened here?
Comment 11 Andrey Loskutov CLA 2017-01-28 10:03:29 EST
(In reply to Udo Walker from comment #10)
> Something happened here?

Do you still observe the problem with 4.6, or why do you ask? The original NPE was fixed with bug 467539 but the actual root cause is still there and tracked with bug 489335.

*** This bug has been marked as a duplicate of bug 467539 ***
Comment 12 Udo Walker CLA 2017-01-30 01:40:32 EST
I still have the problem from bug 489335.

I do not observe the problem described in here anymore.