Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331608 - NPE on creation of a ChildModuleReference
Summary: NPE on creation of a ChildModuleReference
Status: RESOLVED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Rob Stryker CLA
QA Contact: Carl Anderson CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-01 15:53 EST by Jason Peterson CLA
Modified: 2013-04-18 13:43 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Peterson CLA 2010-12-01 15:53:21 EST
An adopter product is seeing the NPE shown below.  Looks like this is due to a null archive name for the IVirtualReference.

public ChildModuleReference(IVirtualReference reference, IPath root) {
.
.
.
root.append(reference.getRuntimePath()).append(reference.getArchiveName());
}



java.lang.NullPointerException
      	at org.eclipse.core.runtime.Path.append(Unknown Source)
      	at org.eclipse.wst.common.componentcore.internal.flat.ChildModuleReference.<init>(Unknown Source)
      	at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.addUsedReferences(Unknown Source)
      	at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.treeWalk(Unknown Source)
      	at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(Unknown Source)
      	at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.fetchResources(Unknown Source)
      	at org.eclipse.jst.j2ee.internal.archive.operations.FlatComponentArchiver.saveArchive(Unknown Source)
Comment 1 Carl Anderson CLA 2010-12-01 21:24:50 EST
Assigning to Rob for initial investigation.  I see that other places in our code guard against a null archive name, but I am not sure if just a simple null check is the correct thing to do in this scenario.
Comment 2 Carl Anderson CLA 2010-12-02 00:24:24 EST
In tonight's J2EE JUnit bucket run, I noticed that 

testMembersDeployment

failed with exactly this problem.
Comment 3 Rob Stryker CLA 2010-12-02 22:54:48 EST
A Nullcheck here probably would not be appropriate. There are two types of references, USED references and CONSUMED references.

In an example where EarProject has a USES reference for WebProject, the web project's resources are published as:
   Blah.ear/WebProject.war/each/war/resource

In an example where EarProject has a CONSUMES reference for WebProject, the behaviour is:
   Blah.ear/each/war/resource

So as you can see, for all USES references, an archive name is a mandatory attribute. It'd be interesting to see why this unit test is failing, or why this particular reference has no archive name.
Comment 4 Rob Stryker CLA 2011-01-20 15:35:29 EST
Retargeting, but, just wanted to say that, all USED references should have a non-null getName(). USED references require a name because their deploy path relative to the parent is parent.append(ref.moduleRelative).append(ref.getname()). This is by previous behaviour and the standardizations that came in with the addition of the Deployment Assembly page.

Any time a USED reference has a null name, this is a bug and the causes of a null-named USED reference should be found, not guarded against.
Comment 5 Chuck Bridgham CLA 2011-06-09 09:51:53 EDT
Moving to 3.3.1
Comment 6 Rob Stryker CLA 2012-01-26 14:04:48 EST
Jason:

Were you able to verify this situation with your adopter product? Perhaps they were having an issue in that the name was null when it should not have been?
Comment 7 Chuck Bridgham CLA 2012-05-31 13:31:47 EDT
Moving to 3.4.1
Comment 8 Rob Stryker CLA 2013-02-01 02:41:02 EST
I'm wondering if this is still an issue?   component.xml files should not have references without explicitly setting an archiveName. Since this bug was from 2010, that may have been before such a requirement was made explicit...
Comment 9 Carl Anderson CLA 2013-04-18 13:43:51 EDT
Closing this.  If the scenario can be reproduced, please reopen.