This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 143966 - project.xml validation errors with simple causes should be corrected
Summary: project.xml validation errors with simple causes should be corrected
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant Project (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords:
Depends on:
Blocks: 42686
  Show dependency tree
 
Reported: 2008-08-14 18:37 UTC by opensolutions
Modified: 2008-08-30 17:25 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
project.xml (1.97 KB, text/xml)
2008-08-14 18:38 UTC, opensolutions
Details

Note You need to log in before you can comment on or make changes to this bug.
Description opensolutions 2008-08-14 18:37:27 UTC
In the "Open Project" dialog, moving to the "Module Project" to open, i got this message in the "Project Name" field on
many of my "Platform Modules":

Error in project.xml: Invalid content was found starting with element 'class-path-extension'. One of
'{".../nb-module-project/3":module-dependencies}' is expected.

My project.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.apisupport.project</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
            <code-name-base>org.apache.derby</code-name-base>
            <suite-component/>
            <module-dependencies>
                <dependency>
                    <code-name-base>org.openide.modules</code-name-base>
                    <build-prerequisite/>
                    <compile-dependency/>
                    <run-dependency>
                        <specification-version>7.6</specification-version>
                    </run-dependency>
                </dependency>
                <dependency>
                    <code-name-base>org.openide.util</code-name-base>
                    <build-prerequisite/>
                    <compile-dependency/>
                    <run-dependency>
                        <specification-version>7.12.0.1</specification-version>
                    </run-dependency>
                </dependency>
            </module-dependencies>
            <class-path-extension>
                <runtime-relative-path>ext/derbyLocale_de_DE.jar</runtime-relative-path>
                <binary-origin>release/modules/ext/derbyLocale_de_DE.jar</binary-origin>
            </class-path-extension>
            <class-path-extension>
                <runtime-relative-path>ext/derby.jar</runtime-relative-path>
                <binary-origin>release/modules/ext/derby.jar</binary-origin>
            </class-path-extension>
            <class-path-extension>
                <runtime-relative-path>ext/derbyclient.jar</runtime-relative-path>
                <binary-origin>release/modules/ext/derbyclient.jar</binary-origin>
            </class-path-extension>
            <public-packages>
                <package>org.apache.derby.jdbc</package>
            </public-packages>
        </data>
    </configuration>
</project>

Opening this module is not possible and the icon before the module directory indicates a normal folder, not a project
folder.
Comment 1 opensolutions 2008-08-14 18:38:32 UTC
Created attachment 67451 [details]
project.xml
Comment 2 opensolutions 2008-08-14 18:42:01 UTC
sorry, in the module, including the project.xml atteched to thie issue, the error is:

Error in project.xml: Invalid content was found starting with element 'class-path-extension'. One of
'{".../nb-module-project/3":test-dependencies, ".../nb-module-project/3":public-packages,
".../nb-module-project/3":friend-packages}' is expected.
Comment 3 opensolutions 2008-08-14 18:47:48 UTC
the xml check from netbeans give me a long description of this error:

Referenced entity at "nbfs://nbhost/SystemFileSystem/ProjectXMLCatalog/project/1.xsd".
Referenced entity at "nbfs://nbhost/SystemFileSystem/ProjectXMLCatalog/nb-module-project/3.xsd".
cvc-complex-type.2.4.a: Invalid content was found starting with element 'class-path-extension'. One of
'{"http://www.netbeans.org/ns/nb-module-project/3":test-dependencies,
"http://www.netbeans.org/ns/nb-module-project/3":public-packages,
"http://www.netbeans.org/ns/nb-module-project/3":friend-packages}' is expected. [26] 
XML validation finished.

Comment 4 opensolutions 2008-08-14 18:56:49 UTC
ok, i got it. it was because of a wrong sequence of the xml elements.

<public-packages> has to be before <class-path-extension>

in netbeans 6.1 it was not relevant and my project.xml is generated from the platform itself.

here the corrected project.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.apisupport.project</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
            <code-name-base>org.apache.derby</code-name-base>
            <suite-component/>
            <module-dependencies>
                <dependency>
                    <code-name-base>org.openide.modules</code-name-base>
                    <build-prerequisite/>
                    <compile-dependency/>
                    <run-dependency>
                        <specification-version>7.6</specification-version>
                    </run-dependency>
                </dependency>
                <dependency>
                    <code-name-base>org.openide.util</code-name-base>
                    <build-prerequisite/>
                    <compile-dependency/>
                    <run-dependency>
                        <specification-version>7.12.0.1</specification-version>
                    </run-dependency>
                </dependency>
            </module-dependencies>
            <public-packages>
                <package>org.apache.derby.jdbc</package>
            </public-packages>
            <class-path-extension>
                <runtime-relative-path>ext/derbyLocale_de_DE.jar</runtime-relative-path>
                <binary-origin>release/modules/ext/derbyLocale_de_DE.jar</binary-origin>
            </class-path-extension>
            <class-path-extension>
                <runtime-relative-path>ext/derby.jar</runtime-relative-path>
                <binary-origin>release/modules/ext/derby.jar</binary-origin>
            </class-path-extension>
            <class-path-extension>
                <runtime-relative-path>ext/derbyclient.jar</runtime-relative-path>
                <binary-origin>release/modules/ext/derbyclient.jar</binary-origin>
            </class-path-extension>
        </data>
    </configuration>
</project>
Comment 5 rmichalsky 2008-08-19 08:21:50 UTC
XML schema validation issue. See issue #142079 for details
Comment 6 Jesse Glick 2008-08-21 00:52:48 UTC
I just tried the Library Wrapper Module wizard today with 6.1 and it generated a correct project.xml....?
Comment 7 opensolutions 2008-08-21 06:52:00 UTC
It is not at all projects. From my module suite with 13 modules, 2 have this problem (Both are library wapper). But
there are another 3 library wrapper without it. From other projects, the proportion is identical.
Comment 8 Jesse Glick 2008-08-22 02:32:12 UTC
Strange. Were all these lib wrapper modules created at the same time? Using NB 6.1?
Comment 9 opensolutions 2008-08-22 07:20:56 UTC
The defect modules are some of the oldest ones, created with nb6.1. I had no problems with newly created. i think, they
are build with the version of nb6.1. available on march 2008.
Comment 10 Jesse Glick 2008-08-23 16:45:28 UTC
It might be possible to internally resort the subelements of <data> before loading so as to make the document valid. I
would need to look into how difficult this would be to implement.
Comment 11 Jesse Glick 2008-08-28 22:19:50 UTC
Can do something about it.
Comment 12 Jesse Glick 2008-08-28 22:39:26 UTC
I have implemented a special phase during project open. If the project.xml is invalid, and one of the following
conditions holds:

1. Incrementing the /nnn namespace on <data> (and subelements) makes it valid. (E.g. NBM projects trying to use
<test-dependencies> in /2.)

2. The validation message says that an element is unexpected. This element can be found in <data> (as a direct child).
Shifting some later elements (starting after any run of other elements with the same unexpected name) to before the
unexpected element, keeping their relative order, makes it valid. For example, shifting <public-packages> above the
first <class-path-extension> in the example here.

then the project is loaded. If project.xml is writable, it is corrected immediately; or if some in-IDE customization
writes out a new document, it will be corrected then.

I hope that this will take care of most of the cases people have reported of validation errors. It is of course
impossible to correct every possible error so I have concentrated on the common cases.

It may be possible to retighten some schemas which were previously relaxed to permit out-of-order elements, if all the
known problematic documents would fall into case #2.

Related bugs:

issue #140300: <explicit-platform> in the wrong place; fixed IDE's writing code but maybe didn't help old projects
issue #140515: <explicit-platform> in the wrong place; schemas relaxed?
issue #142079: same problem as originally reported here; error messages improved
issue #142594: /2 vs. /3 for <test-dependencies>; can fix IDE's writing code but would not help old projects (hence #1
above)

core-main #5d3d4a15ac2c
Comment 13 David Konecny 2008-08-29 03:24:37 UTC
I've reverted changes done to workaround issue 140515 but now testing it it does not seem to work properly:

my schema says:
<xsd:sequence>
 <xsd:element name="name" type="xsd:token"/>
 <xsd:element name="minimum-ant-version" minOccurs="0"/>
 <xsd:element name="explicit-platform" minOccurs="0"/>
 <xsd:element name="use-manifest" minOccurs="0"/>
 <xsd:element name="included-library" type="libraryType" minOccurs="0" maxOccurs="unbounded"/> 
 <xsd:element name="web-services"  minOccurs="0" maxOccurs="1" type="webServicesType"/>
 <xsd:element name="web-service-clients" minOccurs="0" maxOccurs="1" type="webServiceClientsType"/>
 <xsd:element name="source-roots"/>
 <xsd:element name="test-roots"/>
</xsd:sequence>

my XML says (<explicit-platform> is in wrong order):
<name>EnterpriseApplication3-ejb</name>
<minimum-ant-version>1.6.5</minimum-ant-version>
<use-manifest/>
<explicit-platform explicit-source-supported="true" />
<source-roots>
    <root id="src.dir" name="Source Packages"/>
</source-roots>

and in console I get (and project is not opened):
Caused: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element
'explicit-platform'. One of '{"http://www.netbeans.org/ns/j2ee-ejbjarproject/3":included-library,
"http://www.netbeans.org/ns/j2ee-ejbjarproject/3":web-services,
"http://www.netbeans.org/ns/j2ee-ejbjarproject/3":web-service-clients,
"http://www.netbeans.org/ns/j2ee-ejbjarproject/3":source-roots}' is expected.

Is this supposed to work or not? (autocorrect() was called.)
Comment 14 Jesse Glick 2008-08-29 03:31:40 UTC
This will not currently work, because the use of minOccurs="0" means that the error is detected in <explicit-platform>,
whereas really <use-manifest/> is the first element out of order. I guess I will need to try shifting earlier elements
down as well as later elements up.
Comment 15 Jesse Glick 2008-08-29 22:11:37 UTC
OK, now taking the supposedly misplaced element (or sequence of similar elements), and trying to put it in every
position in the list, including the very front and the very end.

core-main #9e13cd601cf3
Comment 16 Quality Engineering 2008-08-30 05:37:53 UTC
Integrated into 'main-golden', available in build *200808300201* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/5d3d4a15ac2c
User: Jesse Glick <jglick@netbeans.org>
Log: #143966: accept (and correct) certain common validation errors in project.xml when opening projects.
Comment 17 Quality Engineering 2008-08-30 17:25:12 UTC
Integrated into 'main-golden', available in build *200808301401* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/9e13cd601cf3
User: Jesse Glick <jglick@netbeans.org>
Log: Improved algorithm for #143966 (project.xml autocorrection).