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

Bug 312678

Summary: ClasspathContainerVirtualComponent throws NPE on workspace restart
Product: [WebTools] WTP Common Tools Reporter: Carl Anderson <ccc>
Component: wst.commonAssignee: Rob Stryker <stryker>
Status: RESOLVED DUPLICATE QA Contact: Carl Anderson <ccc>
Severity: normal    
Priority: P3 CC: jasonpet, stryker
Version: 3.2   
Target Milestone: Future   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 311932    
Bug Blocks:    
Attachments:
Description Flags
My final patch for bug 311932 none

Description Carl Anderson CLA 2010-05-12 14:03:29 EDT
This clone is created to handle post-3.2 work to address this issue.

Things to consider:

If ClasspathContainerVirtualComponent instances are not short-lived, then we should re-get the container every time, and then worry about its classpath entries.  (According to Jason Sholl, a container's entries are computed once and cached.  If there is twiddling done on the component, JDT will create a new container instance for that project.)

JDT JavaDoc for IClasspathContainer.getClasspathEntries() states:

* This method must not be called by other clients.

However, we are calling it (and since we are not JDT, perhaps we are messing something up).

+++ This bug was initially created as a clone of Bug #311932 +++

Created an attachment (id=167342)
patch

An adopter ran into a scenario where they had added the EAR library to an EAR project as a Classpath Container reference from the Deployment Assembly editor.  Everything appeared OK until they restarted the workspace and got the following npe thrown to the log (close/reopen will also trigger the npe):


java.lang.NullPointerException at org.eclipse.jst.common.internal.modulecore.ClasspathContainerVirtualComponent.<init>(ClasspathContainerVirtualComponent.java:48) at org.eclipse.jst.common.internal.modulecore.ClasspathContainerReferenceResolver.resolve(ClasspathContainerReferenceResolver.java:43)
.
.

The fix is to simply and safely check for null to avoid the npe from being thrown.
Comment 1 Carl Anderson CLA 2010-05-12 14:05:26 EDT
Created attachment 168217 [details]
My final patch for bug 311932

I am attaching my final patch for bug 311932 to keep track of what we were thinking of doing.  If something gets approved for 311932 during WTP 3.2's shutdown, this patch will not apply cleanly.
Comment 2 Rob Stryker CLA 2010-10-12 02:46:32 EDT
Hey Carl:

Any idea on the result of the previous discussions? I know we agreed we weren't supposed to be using this JDT API at all, but we also now realize it expires if the container is changed at all and that we should update our list of jars.

Am I right?
Comment 3 Rob Stryker CLA 2010-11-08 04:33:17 EST
Seems Jason fixed this in bug 311932. Seems the NPE was removed

*** This bug has been marked as a duplicate of bug 311932 ***