Bug 19504 - NPE on startup caused by duplicate attribute in a feature.xml file in workspace
Summary: NPE on startup caused by duplicate attribute in a feature.xml file in workspace
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC All
: P1 critical (vote)
Target Milestone: 2.0 F3   Edit
Assignee: Dejan Glozic CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-06 11:41 EDT by Jim des Rivieres CLA
Modified: 2002-06-06 15:51 EDT (History)
0 users

See Also:


Attachments
log showing repeated and rippling failures (66.74 KB, text/plain)
2002-06-06 11:42 EDT, Jim des Rivieres CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jim des Rivieres CLA 2002-06-06 11:41:41 EDT
F2

I'm seeing an NPE on startup caused by duplicate attribute in a feature.xml 
file *in the workspace*. The feature.xml was built by hand, and
is in a project that is not marked as belonging to PDE (CVS project 
org.eclipse.platform.aix.motif-feature in dev.eclipse.org).

The feature.xml had:
<feature
      id="org.eclipse.platform.aix.motif"
      label="%featureName"
      version="2.0.0"
      image= "eclipse32.gif"
      provider-name="%providerName"
      os="aix"
      ws="motif"
      image= "eclipse32.gif">

The log is attached.

The NPE result in the pde.core and pde.ui plug-ins being deactivated.
Then all hell breaks loose from the user's point of view.
Comment 1 Jim des Rivieres CLA 2002-06-06 11:42:59 EDT
Created attachment 1293 [details]
log showing repeated and rippling failures
Comment 2 Dejan Glozic CLA 2002-06-06 12:25:35 EDT
Are you sure this is caused by the duplicate attribute? The NPE is related to 
the included feature (when PDE cannot find it in the workspace).
Comment 3 Dejan Glozic CLA 2002-06-06 12:51:55 EDT
Actually, that is exactly the problem. Here is the sequence of events:

1) You had a child feature with an error (duplicate attribute).
2) You didn't create the feature project with PDE so you didn't have feature 
nature.
3) As a result of that, you didn't have feature builder to create an error
marker for the syntax error.
4) You probably left the parent feature editor open. 
5) When loading the model, it tried to connect to the child feature model. 
6) Becuase child feature model failed to load due to errors, its 'feature'
root element was null.
7) PDE called 'getId' on a null object. BOOM.

I fixed the 'null' call to avoid the cascade failures. In your own interest,
you should consider adding the PDE nature and builder to the '.project' file
of the feature. It isn't hard: create one dummy feature project using PDE
and inspect the content of the .project file. You will see the entries for
the nature and builder. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>com.example.child</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.pde.FeatureBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.eclipse.pde.FeatureNature</nature>
	</natures>
</projectDescription>

You need to add 'buildCommand' an 'nature' elements.
Comment 4 Jim des Rivieres CLA 2002-06-06 15:47:39 EDT
It does not make sense to me to add the Java nature to feature
projects in general (they contain no Java code whatsoever.) Can the
feature nature be added by itself?
Comment 5 Dejan Glozic CLA 2002-06-06 15:51:22 EDT
Actually, it does make sense because features may contain install handlers 
which are written in Java. In addition, having a Java nature makes the project 
visible in the Packages view.