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

Bug 323658

Summary: NPE- modules variable not initialized when API called during automated scenario
Product: [WebTools] WTP ServerTools Reporter: Eric Peters <ericdp>
Component: wst.serverAssignee: Angel Vera <arvera>
Status: RESOLVED FIXED QA Contact: Angel Vera <arvera>
Severity: normal    
Priority: P3 CC: ccc, ivanc, keith.chong.ca
Version: 3.0.5   
Target Milestone: 3.0.5 P   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
v1.0 none

Description Eric Peters CLA 2010-08-25 17:13:25 EDT
Seems this is already fixed in 3.x, but for some reason we not backported to 305p. 

The reason for the NPE, is because the modules variable inside of the server object have not yet been initialized. They typically get initialized when someone calls server.getModules, I assume in this case noone has as it seems that mostly the .getModules is done for UI, or for the Publish action. I guess since this is a JUnit this probably hasn't happend. 

The 
change is to instead of doing:


		// no modules are deployed
		if (modules.isEmpty())

to do a: 
		// no modules are deployed
		if (getModules().length < 0)

Stacktrace below...


java.lang.NullPointerException
 at org.eclipse.wst.server.core.internal.Server.isModuleDeployed(Server.java:797)
 at org.eclipse.wst.server.core.internal.Server.handleModuleProjectChange(Server.java:768)
 at org.eclipse.wst.server.core.internal.ResourceManager.publishHandleProjectChange(ResourceManager.java:977)
 at org.eclipse.wst.server.core.internal.ResourceManager$ServerResourceChangeListener$1.visit(ResourceManager.java:122)
 at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:68)
 at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:79)
 at org.eclipse.core.internal.events.ResourceDelta.accept(ResourceDelta.java:48)
 at org.eclipse.wst.server.core.internal.ResourceManager$ServerResourceChangeListener.resourceChanged(ResourceManager.java:116)
 at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:288)
 at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
 at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:282)
 at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:148)
 at org.eclipse.core.internal.resources.Workspace.broadcastBuildEvent(Workspace.java:297)
 at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:333)
 at ...
...
 at junit.framework.TestCase.runBare(TestCase.java:128)
 at junit.framework.TestResult$1.protect(TestResult.java:106)
 at junit.framework.TestResult.runProtected(TestResult.java:124)
 at junit.framework.TestResult.run(TestResult.java:109)
 at junit.framework.TestCase.run(TestCase.java:120)
 at junit.framework.TestSuite.runTest(TestSuite.java:230)
 at junit.framework.TestSuite.run(TestSuite.java:225)
 at junit.framework.TestSuite.runTest(TestSuite.java:230)
 at junit.framework.TestSuite.run(TestSuite.java:225)
 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
 at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run(UITestApplication.java:114)
 at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
 at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133)
 at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3817)
 at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3442)
 at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2384)
 at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2348)
 at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2200)
 at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:495)
 at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
 at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:490)
 at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
 at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
 at org.eclipse.pde.internal.junit.runtime.UITestApplication.start(UITestApplication.java:46)
 at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
 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:386)
 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:25)
 at java.lang.reflect.Method.invoke(Method.java:600)
 at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
 at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
 at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Comment 1 Keith Chong CLA 2010-08-25 17:32:23 EDT
*** Bug 323660 has been marked as a duplicate of this bug. ***
Comment 2 Angel Vera CLA 2010-08-26 13:12:55 EDT
Created attachment 177541 [details]
v1.0
Comment 3 Carl Anderson CLA 2010-08-30 17:46:44 EDT
Committed to R3_0_5_patches