Bug 185254 - Null Pointer Exception in BuildPluginAction.makeScripts
Summary: Null Pointer Exception in BuildPluginAction.makeScripts
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Noam Chitayat CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
: 187816 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-02 18:50 EDT by Brian Nettleton CLA
Modified: 2007-06-05 18:54 EDT (History)
3 users (show)

See Also:


Attachments
Patch for bug 185254. (Affects ConvertedProjectsPage.java) (4.19 KB, patch)
2007-05-08 18:41 EDT, Noam Chitayat CLA
no flags Details | Diff
Revised patch for bug 185254. (Affects BuildPluginAction.java, ConvertedProjectsPage.java, pderesources.properties, PDEUIMessages.java) (7.97 KB, patch)
2007-05-09 11:29 EDT, Noam Chitayat CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Nettleton CLA 2007-05-02 18:50:19 EDT
Build ID: M20070212-1330

Steps To Reproduce:
1. Create a plain java project
2. Create a directory META-INF
3. Create a manifest file META-INF/MANIFEST.MF with the
single line in it:
Manifest-Version: 1.0
4. Convert the project to a plug-in project by running the wizard started by <project>->Context Menu->PDE Tools->Convert projects to plugin projects...
5. Try to create an Ant Build File by selecting the build.properties file and then Context Menu->PDE Tools->Create Ant Build File

Result is a Null Pointer Exception:
java.lang.NullPointerException
	at org.eclipse.pde.internal.ui.build.BuildPluginAction.makeScripts(BuildPluginAction.java:44)
	at org.eclipse.pde.internal.ui.build.BaseBuildAction.doBuild(BaseBuildAction.java:115)
	at org.eclipse.pde.internal.ui.build.BaseBuildAction.access$0(BaseBuildAction.java:104)
	at org.eclipse.pde.internal.ui.build.BaseBuildAction$2.run(BaseBuildAction.java:70)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1737)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1719)
	at org.eclipse.pde.internal.ui.build.BaseBuildAction$1.run(BaseBuildAction.java:77)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:369)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:313)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:763)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:760)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2283)
	at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:1130)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.progress.ProgressManager.runInUI(ProgressManager.java:1126)
	at org.eclipse.pde.internal.ui.build.BaseBuildAction.run(BaseBuildAction.java:84)
	at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:254)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:539)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:400)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	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.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)



More information:
Comment 1 Brian Bauman CLA 2007-05-02 20:01:54 EDT
seems like this might be a good bug for Noam Chitayat.  The problem is when converting we check to see if a Manifest exists.  Instead, we should check to see if a valid OSGi Manifest exists.  Would give some exposure to models and modifying files.
Comment 2 Wassim Melhem CLA 2007-05-03 19:09:58 EDT
Noam to fix it.  Brian to review.
Comment 3 Noam Chitayat CLA 2007-05-08 18:41:24 EDT
Created attachment 66378 [details]
Patch for bug 185254. (Affects ConvertedProjectsPage.java)

If the Manifest file exists, we assume it has the necessary information for a plugin and do not alter it. Afterwards, when we try to read in necessary data, an NPE is thrown if the data is missing.

ConvertedProjectsPage.createManifestFile is now always called from ConvertedProjectsPage.convertProject, instead of only when the manifest file does not exist.

createManifestFile now checks if a Bundle-SymbolicName exists, a Bundle-Name exists, and a Bundle-Version exists. If they all exist, then there is no need to go through the rest of the Manifest creation since the existing Manifest is valid. If any (or all) of the information is missing, then createManifestFile performs the same behaviour as before, because the Manifest file is not valid or does not exist.
Comment 4 Wassim Melhem CLA 2007-05-09 01:16:40 EDT
Noam, it would also be good to ensure 'model' and 'model.getPluginBase().getId()' are not equal to null in BuildPluginAction. 
Comment 5 Noam Chitayat CLA 2007-05-09 11:29:25 EDT
Created attachment 66493 [details]
Revised patch for bug 185254. (Affects BuildPluginAction.java, ConvertedProjectsPage.java, pderesources.properties, PDEUIMessages.java)

If a user creates a MANIFEST.MF file for a Java project, there is not yet enough information to create a build script. If a user attempts to do so before converting the project, the script is not built and a proper error message is shown to the user.
Comment 6 Brian Bauman CLA 2007-05-09 12:21:36 EDT
Patch looked really good.  

Released with slight modification.  I am glad you found the two methods (IBundle/IPlugin) to access a Manifest's id, name, and version.  To keep everything simple, I modified the IPlugin.setId(), .setVersion(), .setName() to IBundle.setHeader.() to use one method set get/set the information.

Thanks Noam
Comment 7 Wassim Melhem CLA 2007-05-18 10:33:09 EDT
*** Bug 187816 has been marked as a duplicate of this bug. ***