Rickard_Åberg_5601

Problem loading a UC4Object with a new XML

Discussion created by Rickard_Åberg_5601 on Feb 23, 2015
Latest reply on Mar 29, 2015 by Jennifer_Jinhong_34
Version of jar: '9.00A407-990


Hi,

I'm trying to create a job and then load it with the information from an XML file. The XML file has been exported from a UC4-object that we currently use. I get this exception:

Exception
INFO: Begin - creating new Job
 -----------------------------------------------
Job: TEST_JAVA_JOB does not exist
Job created with name: TEST_JAVA_JOB of JobType: JAVA_JOB in path: INFO/MARSP/JAVA.API
Modiyfing job: TEST_JAVA_JOB
Modiyfing idnr: 2061004
Exception in thread "main" java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredTextImpl cannot be cast to org.w3c.dom.Element
        at com.uc4.api.objects.UC4Object.loadHead(UC4Object.java:82)
        at com.uc4.api.objects.UC4Object.load(UC4Object.java:162)
        at com.nordea.marketrisk.uc4publisher.UC4JavaImpl.createNewJob(UC4JavaImpl.java:254)


The code that does the job is (just an extract) is this:

FolderTree tree = new FolderTree();
uc4Connection.sendRequestAndWait(tree);
IFolder folder = tree.getFolder(treePath); 
 
 
Job job = null;
UC4ObjectName name = new UC4ObjectName(jobName);
CreateObject create = null;
 switch (jobType){
 
         case "JAVA_JOB": {
                 if (!isJobExists(jobName)){
                         OpenObject openObject = new OpenObject(new UC4ObjectName(jobName));
                         uc4Connection.sendRequestAndWait(openObject);
                         
                              create  = new CreateObject(name, Template.JOBS_WIN, folder);                              
                              uc4Connection.sendRequestAndWait(create);        
                         System.out.println ("Job created with name: " +jobName + " of JobType: "+ jobType + " in path: " + treePath);
                         //TODO: check null
 
                         openObject = new OpenObject(new UC4ObjectName(jobName));
                         uc4Connection.sendRequestAndWait(openObject);
                         
                         
                         job = (Job) openObject.getUC4Object();
                         
                         
                         XMLDocument xml = (XMLDocument)templates.getJAVA_JOB_XML_TEMPLATE();
                         ConnectionAttributes attr = uc4Connection.getSessionInfo();
                         
 
                         job.load(xml,attr );        CRASHES HERE


I also read the xml like this:

public class Templates {
 
 
private  XMLDocument SQL_JOB_XML_TEMPLATE = null;
private  XMLDocument SQL_JOB_PLAN_XML_TEMPLATE = null;
 
private  XMLDocument JAVA_JOB_XML_TEMPLATE = null;
private  XMLDocument JAVA_JOBPLAN__XML_TEMPLATE = null;
 
public Templates () throws ParserConfigurationException, SAXException, IOException{
 
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
 
File javaJobFileName =new  File ("src/main/re     sources/templates/java_job_template.xml");
File sqlJobFileName = new  File ("src/main/resources/templates/sql_job_template.xml");
 
 
this.JAVA_JOB_XML_TEMPLATE = new XMLDocument(dBuilder.parse(javaJobFileName));
 
 
 
}
 
 
public XMLDocument getJAVA_JOB_XML_TEMPLATE() {
return JAVA_JOB_XML_TEMPLATE;
}
 
 
}
 


Outcomes