users@jaxb.java.net

Using Java, Ant and XJC

From: Uday Kamath <UKamath_at_dharbor.com>
Date: Mon, 21 Feb 2005 09:48:31 -0500

Hi
I am trying to use Jaxb's Ant target for XJCtask and this is my code
 

 
_project.addTaskDefinition("xjc",com.sun.tools.xjc.XJCTask.class);
        XJCTask xjcTask = (XJCTask) _project.createTask("xjc");
        xjcTask.setPackage(domainDirectoryPath);
        //set args
        String args = " -nv use-runtime com.eidea.util.xml.jaxbri";
        Commandline.Argument argument = xjcTask.createArg();
        argument.setValue(args);
        String schemaFileName =directoryForGeneration + File.separator +
schemaName;
        File schemaFile =
            new File(schemaFileName);
        if (schemaFile.exists())
            xjcTask.setSchema(schemaFile);
        else
            throw new CodeGeneratorException(
                schemaFile.getName() + "doesn't exist");
        File classesDir = new File(directoryForGeneration);
        System.out.println("The directory for generation: " +
directoryForGeneration +
                           " Schema File Name :" + schemaFileName +
                           " target for xjc: " + classesDir);
        if (classesDir.exists())
            xjcTask.setTarget(classesDir);
        else
            throw new CodeGeneratorException(
                classesDir.getName() + "doesn't exist");
        xjcTask.setExtension(true);
        xjcTask.execute();

When I run this I get following error, somehow it uses my args of NV and
use runtime,
Am I doing it right?

Thanks
Uday

 : +User task: xjc com.sun.tools.xjc.XJCTask
 : +Task: xjc
The directory for generation:
C:\bea813\user_projects\domains\cluster17\oms\xmlt
mpSchema File Name
:C:\bea813\user_projects\domains\cluster17\oms\xmltmp\CustDe
tails_SAP.xsdtarget for xjc:
C:\bea813\user_projects\domains\cluster17\oms\xmltm
p
xjc : build id of XJC is 1.0.2-b15-fcs
xjc : Checking timestamp of
C:\bea813\user_projects\domains\cluster17\oms\xmltmp
\CustDetails_SAP.xsd
xjc : the last modified time of ths inputs is 1108995915390
xjc : the last modified time of the outputs is -9223372036854775808
xjc : Compiling
file:/C:/bea813/user_projects/domains/cluster17/oms/xmltmp/CustD
etails_SAP.xsd and others
xjc : [INFO] Using Xerces from
zip:C:/bea813/user_projects/domains/cluster17/mys
erver/.wlnotdelete/extract/myserver_Admin_admin/jarfiles/WEB-INF/lib/xer
cesImpl2
0928.jar!/org/apache/xerces/impl/Version.class
xjc : unknown location
xjc :
 : Finding class org.apache.xerces.impl.xs.XMLSchemaLoader
 : Finding class org.apache.xerces.impl.dv.dtd.DTDDVFactoryImpl
 : Finding class org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl
 : Finding class org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl
 : Finding class org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl
 : Finding class org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl
xjc : [ERROR] schema_reference.4: Failed to read schema document
'file:/C:/bea81
3/user_projects/domains/cluster17/%20-nv%20use-runtime%20com.eidea.util.
xml.jaxb
ri', because 1) could not find the document; 2) the document could not
be read;
3) the root element of the document is not <xsd:schema>.
xjc : unknown location
xjc :
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)