Hi All
I am doing a multimap 1:n IDOC to multiple files scenario using JAVA map
I am getting an error while executing the java map
Mapping "http://certainteed.com/ecc_redprairie/a2a/transact/otc/OM_Order_To_TMSOrderMultiMap" failed to execute: MappingException: Mapping failed in runtimeApplication mapping program com/certainteed/tms/jmap/ordermultimap/local/MapOrderIDOCToTMSFile throws a stream transformation exception: Mapping Exception: while trying to invoke the method org.w3c.dom.Node.getChildNodes() of a null object loaded from local variable 'node', ApplicationException: Application mapping program com/certainteed/tms/jmap/ordermultimap/local/MapOrderIDOCToTMSFile throws a stream transformation exception: Mapping Exception: while trying to invoke the method org.w3c.dom.Node.getChildNodes() of a null object loaded from local variable 'node', StreamTransformationException: Mapping Exception: while trying to invoke the method org.w3c.dom.Node.getChildNodes() of a null object loaded from local variable 'node', NullPointerException: while trying to invoke the method org.w3c.dom.Node.getChildNodes() of a null object loaded from local variable 'node'
The source IDOC XML has this format below in the mapping editor and it looks like the document is always coming as null in the java map code for some reason. Any idea?
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
<ns0:Message1>
<ORDERS05>
<IDOC>
--
---
---
</IDOC>
</ORDERS05>
this is my java map code excerpt
public void transform(TransformationInput in, TransformationOutput out)
throws StreamTransformationException {
AbstractTrace trace = null;
try {
// Initialise Trace
trace = getTrace();
DocumentBuilderFactory tfactory = DocumentBuilderFactory
.newInstance();
//tfactory.setNamespaceAware(true);
DocumentBuilder tbuilder = tfactory.newDocumentBuilder();
Document doc = tbuilder.parse(in.getInputPayload()
.getInputStream());
doc.getDocumentElement().normalize();
// Create new output document
Document outDoc = tbuilder.newDocument();
Node idocNode = null; | |||
NodeList children = doc.getChildNodes();
for(int i=0;i<children.getLength();i++)
{
Node child = children.item(i); | |||
short childType = child.getNodeType(); | |||
if(childType == Node.ELEMENT_NODE){ | |||
String nodeName = child.getNodeName(); | |||
if(nodeName.equals("ORDERS05")){ | |||
idocNode = child.getFirstChild(); | |||
break; | |||
} | |||
} |
}
And rest of the logic ..the error seems to be occuring at the statement "NodeList children = doc.getChildNodes();" It is not finding any value in doc to get the child nodes and throwing null exception. any help is really appreciated
thx
mike