Menu

#3 SAX error running ANT example

v1.0 (example)
open
Ant (1)
5
2014-08-09
2008-01-17
No

em001864@dlktzt79 ~/pd_src/SimpleJavaApp $ ant -f ant-build-codecover.xml
Buildfile: ant-build-codecover.xml

clean:
[delete] Deleting: /data/home/em001864/pd_src/SimpleJavaApp/codecover.xml

instrument-sources:
[INFO] Instrumentation:
[INFO] root-directory: /data/home/em001864/pd_src/SimpleJavaApp/src
[INFO] destination: /data/home/em001864/pd_src/SimpleJavaApp/instrumented
[INFO] language: java
[INFO] instrumenter key: CodeCover_Java_1.5
[INFO] instrumenter for: Java 1.5
[INFO] An instrumenter for Java 1.5.
Source files have to have the extension ".java"
This instrumenter is part of the release of CodeCover. It supports Statement, Branch, Condition and Loop Coverage. Long arrays are used to keep the counters.
Attention: for Java 1.4 compatibility use the instrumenter directive "-D Java1.4=true".
by: Christoph Mueller
instrumenter version: 1.0
[INFO] using all criteria
[INFO] charset: utf-8
[INFO] copy uninstrumented files: yes
[INFO] The following directives have been set:
[INFO] > Java1.4 = false (Boolean)
[INFO] > UUID = 68c1a63c-3ded-4786-9ee0-a7b0defdff93 (String)
[INFO] 7 files selected for instrumentation.
[INFO] Instrumentation starting...
[INFO] Additional classes added to:
/data/home/em001864/pd_src/SimpleJavaApp/instrumented
[INFO] Instrumentation finished.
[INFO] 0 files will be copied
[INFO] Saving /data/home/em001864/pd_src/SimpleJavaApp/codecover.xml
[INFO] Successfully saved /data/home/em001864/pd_src/SimpleJavaApp/codecover.xml

compile-instrumented:
[javac] Compiling 26 source files to /data/home/em001864/pd_src/SimpleJavaApp/instrumented
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

run-instrumented:

create-report:
[INFO] Loading /data/home/em001864/pd_src/SimpleJavaApp/codecover.xml
[ERROR] A SAX error occurred: cvc-complex-type.3.2.2: Attribute 'Date' is not allowed to appear in element 'TestSessionContainer'.

BUILD FAILED
/data/home/em001864/pd_src/SimpleJavaApp/ant-build-codecover.xml:53: A FileLoadParseException has occurred

Total time: 32 seconds

Discussion

  • Eduard Martinescu

    codecover.xml and test.clf

     
  • Johannes Langauf

    • assigned_to: nobody --> wittlinger
     
  • Johannes Langauf

    Logged In: YES
    user_id=1963600
    Originator: NO

    Markus: AFK you wrote the routines for XML-IO. Got any Idea, what's going wrong and how to fix it?

     
  • Markus Wittlinger

    Logged In: YES
    user_id=1960045
    Originator: NO

    Yes I wrote the XML-IO. And the error seems to be caused by the parser during the validation of the xml file. But I'm puzzled by the error message, since 'Date' is very much allowed to appear in the 'TestSessionContainer' element.

    I tried to reproduce the error, both with the uploaded file and with a new ant execution. But in neither case did I get the same error.

    Eduard Martinescu: Could you maybe post your 'ant-build-codecover.xml' file, so I could try to reproduce the error with it? And can you reproduce the error?

     
  • Ron

    Ron - 2008-05-29

    Logged In: YES
    user_id=1333548
    Originator: NO

    I also have this bug when trying to generate a report.

    Java 1.6.0
    Ant 1.7.0

    In SaxFileReader I tried to set the parser to nonvalidating this way: factory.setValidating(false); That does not solve the problem. I added the following line to produce a stacktrace:
    try {
    parser.parse(inputStream, readerBase);
    } catch (Exception e) {
    e.printStackTrace();
    }

    This produces the following stacktrace:

    [ERROR] A SAX error occurred: cvc-complex-type.3.2.2: Attribute 'Date' is not allowed to appear in element 'TestSessionContainer'.
    [codecover] org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'Date' is not allowed to appear in element 'TestSessionContainer'.
    [codecover] at org.codecover.model.XMLReaderBase.error(XMLReaderBase.java:64)
    [codecover] at org.apache.xerces.util.ErrorHandlerProxy.error(Unknown Source)
    [codecover] at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    [codecover] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    [codecover] at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    [codecover] at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:410)
    [codecover] at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3165)
    [codecover] at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processAttributes(XMLSchemaValidator.java:2630)
    [codecover] at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:2037)
    [codecover] at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:685)
    [codecover] at com.sun.org.apache.xerces.internal.jaxp.validation.ValidatorHandlerImpl.startElement(ValidatorHandlerImpl.java:549)
    [codecover] at org.apache.xerces.jaxp.JAXPValidatorComponent$XNI2SAX.startElement(Unknown Source)
    [codecover] at org.apache.xerces.jaxp.JAXPValidatorComponent.startElement(Unknown Source)
    [codecover] at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
    [codecover] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
    [codecover] at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
    [codecover] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    [codecover] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    [codecover] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    [codecover] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    [codecover] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    [codecover] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    [codecover] at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    [codecover] at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    [codecover] at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
    [codecover] at org.codecover.model.SAXFileReader.parse(SAXFileReader.java:80)
    [codecover] at org.codecover.model.TestSessionContainer.load(TestSessionContainer.java:238)
    [codecover] at org.codecover.model.TestSessionContainer.load(TestSessionContainer.java:219)
    [codecover] at org.codecover.ant.LoadCommand.run(LoadCommand.java:65)
    [codecover] at org.codecover.ant.CodecoverTask.execute(CodecoverTask.java:174)
    [codecover] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    [codecover] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [codecover] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [codecover] at java.lang.reflect.Method.invoke(Method.java:597)
    [codecover] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    [codecover] at org.apache.tools.ant.Task.perform(Task.java:348)
    [codecover] at org.apache.tools.ant.Target.execute(Target.java:357)
    [codecover] at org.apache.tools.ant.Target.performTasks(Target.java:385)
    [codecover] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
    [codecover] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
    [codecover] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [codecover] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
    [codecover] at org.apache.tools.ant.Main.runBuild(Main.java:698)
    [codecover] at org.apache.tools.ant.Main.startAnt(Main.java:199)
    [codecover] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
    [codecover] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

    Might this have something to do with ant using it's own SaxParserFactory ?

     
  • Johannes Langauf

    Logged In: YES
    user_id=1963600
    Originator: NO

    So you tried disabling validation in
    https://codecover.svn.sourceforge.net/svnroot/codecover/trunk/code/model/src/org/codecover/model/SAXFileReader.java yet it still tries to validate and fails?

    You could try checking in a debugger if you disabled validation for the parser-object that is used and possibly why it's ignoring your change.

    We haven't reproduced the problem yet.

     
  • striebhz

    striebhz - 2008-09-23

    I just want to add that this bug is definitely connected to Java 1.6. I got the same error just by upgrading from Java 1.5 to Java 1.6.

    Perhaps this information helps in reproducing the problem!?

     
  • Nobody/Anonymous

    I was able to fix/workaround the error by commenting out the lines 69-72 of org.codecover.model.SAXFileReader

    Is there a place to put the "fixed" jar file to?

     
  • Marco Aurélio Graciotto Silva

    Index: model/src/org/codecover/model/SAXFileReader.java

    --- model/src/org/codecover/model/SAXFileReader.java (revision 32)
    +++ model/src/org/codecover/model/SAXFileReader.java (working copy)
    @@ -55,17 +55,18 @@
    XMLReaderBase readerBase) throws ParserConfigurationException,
    SAXException, IOException {
    final SAXParserFactory factory = SAXParserFactory.newInstance();
    + factory.setNamespaceAware(true);

    final SchemaFactory schemaFactory = SchemaFactory
    .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

    final InputStream schemaInputStream = SAXFileReader.class
    .getResourceAsStream("resources/testSessionContainerSchema.xsd");
    -
    +
    if (schemaInputStream == null) {
    throw new RuntimeException("Cannot find schema resource");
    }
    -
    +
    final Schema schema = schemaFactory.newSchema(new SAXSource(
    new InputSource(schemaInputStream)));

    Index: model/src/org/codecover/model/resources/testSessionContainerSchema.xsd

    --- model/src/org/codecover/model/resources/testSessionContainerSchema.xsd (revision 32)
    +++ model/src/org/codecover/model/resources/testSessionContainerSchema.xsd (working copy)
    @@ -3,7 +3,7 @@
    <!--
    This schema can be used to validate the 1.0 test session container xml format.
    -->
    -<xsd:schema elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.codecover.org/xml/testsession-container" xmlns="http://www.codecover.org/xml/testsession-container" elementFormDefault="qualified">
    <xsd:element name="TestSessionContainer">
    <xsd:complexType>
    <xsd:choice maxOccurs="unbounded" minOccurs="0">
    Index: model/src/org/codecover/model/XMLReader1_0_SAX.java
    ===================================================================
    --- model/src/org/codecover/model/XMLReader1_0_SAX.java (revision 32)
    +++ model/src/org/codecover/model/XMLReader1_0_SAX.java (working copy)
    @@ -969,23 +969,11 @@
    * @param attributes
    */
    protected void handleStartElementTestSessionContainer(Attributes attributes) {
    - final String namespaceURI = attributes.getValue(NAMESPACE_IDENTIFIER);
    final String versionString = attributes.getValue(VERSION);
    final String containerId = attributes
    .getValue(TEST_SESSION_CONTAINER_ID);
    final Date date = new Date(Long.parseLong(attributes.getValue(DATE)));

    - if (namespaceURI == null) {
    - throw new IllegalArgumentException("Expected namespace "
    - + "Attribute, but found none.");
    - }
    -
    - if (!namespaceURI.equals(NAMESPACE_TEST_SESSION_CONTAINER)) {
    - throw new IllegalArgumentException("Expected namespace "
    - + NAMESPACE_TEST_SESSION_CONTAINER + ", got "
    - + namespaceURI);
    - }
    -
    if (versionString == null) {
    throw new IllegalArgumentException("No version information");
    }

     
  • Marco Aurélio Graciotto Silva

    Hum, the patch file got some formatting issues when posting here. How can I attach it as a file here? I couldn't find a way.

     
  • DeCosta

    DeCosta - 2009-10-16

    Interestingly, if I remove xercesImpl.jar from $ANT_HOME/lib the problem seems to go away. According to the manifest file in xercesImpl.jar, the jar file contains Xerces-J 2.8.1 and by looking at the Version files in rt.jar for both Java 1.5.0_11 and 1.6.0_12, I see Xerces-J 2.6.2

    Looks like the order in which the jars are being searched/loaded has changed?

     

Log in to post a comment.

MongoDB Logo MongoDB