Hi, 

I am trying to use the API like so, creating a BundleApp via API.  I am using 
Falcon 0.9 jars. 

private static void generateBundle() throws FalconException{
                
                BUNDLEAPP bundleapp = new BUNDLEAPP();
                //BUNDLEAPP bundle = unmarshalBundleapp(bundleTemplate);
                bundleapp.setName("My-Bundle-App");
                
                CONTROLS controls = new CONTROLS();
                controls.setKickOffTime(sdf.format(new Date()));
                bundleapp.setControls(controls);
                
                COORDINATOR coordinator = new COORDINATOR();
                coordinator.setName("My-Bundle-Coordinator");
                coordinator.setAppPath("/user/cloudera/oozieco");
                bundleapp.getCoordinator().add(coordinator);
                
                JAXBElement<BUNDLEAPP> bApp = new 
org.apache.falcon.oozie.bundle.ObjectFactory().createBundleApp(bundleapp);
                
                try {
                        Marshaller buMarshaller = 
OozieUtils.BUNDLE_JAXB_CONTEXT.createMarshaller();
                        //Marshaller buMarshaller = 
JAXBContext.newInstance(BUNDLEAPP.class).createMarshaller();
                        
buMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
                        
                        SchemaFactory schemaFactory = 
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema";);
                        Schema schema = 
schemaFactory.newSchema(GenerateCoordinator.class.getResource("/oozie-bundle-0.2.xsd"));
                        buMarshaller.setSchema(schema);
                        
                        buMarshaller.marshal(bApp, new 
OutputStreamWriter(System.out));
                        
                } catch (JAXBException | SAXException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }

But when I execute this code, I get an exception 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
javax.xml.bind.MarshalException
 - with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; cvc-elt.1.a: 
Cannot find the declaration of element 'bundle-app'.]
        at 
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
        at 
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:249)
        at 
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:116)
        at 
com.ligadata.oozie.check.GenerateCoordinator.generateBundle(GenerateCoordinator.java:84)
        at 
com.ligadata.oozie.check.GenerateCoordinator.main(GenerateCoordinator.java:52)
Caused by: org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; 
cvc-elt.1.a: Cannot find the declaration of element 'bundle-app'.
        at 
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown 
Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
        at 
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
        at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown 
Source)
        at 
org.apache.xerces.jaxp.validation.ValidatorHandlerImpl.startElement(Unknown 
Source)
        at 
org.xml.sax.helpers.XMLFilterImpl.startElement(XMLFilterImpl.java:551)
        at 
com.sun.xml.bind.v2.runtime.output.SAXOutput.endStartTag(SAXOutput.java:128)
        at 
com.sun.xml.bind.v2.runtime.output.ForkXmlOutput.endStartTag(ForkXmlOutput.java:106)
        at 
com.sun.xml.bind.v2.runtime.XMLSerializer.endAttributes(XMLSerializer.java:310)
        at 
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:699)
        at 
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:156)
        at 
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl$1.serializeBody(ElementBeanInfoImpl.java:193)
        at 
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeBody(ElementBeanInfoImpl.java:321)
        at 
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:328)
        at 
com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl.serializeRoot(ElementBeanInfoImpl.java:76)
        at 
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:498)
        at 
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:320)
        ... 4 more

Not sure what I am doing wrong. Similar code works for Coordinator App and 
Workflow App. 

Thanks in Advance.
Chandra

Reply via email to