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

Bug 345667

Summary: NPE when creating a servlet if created in a source folder with java build path exclusion patters
Product: [WebTools] WTP Java EE Tools Reporter: Roberto Sanchez Herrera <shr31223>
Component: jst.servletAssignee: Roberto Sanchez Herrera <shr31223>
Status: RESOLVED FIXED QA Contact: Chuck Bridgham <cbridgha>
Severity: normal    
Priority: P3 CC: ccc
Version: 3.2.3Flags: cbridgha: review+
Target Milestone: 3.2.4 P   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 347193    
Attachments:
Description Flags
Proposed patch none

Description Roberto Sanchez Herrera CLA 2011-05-12 16:43:05 EDT
When creating a servlet in a dynamic web project, you will see the following NPE if the source folder selected in the wizard has java build path exclusion patterns that causes the servlet to not be included in the build path. 

!ENTRY org.eclipse.jst.servlet.ui 4 0 2011-05-12 15:22:44.796
!MESSAGE null
!STACK 0
java.lang.NullPointerException
        at org.eclipse.jst.servlet.ui.internal.wizard.NewWebArtifactWizard.openJavaClass(NewWebArtifactWizard.java:79)
        at org.eclipse.jst.servlet.ui.internal.wizard.AddServletWizard.postPerformFinish(AddServletWizard.java:79)
        at org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard.performFinish(DataModelWizard.java:201)
        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:2640)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
        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:48)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:600)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1384)

Steps to recreate:

1. Create a dynamic web project.
2. Add a second source folder
3. Go to the Properties -> Java build path -> Source page of the project.
4. Add the exclusion pattern ** to the source folder you created in step 2
5. Open the New servlet wizard
6. Select the source folder you created in step 2
7. Finish the wizard. The NPE is logged, and the servlet class is not opened.
Comment 1 Roberto Sanchez Herrera CLA 2011-05-13 14:05:15 EDT
Created attachment 195615 [details]
Proposed patch
Comment 2 Chuck Bridgham CLA 2011-05-17 11:30:45 EDT
approved - this was a scenario we hit testing with 3rd party plugins affecting the "filtered" settings of source folders.
Comment 3 Carl Anderson CLA 2011-05-17 13:12:30 EDT
Committed to R3_2_4_patches