7 Replies Latest reply on Jan 23, 2007 12:58 AM by 807581

    An XJC compilation error - Could not load class (..) for type cvsversion

    807581
      I've got a strange compilation error using NetBeans 4.0 (I'd guess the version does not matter here) and Ant 1.6.2. When the following task is executed,

      <target name="compile_ofx_schema">

      <antcall target="clean-ofx"/>

      <delete dir="${ofx-jaxb-src.dir}"/>
      <mkdir dir="${ofx-jaxb-src.dir}" />
      <xjc schema="${schema.dir}/ofx102.xsd" package="com.xxx.ofx102" target="${ofx-jaxb-src.dir}">
      <arg value="-nv" />
      <arg value="-extension" />
      </xjc>
      </target>

      I get the error from NetBeans console,

      ...
      Class org.xml.sax.SAXException loaded from parent loader (parentFirst)
      Class java.io.IOException loaded from parent loader (parentFirst)
      D:\appserver\build.xml:797: unable to parse the schema. Error messages should have been provided

      at com.sun.tools.xjc.XJCTask._doXJC(XJCTask.java:334)

      at com.sun.tools.xjc.XJCTask.doXJC(XJCTask.java:283)

      at com.sun.tools.xjc.XJCTask.execute(XJCTask.java:227)

      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

      at org.apache.tools.ant.Task.perform(Task.java:364)

      at org.apache.tools.ant.Target.execute(Target.java:341)

      at org.apache.tools.ant.Target.performTasks(Target.java:369)

      at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

      at org.apache.tools.ant.Project.executeTargets(Project.java:1062)

      at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:217)

      at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:236)

      at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)

      BUILD FAILED (total time: 4 seconds)
      Could not load class (org.apache.tools.ant.tasksdefs.cvslib.CvsVersion) for type cvsversion
      Could not load class (org.apache.tools.ant.tasksdefs.cvslib.CvsVersion) for type cvsversion

      And when I run the Ant task from the command line, I don't get the error at all.

      Any help is greatly appreciated.
        • 1. Re: An XJC compilation error - Could not load class (..) for type cvsversio
          807581
          Please refer to:
          http://forum.java.sun.com/thread.jspa?forumID=747&threadID=5056961


          Looks like this is an ant bug.

          A bug has been filed against ant1.6.2:
          http://issues.apache.org/bugzilla/show_bug.cgi?id=31403

          - The bug report says the fix is available in the next version. You can try downloading a later 1.6.x (x > 2)version and use it in the ide. (You will need to replace <idedir>/ant/lib/ant.jar).

          - Alternatively you can:
          - unjar <bowdir>/ant/lib/ant.jar
          - edit org/apache/tools/ant/taskdefs/defaults.properties
          change the line cvsversion=org.apache.tools.ant.tasksdefs.cvslib.CvsVersion
          by changing tasksdefs to taskdef
          - jar the files back and put the new ant.jar in <bowdir>/ant/lib.


          Does that help?

          Also, as you mentioned, the ide version should not matter; but still you may want to upgrade to the latest NetBeans 5.5, since it has a lot many features.
          • 2. Re: An XJC compilation error - Could not load class (..) for type cvsversio
            807581
            That was a great finding from you. Thank you.

            I followed your alternative approach and updated the ant.jar file. The "Could not load class..." error went away but the stack trace still remains. Now I am clueless again since I have ant on the debug mode and can't find any more useful info.

            Class com.sun.tools.xjc.reader.internalizer.LocatorTable loaded from ant loader (parentFirst)
            Class java.util.HashSet loaded from parent loader (parentFirst)
            Class javax.xml.parsers.DocumentBuilderFactory loaded from parent loader (parentFirst)
            Couldn't load Resource org/netbeans/core/xml/DOMFactoryImpl.class
            Couldn't load ResourceStream for META-INF/services/javax.xml.parsers.DocumentBuilderFactory
            Class org.apache.crimson.jaxp.DocumentBuilderFactoryImpl loaded from parent loader (parentFirst)
            Class javax.xml.parsers.SAXParserFactory loaded from parent loader (parentFirst)
            Couldn't load Resource org/netbeans/core/xml/SAXFactoryImpl.class
            Couldn't load ResourceStream for META-INF/services/javax.xml.parsers.SAXParserFactory
            Class org.apache.crimson.jaxp.SAXParserFactoryImpl loaded from parent loader (parentFirst)
            Class javax.xml.parsers.DocumentBuilder loaded from parent loader (parentFirst)
            Class java.util.Map loaded from parent loader (parentFirst)
            Class javax.xml.parsers.SAXParser loaded from parent loader (parentFirst)
            Finding class com.sun.tools.xjc.reader.xmlschema.parser.XMLSchemaInternalizationLogic$ReferenceFinder
            Loaded from D:\bbw\build\Common_3.6\Packaged\appserver\lib\jaxb\jaxb-xjc.jar com/sun/tools/xjc/reader/xmlschema/parser/XMLSchemaInternalizationLogic$ReferenceFinder.class
            Finding class com.sun.tools.xjc.reader.internalizer.AbstractReferenceFinderImpl
            Loaded from D:\bbw\build\Common_3.6\Packaged\appserver\lib\jaxb\jaxb-xjc.jar com/sun/tools/xjc/reader/internalizer/AbstractReferenceFinderImpl.class
            Class org.xml.sax.helpers.XMLFilterImpl loaded from parent loader (parentFirst)
            Class com.sun.tools.xjc.reader.internalizer.AbstractReferenceFinderImpl loaded from ant loader (parentFirst)
            Class com.sun.tools.xjc.reader.xmlschema.parser.XMLSchemaInternalizationLogic$ReferenceFinder loaded from ant loader (parentFirst)
            Class org.xml.sax.XMLFilter loaded from parent loader (parentFirst)
            Finding class com.sun.tools.xjc.reader.internalizer.VersionChecker
            Loaded from D:\bbw\build\Common_3.6\Packaged\appserver\lib\jaxb\jaxb-xjc.jar com/sun/tools/xjc/reader/internalizer/VersionChecker.class
            Class com.sun.tools.xjc.reader.internalizer.VersionChecker loaded from ant loader (parentFirst)
            Finding class com.sun.tools.xjc.reader.internalizer.DOMBuilder
            Loaded from D:\bbw\build\Common_3.6\Packaged\appserver\lib\jaxb\jaxb-xjc.jar com/sun/tools/xjc/reader/internalizer/DOMBuilder.class
            Finding class com.sun.xml.bind.marshaller.SAX2DOMEx
            Loaded from D:\bbw\build\Common_3.6\Packaged\appserver\lib\jaxb\jaxb-impl.jar com/sun/xml/bind/marshaller/SAX2DOMEx.class
            Class org.xml.sax.ContentHandler loaded from parent loader (parentFirst)
            Class com.sun.xml.bind.marshaller.SAX2DOMEx loaded from ant loader (parentFirst)
            Class com.sun.tools.xjc.reader.internalizer.DOMBuilder loaded from ant loader (parentFirst)
            Class java.util.Stack loaded from parent loader (parentFirst)
            Class org.w3c.dom.Document loaded from parent loader (parentFirst)
            Class org.xml.sax.XMLReader loaded from parent loader (parentFirst)
            Class org.w3c.dom.Node loaded from parent loader (parentFirst)
            Class org.w3c.dom.Element loaded from parent loader (parentFirst)
            Class javax.xml.parsers.ParserConfigurationException loaded from parent loader (parentFirst)
            Class org.xml.sax.SAXException loaded from parent loader (parentFirst)
            Class java.io.IOException loaded from parent loader (parentFirst)
            D:\bbw\build\Common_3.6\Packaged\appserver\build.xml:799: unable to parse the schema. Error messages should have been provided

            at com.sun.tools.xjc.XJCTask._doXJC(XJCTask.java:334)

            at com.sun.tools.xjc.XJCTask.doXJC(XJCTask.java:283)

            at com.sun.tools.xjc.XJCTask.execute(XJCTask.java:227)

            at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)

            at org.apache.tools.ant.Task.perform(Task.java:364)

            at org.apache.tools.ant.Target.execute(Target.java:341)

            at org.apache.tools.ant.Target.performTasks(Target.java:369)

            at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

            at org.apache.tools.ant.Project.executeTargets(Project.java:1062)

            at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:217)

            at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:236)

            at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)

            BUILD FAILED (total time: 1 second)

            Any suggestions? BTW, I did not upgrade NetBeans to v5.5 due that my code is still JDK1.4 based.
            • 3. Re: An XJC compilation error - Could not load class (..) for type cvsversio
              807581
              I think this error most likely indicates a version incompatibility with the xml parser that is being used. The trouble is usually with xerces or xalan; if there are different versions of these libraries in the system being used by the different entities (appserver, ide, ant and system classpath itself), then this problem could arise. Sometimes removing the xml parser from the jdk's endorsed directory may help....
              • 4. Re: An XJC compilation error - Could not load class (..) for type cvsversio
                807581
                xml parser version incompatibility is a hard problem to debug and diagnose.

                by the way, from the error message it seems that classes needed for xjc are being loaded from D:\bbw\build\Common_3.6\Packaged\appserver\lib\jaxb\jaxb-xjc.jar by ant; is it because this jar is in the classpath prior to ant's jar itself? Can you temporarily rename the one in appserver/lib to some other name and see what the behaviour is?
                • 5. Re: An XJC compilation error - Could not load class (..) for type cvsversio
                  807581
                  I renamed the lib but IDE Ant picked it up anyway. So I moved the .jar to the temp dir. And I got the following as I suspected,

                  fileset: Setup scanner in dir E:\MIBS\build\Common_3.6\Packaged\appserver\lib\jaxb with patternSet{ includes: [*.jar] excludes: [] }
                  fileset: Setup scanner in dir E:\MIBS\build\Common_3.6\Packaged\appserver\lib with patternSet{ includes: [${jaxpapi.jar}] excludes: [] }
                  Finding class com.sun.tools.xjc.XJCTask

                  BUILD FAILED
                  E:\MIBS\build\flypaper\build.xml:771: taskdef class com.sun.tools.xjc.XJCTask cannot be found
                  at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:483)
                  at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:183)
                  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
                  at org.apache.tools.ant.Task.perform(Task.java:364)
                  at org.apache.tools.ant.Target.execute(Target.java:341)
                  at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
                  at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(Interna lAntRunner.java:191)
                  at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner. java:400)
                  at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner .java:137)
                  Caused by: java.lang.ClassNotFoundException: com.sun.tools.xjc.XJCTask
                  at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1 166)
                  at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1107)
                  at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:977)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
                  at java.lang.Class.forName0(Native Method)
                  at java.lang.Class.forName(Class.java:219)
                  at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:457)
                  ... 8 more

                  I could not find a .jar file in the Ant package that defines this task though. And in the MANIFEST.MF file I saw this,

                  Manifest-Version: 1.0
                  Sealed: true
                  Implementation-Version: 1.0.2
                  Specification-Title: Java Architecture for XML Binding
                  Specification-Version: 1.0
                  Ant-Version: Apache Ant 1.5.2
                  Implementation-Title: JAXB Reference Implementation
                  Main-Class: com.sun.tools.xjc.Driver
                  Extension-Name: com.sun.tools.xjc
                  Created-By: 1.4.1_02-b06 (Sun Microsystems Inc.)
                  Class-Path: jaxb-api.jar jaxb-impl.jar jaxb-libs.jar ../../jaxp/lib/en
                  dorsed/sax.jar ../../jaxp/lib/endorsed/dom.jar ../../jaxp/lib/jaxp-ap
                  i.jar ../../jaxp/lib/endorsed/xercesImpl.jar ../../jaxp/lib/endorsed/
                  xalan.jar ../../jwsdp-shared/lib/jax-qname.jar ../../jwsdp-shared/lib
                  /namespace.jar ../../jwsdp-shared/lib/xsdlib.jar ../../jwsdp-shared/l
                  ib/relaxngDatatype.jar
                  Implementation-Vendor-Id: com.sun
                  Implementation-Vendor: Sun Microsystems, Inc.
                  Specification-Vendor: Sun Microsystems, Inc.

                  Not sure if there is any incompatibility between Ant 1.5.2 and 1.6.5 (that comes with NetBeans). Note that I upgraded my NetBeans to 5.0.

                  You're right. Debugging this kind of errors really pulled my hair out for the last few days (thankfully I still have a command line build to fall back on). (BTW, I tried and got exactly the same error on Eclipse 3.2.1). Therefore I truly appreciate your willingness to help me dig into it.
                  • 6. Re: An XJC compilation error - Could not load class (..) for type cvsversio
                    807581
                    I had a break through last night. Apparently I've been using Ant 1.7.0 on command line compilation but 1.6.5 with NetBeans/Eclipse. I did not think this was a factor. But when I switched Ant from 1.6.5 to 1.7.0 in Eclipse, the compilation went through successfully. I still have no idea what the subtlety is though, unfortunately.

                    I also changed the Ant version in NetBeans. Everything started working. I guess I'll move on since I've spent enough time on this hair-splitting issue. Thanks again for your help.
                    • 7. Re: An XJC compilation error - Could not load class (..) for type cvsversio
                      807581
                      Glad to note that your problem is resolved.
                      I renamed the lib but IDE Ant picked it up anyway...
                      That is really strange. In any case, i do agree with you that it is probably not worth spending time to figure out the subtlety.