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

Bug 326458

Summary: NPE when removing an EAR reference with no archiveName attribute defined
Product: [WebTools] WTP Java EE Tools Reporter: Aidyl Kareh <amkareh>
Component: jst.j2eeAssignee: Aidyl Kareh <amkareh>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: amkareh, ccc, jsholl
Version: unspecifiedFlags: cbridgha: review+
Target Milestone: 3.2.3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed Patch
none
Updated Patch none

Description Aidyl Kareh CLA 2010-09-28 16:03:38 EDT
Build Identifier: WTP 3.2.2

I got the following NPE when removing a project reference from the EAR using the 'Deployment Assembly' properties page. The archiveName attribute had been previously removed from the dependent-module element in the .component file. The RemoveComponentFromEnterpriseApplicationOperation.updateEARDD() method should not assume that the archiveName is not null.

java.lang.NullPointerException
	at org.eclipse.core.runtime.Path.<init>(Path.java:153)
	at org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationOperation$1.run(RemoveComponentFromEnterpriseApplicationOperation.java:102)
	at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.modify(JEE5ModelProvider.java:256)
	at org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationOperation.updateEARDD(RemoveComponentFromEnterpriseApplicationOperation.java:80)
	at org.eclipse.jst.j2ee.application.internal.operations.RemoveComponentFromEnterpriseApplicationOperation.execute(RemoveComponentFromEnterpriseApplicationOperation.java:52)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(DataModelPausibleOperationImpl.java:385)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:410)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(DataModelPausibleOperationImpl.java:360)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(DataModelPausibleOperationImpl.java:247)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(DataModelPausibleOperationImpl.java:219)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(DataModelPausibleOperationImpl.java:89)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(DataModelPausibleOperationImpl.java:207)
	at org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.removeOneReference(AddModuleDependenciesPropertiesPage.java:1075)
	at org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.removeReferences(AddModuleDependenciesPropertiesPage.java:1068)
	at org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage$3.run(AddModuleDependenciesPropertiesPage.java:1054)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1957)
	at org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.handleRemoved(AddModuleDependenciesPropertiesPage.java:1058)
	at org.eclipse.jst.j2ee.internal.ui.preferences.EarModuleDependenciesPropertyPage.handleRemoved(EarModuleDependenciesPropertyPage.java:132)
	at org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.saveReferenceChanges(AddModuleDependenciesPropertiesPage.java:1028)
	at org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.performOk(AddModuleDependenciesPropertiesPage.java:940)
	at org.eclipse.jst.j2ee.internal.ui.preferences.EarModuleDependenciesPropertyPage.performOk(EarModuleDependenciesPropertyPage.java:196)
	at org.eclipse.wst.common.componentcore.ui.propertypage.ModuleAssemblyRootPage.performOk(ModuleAssemblyRootPage.java:74)
	at org.eclipse.jface.preference.PreferenceDialog$13.run(PreferenceDialog.java:964)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.preference.PreferenceDialog.okPressed(PreferenceDialog.java:944)
	at org.eclipse.ui.internal.dialogs.FilteredPreferenceDialog.okPressed(FilteredPreferenceDialog.java:447)
	at org.eclipse.jface.preference.PreferenceDialog.buttonPressed(PreferenceDialog.java:233)
	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.dialogs.PropertyDialogAction.run(PropertyDialogAction.java:157)
	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(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:599)
	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)

Reproducible: Always
Comment 1 Aidyl Kareh CLA 2010-09-28 16:51:33 EDT
Created attachment 179789 [details]
Proposed Patch

Updated RemoveComponentFromEnterpriseApplicationOperation.updateEARDD() method so that it avoids using the dependentObject if it has no id set. Also added check to make sure the getArchiveName() method returned a non-null value before using it to get the matching module.
Comment 2 Chuck Bridgham CLA 2010-09-29 10:18:02 EDT
approved - please make sure we have junit coverage in this area
Comment 3 Aidyl Kareh CLA 2010-09-29 10:44:09 EDT
Created attachment 179854 [details]
Updated Patch

Patch has been updated to replace using the <String>.isEmpty() method, which
is Java 6 specific, with a Java 5 equivalent.
Comment 4 Jason Sholl CLA 2010-09-29 12:36:37 EDT
code checked into 32M and HEAD for WTP 3.2.3 and 3.3 respectively.