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

Bug 319935

Summary: Null Pointer Exception when Importing UtilityJar
Product: [WebTools] WTP Java EE Tools Reporter: Scott Huff <shuff>
Component: jst.j2eeAssignee: Scott Huff <shuff>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: ccc, david_williams, jsholl, neil.hauge
Version: 3.2Flags: david_williams: pmc_approved+
cbridgha: pmc_approved? (raghunathan.srinivasan)
cbridgha: pmc_approved? (naci.dai)
cbridgha: pmc_approved? (deboer)
neil.hauge: pmc_approved+
cbridgha: pmc_approved? (kaloyan)
cbridgha: review+
ccc: review+
Target Milestone: 3.2.1   
Hardware: PC   
OS: Windows XP   
Whiteboard: PMC_approved
Attachments:
Description Flags
Patch file alters J2EEUtilityJarListImportDataModelProvider.java
none
replacement patch none

Description Scott Huff CLA 2010-07-14 20:32:41 EDT
Created attachment 174364 [details]
Patch file alters J2EEUtilityJarListImportDataModelProvider.java

Patch resolves the error by checking user entered path text with the same validation that is checked when the wizard is finished at entry and returning exceptions when they occur.

Bug traced to not checking the path validation before the user finishes the wizard.

Steps to reproduce Bug:

1.- Create  an EAR project 
2.- Import an Utility jar to this project using contex menu: Import > Java EE Utility JAR, Select the import type as: "Create Java projects from utility JARs", check the "Override project root" option, leave the default location. Next.
3.- Browse for the JAR directory, select the JAR file, and Finish.

At this point the following exception is throw:
Comment 1 Chuck Bridgham CLA 2010-07-14 23:16:48 EDT
Scott can you explain in this snippet why we notify in different order(before, then after property set) for each branch?

if(model.getBooleanProperty(OVERRIDE_PROJECT_ROOT)){
				model.notifyPropertyChange(PROJECT_ROOT, IDataModel.VALUE_CHG);
				model.setProperty(PROJECT_ROOT, lastUserPath);
			}else{
				lastUserPath = model.getStringProperty(PROJECT_ROOT);
				model.setProperty(PROJECT_ROOT, getDefaultProperty(PROJECT_ROOT));
				model.notifyPropertyChange(PROJECT_ROOT, IDataModel.VALUE_CHG);
			}
Comment 2 Chuck Bridgham CLA 2010-07-15 10:26:36 EDT
Created attachment 174400 [details]
replacement patch

Same patch, but making sure we notify after setting property
Comment 3 Chuck Bridgham CLA 2010-07-15 10:26:50 EDT
Approve
Comment 4 Chuck Bridgham CLA 2010-07-15 10:40:45 EDT
Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug"
(requested by an adopter) please document it as such.

Exceptions thrown invalid path entered - no validation is done prior to operation running

Is there a work-around? If so, why do you believe the work-around is
insufficient?

No - exception will be thrown

How has the fix been tested? 

scenario testing


Give a brief technical overview. Who has reviewed this fix?

The case where this is failing.. a bad path is entered in the "override project root" field.  The validation was not done after setting the property - notification wasn't done to activate validation

Carl and myself reviewed the patch


What is the risk associated with this fix?

Low risk - validation now runs on settings
Comment 5 Carl Anderson CLA 2010-07-15 10:49:17 EDT
I approve of this fix.
Comment 6 Carl Anderson CLA 2010-07-15 11:54:04 EDT
Committed to HEAD for WTP 3.2.1 and WTP 3.3

Please note that the changes for bug 319918 were also (erroneously) committed with the comment for this bug- if you are looking for the bug related to changes to FlatComponentDeployable or J2EEFlexProjDeployable.java, please see bug 319918