One Star

Deploying a Data Mapper Job

Hello -
I've created a job that parses a complex XML and maps the output to a CSV file, using Data Mapper in Talend Enterprise 5.4.1. I've tested the map, and the output looks great - works as expected.
Now I want to deploy my job to be able to execute it from Talend DI - as a part of a set of operations. I've exported my job from the Studio using File --> Export --> General --> Archive. I'd like to execute this job from my Talend Job using the Java API (think this is the most straightforward option that does not depend on 3rd party libraries) - http://doc.talend.com/enterprise/talend_data_mapper/3.3/api.php
The documentation talks of examples, but I couldn't find them - got errors when I selected Help --> Cheat Sheets...
Any help in deploying a Data Mapper job would be appreciated.
Thanks.
4 REPLIES
Moderator

Re: Deploying a Data Mapper Job

Hi
We have reported your problem to Talend Data Mapper Developer then come back to you asap.
Thanks for your time.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Deploying a Data Mapper Job

Thank you, Sabrina... I'll wait to hear back... In the meantime, I'll investigate if this is the right approach - seems to be - https://help.talend.com/search/all?query=tHMap&content-lang=en
I'll report back as well...
One Star

Re: Deploying a Data Mapper Job

I made some progress by following the Scenario 2 on the link in my previous post.
I've configured my job as shown in the attached screenshots. I independently created a map in the Data Mapping perspective. Then I switched to the Integration perspective, created the job as shown and mapped to the map I had created in the Mapping perspective. Unfortunately, it failed with the following error:

Starting job Test004XML at 17:15 17/04/2014.
connecting to socket on port 3586
connected
Overall: Fatal
1: Info - Executing map. (328)
Map: /DATAMAPPERPROJECTS/Maps/NestedXMLs Properties: {}
2: Fatal - The transformation engine failed. (202)
Generated text: 01 declare namespace Flat = "urnSmiley Surprisedaklandsw:rep:flat";
02 declare namespace com_oaklandsw_transform_runtime_RuntimeSupport = "java:com.oaklandsw.transform.runtime.RuntimeSupport";
03 declare namespace com_oaklandsw_transform_rep_db_RuntimeSupportDatabase = "java:com.oaklandsw.transform.rep.db.RuntimeSupportDatabase";
04
05
06 declare function localSmiley Surprisedut_Flat_csv_Flat_row_Flat_row($top,$out_Flat_csv_Flat_row,$out_Flat_csv_Flat_row_i,$out_Flat_csv,$out_Flat_csv_i)
07 {
08 (: seq in$/ZPM/ZPM_EQUIPMENT_EXPORT/CLOBJ/CLOBJDAT Smiley Happy
09 for $out_Flat_csv_Flat_row_Flat_row at $out_Flat_csv_Flat_row_Flat_row_i in let $inVar := $out_Flat_csv_Flat_row/CLOBJ/CLOBJDAT return $inVar
10 return (: for Smiley Happy (
11 (: element out$/csv/row Smiley Happy element Flat:row {
12 (: element out$/csv/row/EXPORT_ID Smiley Happy element Flat:EXPORT_ID {
13 (: value out$/csv/row/EXPORT_ID Smiley Happy
14 let $unconvertedValue := (
15 (: nullCheck Smiley Happy if ($out_Flat_csv_Flat_row/EXPORT_ID/@xsi:nil) then ('_osdt987Null') else ($out_Flat_csv_Flat_row/EXPORT_ID/text()) (: nullCheck Smiley Happy ) return if ((if (fn:count($unconvertedValue) = 1) then $unconvertedValue else $unconvertedValue) cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
16 (: element end out$/csv/row/EXPORT_ID Smiley Happy },
17 (: element out$/csv/row/EQUNR Smiley Happy element Flat:EQUNR {
18 (: value out$/csv/row/EQUNR Smiley Happy
19 let $unconvertedValue := (
20 (: nullCheck Smiley Happy if ($out_Flat_csv_Flat_row/EQUI/EQUNR/@xsi:nil) then ('_osdt987Null') else ($out_Flat_csv_Flat_row/EQUI/EQUNR/text()) (: nullCheck Smiley Happy ) return if ((if (fn:count($unconvertedValue) = 1) then $unconvertedValue else $unconvertedValue) cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
21 (: element end out$/csv/row/EQUNR Smiley Happy },
22 (: element out$/csv/row/AEDAT Smiley Happy element Flat:AEDAT {
23 (: value out$/csv/row/AEDAT Smiley Happy
24 let $unconvertedValue := (
25 (: nullCheck Smiley Happy if ($out_Flat_csv_Flat_row/EQUI/AEDAT/@xsi:nil) then ('_osdt987Null') else ($out_Flat_csv_Flat_row/EQUI/AEDAT/text()) (: nullCheck Smiley Happy ) return if ((if (fn:count($unconvertedValue) = 1) then $unconvertedValue else $unconvertedValue) cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
26 (: element end out$/csv/row/AEDAT Smiley Happy },
27 (: element out$/csv/row/TABIX Smiley Happy element Flat:TABIX {
28 (: value out$/csv/row/TABIX Smiley Happy
29 let $unconvertedValue := (
30 (: nullCheck Smiley Happy if ($out_Flat_csv_Flat_row_Flat_row/TABIX/@xsi:nil) then ('_osdt987Null') else ($out_Flat_csv_Flat_row_Flat_row/TABIX/text()) (: nullCheck Smiley Happy ) return if ((if (fn:count($unconvertedValue) = 1) then $unconvertedValue else $unconvertedValue) cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
31 (: element end out$/csv/row/TABIX Smiley Happy },
32 (: element out$/csv/row/ATFLV Smiley Happy element Flat:ATFLV {
33 (: value out$/csv/row/ATFLV Smiley Happy
34 let $unconvertedValue := (
35 (: nullCheck Smiley Happy if ($out_Flat_csv_Flat_row_Flat_row/ATFLV/@xsi:nil) then ('_osdt987Null') else ($out_Flat_csv_Flat_row_Flat_row/ATFLV/text()) (: nullCheck Smiley Happy ) return if ((if (fn:count($unconvertedValue) = 1) then $unconvertedValue else $unconvertedValue) cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
36 (: element end out$/csv/row/ATFLV Smiley Happy },
37 (: element out$/csv/row/ATNAM Smiley Happy element Flat:ATNAM {
38 (: value out$/csv/row/ATNAM Smiley Happy
39 let $unconvertedValue := (
40 (: nullCheck Smiley Happy if ($out_Flat_csv_Flat_row_Flat_row/ATNAM/@xsi:nil) then ('_osdt987Null') else ($out_Flat_csv_Flat_row_Flat_row/ATNAM/text()) (: nullCheck Smiley Happy ) return if ((if (fn:count($unconvertedValue) = 1) then $unconvertedValue else $unconvertedValue) cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
41 (: element end out$/csv/row/ATNAM Smiley Happy }
42 (: element end out$/csv/row Smiley Happy }
43 (: seq end in$/ZPM/ZPM_EQUIPMENT_EXPORT/CLOBJ/CLOBJDAT Smiley Happy )
44 };
45
46
47 declare function localSmiley Surprisedut_Flat_csv_Flat_row($top,$out_Flat_csv,$out_Flat_csv_i)
48 {
49 (: seq in$/ZPM/ZPM_EQUIPMENT_EXPORT Smiley Happy
50 for $out_Flat_csv_Flat_row at $out_Flat_csv_Flat_row_i in let $inVar := $out_Flat_csv/ZPM_EQUIPMENT_EXPORT return $inVar
51 return (: for Smiley Happy (localSmiley Surprisedut_Flat_csv_Flat_row_Flat_row($top,$out_Flat_csv_Flat_row,$out_Flat_csv_Flat_row_i,$out_Flat_csv,$out_Flat_csv_i)
52
53 (: seq end in$/ZPM/ZPM_EQUIPMENT_EXPORT Smiley Happy )
54 };
55
56
57 declare function localSmiley Surprisedut_Flat_csv($top)
58 {
59 (: seq in$/ZPM Smiley Happy
60 for $out_Flat_csv at $out_Flat_csv_i in let $inVar := $top/ZPM return $inVar
61 return (: for Smiley Happy (
62 (: element out$/csv Smiley Happy element Flat:csv { (), localSmiley Surprisedut_Flat_csv_Flat_row($top,$out_Flat_csv,$out_Flat_csv_i)
63
64 (: element end out$/csv Smiley Happy }
65 (: seq end in$/ZPM Smiley Happy )
66 };
67
68 (: OUTPUT - Start Smiley Happy
69 localSmiley Surprisedut_Flat_csv(/)
70 (: OUTPUT - End Smiley Happy
Exception: java.lang.ClassCastException: org.talend.transform.runtime.api.JavaObjectResult cannot be cast to javax.xml.transform.stream.StreamResult
at com.oaklandsw.transform.rep.delimited.AbstractDelimitedWriter.setResult(AbstractDelimitedWriter.java:119)
at com.oaklandsw.transform.runtime.func.IoWriteRuntimeImpl.createContentHandler(IoWriteRuntimeImpl.java:284)
at com.oaklandsw.transform.runtime.MapOutputContentHandler.installNewRuntime(MapOutputContentHandler.java:112)
at com.oaklandsw.transform.runtime.MapOutputContentHandler.startDocument(MapOutputContentHandler.java:240)
at net.sf.saxon.event.ContentHandlerProxy.open(ContentHandlerProxy.java:261)
at net.sf.saxon.event.ProxyReceiver.open(ProxyReceiver.java:80)
at net.sf.saxon.event.ComplexContentOutputter.open(ComplexContentOutputter.java:105)
at net.sf.saxon.query.XQueryExpression.run(XQueryExpression.java:390)
at com.oaklandsw.transform.runtime.xquery.saxon9.Saxon9AdaptorImpl.run(Saxon9AdaptorImpl.java:449)
at com.oaklandsw.transform.runtime.xquery.XQueryAdaptorImpl.run(XQueryAdaptorImpl.java:256)
at com.oaklandsw.transform.runtime.StandardMapRuntimeImpl.runQuery(StandardMapRuntimeImpl.java:379)
at com.oaklandsw.transform.runtime.StandardMapRuntimeImpl.runSubclass(StandardMapRuntimeImpl.java:306)
at com.oaklandsw.transform.runtime.MapRuntimeImpl$1.run(MapRuntimeImpl.java:377)
at com.oaklandsw.transform.runtime.RuntimeEngineImpl.runSansEditor(RuntimeEngineImpl.java:957)
at com.oaklandsw.transform.runtime.MapRuntimeImpl.runMap(MapRuntimeImpl.java:368)
at com.oaklandsw.transform.runtime.MapOrStructRuntimeImpl.run(MapOrStructRuntimeImpl.java:794)
at datamapperprojects.test004xml_0_1.Test004XML.tFileInputXML_1Process(Test004XML.java:1149)
at datamapperprojects.test004xml_0_1.Test004XML.runJobInTOS(Test004XML.java:1582)
at datamapperprojects.test004xml_0_1.Test004XML.main(Test004XML.java:1447)
Exception in component tHMap_1_THMAP_IN
java.lang.NullPointerException
at datamapperprojects.test004xml_0_1.Test004XML.tFileInputXML_1Process(Test004XML.java:1164)
at datamapperprojects.test004xml_0_1.Test004XML.runJobInTOS(Test004XML.java:1582)
at datamapperprojects.test004xml_0_1.Test004XML.main(Test004XML.java:1447)
disconnected
Job Test004XML ended at 17:15 17/04/2014.

Any help will be appreciated...
Thanks.
One Star

Re: Deploying a Data Mapper Job

Hi willm,
I know that it's too late for a response but I think this might help someone facing a similar issue in future.
The reason that you're getting that exception is because of a configuration issue in tHMap component. You're reading a single XML as input and you intend to output a single XML, so change your tHMap component settings like below.
Write Output As Document (single column) instead of Write Output As (Date Integration columns)
Thanks,
webdev