Project: Eclipse_Platform_UI
Bug 331621 Workbench throws NPE's on initial startup after install when bundles are started programmatically in earlyStartup()
Reported: 2010-12-01 18:40:11 | Status: verified fixed

Build Identifier: M20091008-1320 Our application runs on top of the Eclipse IDE, and we're seeing NullPointerExceptions in the error log file when the it starts for the first time after installation (or with the -clean option). Besides the exceptions, there seems to be no ill effects, and the exceptions do not occur in subsequent startups. The problem seems to the related to starting bundles programmatically in our application's earlyStartup(IStartup). Our application is starting the following bundles in earlyStartup(): org.mortbay.jetty, org.eclipse.equinox.http.jetty, org.eclipse.equinox.http.registry, com.ibm.nex.3rdparty.spring (spring lib), org.springframework.bundle.osgi.core, org.springframework.bundle.osgi.web, org.springframework.bundle.osgi.extender, org.springframework.bundle.osgi.io, org.eclipse.equinox.servletbridge. This is the exception we're getting in the Error Log: java.lang.NullPointerException at org.eclipse.ui.internal.Workbench.getWorkbenchWindows(Unknown Source) at org.eclipse.ui.internal.ExtensionEventHandler.registryChanged(Unknown Source) at org.eclipse.core.internal.registry.ExtensionRegistry$2.run(Unknown Source) at org.eclipse.core.runtime.SafeRunner.run(Unknown Source) at org.eclipse.core.internal.registry.ExtensionRegistry.processChangeEvent(Unknown Source) at org.eclipse.core.runtime.spi.RegistryStrategy.processChangeEvent(Unknown Source) at org.eclipse.core.internal.registry.osgi.ExtensionEventDispatcherJob.run(Unknown Source) at org.eclipse.core.internal.jobs.Worker.run(Unknown Source) It seems that windowManager is null when the getWorkbenchWindows() function gets called. public IWorkbenchWindow[] getWorkbenchWindows() { Window[] windows = windowManager.getWindows(); IWorkbenchWindow[] dwindows = new IWorkbenchWindow[windows.length]; System.arraycopy(windows, 0, dwindows, 0, windows.length); return dwindows; } Reproducible: Always

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/ExtensionEventHandler.java bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java