Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312678 - ClasspathContainerVirtualComponent throws NPE on workspace restart
Summary: ClasspathContainerVirtualComponent throws NPE on workspace restart
Status: RESOLVED DUPLICATE of bug 311932
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: Future   Edit
Assignee: Rob Stryker CLA
QA Contact: Carl Anderson CLA
URL:
Whiteboard:
Keywords:
Depends on: 311932
Blocks:
  Show dependency tree
 
Reported: 2010-05-12 14:03 EDT by Carl Anderson CLA
Modified: 2010-11-08 04:33 EST (History)
2 users (show)

See Also:


Attachments
My final patch for bug 311932 (2.51 KB, patch)
2010-05-12 14:05 EDT, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 ***