Exception in Java Mapping

hi All,
I'm trying to validate the incoming XML against a given XSD using Java Mapping.. When i execute it i get the following error in the Mapping...
com.sap.engine.lib.xml.util.NestedException -> com.sap.engine.lib.xml.parser.ParserException -> java.io.IOException: Parsing an empty source. Root element expected!
Please do help me out..... I have given my java Code Below.....
Note:The XSD is attached in the same zip file which contains java class and the zip file is imported in the Imported ARchive Area....
package cts.com.XSD;
import java.io.*;
import java.util.Map;
import com.sap.aii.mapping.api.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
public class TestJavaMapping implements StreamTransformation
     Map param=null;
     public void setParameter(Map arg0)
          this.param=arg0;
     public  void execute(InputStream in, OutputStream out) throws StreamTransformationException
     byte b[];
     byte b1[];
     try
           b = new byte[in.available()];
           in.read(b);
              AbstractTrace trace=(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);
           InputStream Schemainput= new
TestJavaMapping().getClass().getClassLoader().getResourceAsStream("cts/com/XSD/ShipmentDetails.xsd");
     b1 = new byte[Schemainput.available()];
     Schemainput.read(b1);
     String XsdString =new String(b1);
     trace.addInfo("XSD obtained");
     DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
     docBuilderFactory.setNamespaceAware(true);
     docBuilderFactory.setValidating(true);
     trace.addInfo("After Setting True");
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage","http://www.w3.org/2001/XMLSchema");
docBuilderFactory.setAttribute( "http://java.sun.com/xml/jaxp/properties/schemaSource",XsdString);
trace.addInfo("After Setting ATtribute");
          trace.addInfo("B4 Parsing");
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
          Document validDoc = docBuilder.parse(in);     
          trace.addInfo("After Parsing");
          out.write(b);
     catch(Exception e)
          AbstractTrace trace=(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);
          trace.addInfo(e.getMessage());

Hi Thorsten,
Thanks for the Suggestion of using SAX instead of DOM... i even tried using SAX parser i get "Generic Exception"..i have give the code below.. please do help me out..
package cts.com.XSD;
import java.util.Map;
import java.io.*;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import org.w3c.dom.Document;
public class TestJavaMapping implements StreamTransformation
     Map param=null;
     public void setParameter(Map arg0)
          this.param=arg0;
     public  void execute(InputStream in, OutputStream out) throws StreamTransformationException
          try
                SAXParserFactory factory = SAXParserFactory.newInstance();
                factory.setNamespaceAware( true);
                factory.setValidating( true);
InputStream Schemainput = new
TestJavaMapping().getClass().getClassLoader().getResourceAsStream("cts/com/XSD/ShipmentDetails.xsd");               
                  SAXParser parser = factory.newSAXParser();
                parser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
                                                            "http://www.w3.org/2001/XMLSchema");
                parser.setProperty( "http://java.sun.com/xml/jaxp/properties/schemaSource",Schemainput);
                byte b[]=new byte[in.available()];
                in.read(b);
                XMLReader reader = parser.getXMLReader();
                  reader.parse(new String(b));
                out.write(b);
          catch ( ParserConfigurationException e)
               AbstractTrace trace=(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);
               trace.addInfo(e.getMessage());
          catch ( SAXException e)
               AbstractTrace trace=(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);
               trace.addInfo(e.getMessage());
          catch ( IOException e)
                 AbstractTrace trace=(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);
               trace.addInfo(e.getMessage());
          catch(Exception e)
               AbstractTrace trace=(AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE);
               trace.addInfo(e.getMessage());

Similar Messages

  • Generic Exception in java mapping

    hi all,
    i'm using xerces api inorder to validate the outbound xml with its corresponding xsd using java mapping . when mapping is executed , i get "Generic Exception". it does'nt leave any  trace other than the word "Generic Exception". i use same jdk version used by  XI.kindly help me regarding this issue.
    Thanks and Regards
    kausik

    hello kausik,
    i have the same problem in java mapping by validating incoming xml files.
    could you solve the problem?
    can you tell me how to solve the problem?
    you can write me an email with the solution ([email protected])? or post it here?
    thanks a lot
    ciao alex

  • Null exception in Java mapping

    Hi Experts,
    I am getting "Exception in thread "main" java.lang.NoClassDefFoundError: com/sap/aii/utilxi/misc/api/BaseRuntimeException
    in line Container container = new Context(new FunctionWrapper(0)); " when trying to execute the java mapping inside my interface mapping.
    I am using the following code iside my java class in NWDS when I get the above error:
    //Get the message Header
              Container container = new Context(new FunctionWrapper(0));
              map = container.getTransformationParameters();
              strMessageID =  (String) map.get("MessageId"); // Get Message GUID
              strMessageID = strMessageID.trim();
              strMessageDate =  (String) map.get("TimeSent");
              strMessageTime = (String) map.get("TimeSent"); // Get Time Sent
    I have also imported aii_mt_rt.jar, aii_map_api.jar, aii_utilxi_misc.jar  into my class.
    Please can you help me solve this problem.
    Thanks and regards,
    Brendon

    I solved the problem by using
    strMessageID = (String)param.get(     
    StreamTransformationConstants.MESSAGE_ID);

  • Throw exception in Java mapping and handle this in BPM

    Hi,
    I'll use a Java mapping in a BPM transform step. Is it possible to throw an exception inside this Java mapping and handle this in a BPM exception handler?
    thanks and regards
    Verena

    Hi Verena,
    In a BPM transformation step, I think you can throw exceptions only for system errors.
    Let me explain with an example, one of the ways to handle your scenario:
    Lets assume your Java Mapping fails then you can trap that exception in your Java mapping and compose an XML message which indicates that an error has occurred.
    say for e.g.
    <intermediateStructure>
    <SatusDocument>
    <StatusCode>ERROR</StatusCode>
    <ErrCode>123</ErrCode>
    <ErrDesc><!populate the thrown exception details></ErrDesc>
    </StatusDocument>
    <Payload>
    <!contains actual XML message with data>
    </Payload>
    </intermediateStructure>
    if Java mapping is Successful, you can compose the XML message as follows:
    <intermediateStructure>
    <SatusDocument>
    <StatusCode>SUCCESS</StatusCode>
    <ErrCode>0</ErrCode>
    <ErrDesc></ErrDesc>
    </StatusDocument>
    <Payload>
    <!contains actual XML message with data>
    </Payload>
    </intermediateStructure>
    You can use BPM switch operation to switch to different processing branches say for e.g. "error" branch or "success" branch by examining the value of <StatusCode> tag.
    Hope it helps !
    Regards,
    Sridhar

  • Exception while perfroming Java mapping in XI

    Hi there,
    Im doing some java mapping in XI using the standard/classic DOM and JAXP packages, I have tested everything outside XI and the code seems to be OK.
    However when I deploy the code into XI self and run a test, something goes wrong.
    This is the exception Im getting from my log (PS: In th eyes of XI eveything goes fine, but this is because I have all my code surrounded by try/catch statements...):
    <b>java.lang.ClassCastException: com.inqmy.lib.xml.dom.DocumentImpl</b>
    1) First, what I dont understand here is the fact that Im not doing any kind of parsing to this type "com.inqmy.lib.xml.dom.DocumentImpl" in my code, so Why XI is doing this?
    2) It seems to me like XI internally uses this "fancy" INQMY package to perform my XML parsing/mapping. But nowhere in the documentation is mentioned, at least I haven't read about it.
    3) Is there anyplace where I can find/download this package "com.inqmy.lib.xml.dom.*" so that I can test/debug my code using this specific SAP pacakge?
    Can anyone give me some clues how to solve and prevent this issue? Below is the part of the code where the exception is generated:
         private void processMultiMessages(Vector indexVector, NodeList msgList) {
              Iterator iter = indexVector.iterator();
              Integer tempIndex = null;
              int index = 0;
              try {
                   for (int i = 0; i < indexVector.size(); i++) {
                        tempIndex = (Integer) indexVector.elementAt(i);
                        index = tempIndex.intValue();
                        Range range = ((DocumentRange) mainDocument).createRange();
                        range.setStartBefore(msgList.item(index));
                        if ((i + 1) > (indexVector.size() - 1)) {
                             index = msgList.getLength() - 1;
                             range.setEndAfter(msgList.item(index));
                        } else {
                             tempIndex = (Integer) indexVector.elementAt(i + 1);
                             index = tempIndex.intValue();
                             range.setEndAfter(msgList.item(--index));
                        createNewMsg(range.cloneContents());
                        range.detach();
                   getSystemParams().put("STATUS", "OK");
                   getSystemParams().put("TOTAL_MSG", new Integer(indexVector.size()));
                   getSystemParams().put(
                        "STATUS_MSG",
                        "Target directory on XI Server: " + folder);
                   this.out.write(
                        new LogDocument().createDocument(getSystemParams()).getBytes());
              } catch (Exception e) {
                   getSystemParams().put("STATUS", "FAIL");
                   getSystemParams().put("TOTAL_MSG", new Integer(indexVector.size()));
                   getSystemParams().put(
                        "STATUS_MSG",
                        "** Exception in Java Mapping: " + e.toString() +" ** System error: " +  System.err);
                   try {
                        this.out.write(
                             new LogDocument()
                                  .createDocument(getSystemParams())
                                  .getBytes());
                        e.printStackTrace();
                   } catch (IOException ioE) {
                        ioE.printStackTrace();

    Hi there,
    I have included the inqmyxml.jar in my classpath and perfor
    med some tests (outside XI), with good results.
    However, when I copy/deploy the same classes into XI then the problem still there. My Java class is complaining about some ClassCastException, the error looks like this:
    java.lang.ClassCastException: com.inqmy.lib.xml.dom.DocumentImpl
    has anyone any ideas/clues was happening here?
    Cheers,
    Rob.
    PS: These are the packages Im importing in my class:
    import com.sap.aii.mapping.api.*;
    <i>import java.io.*;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamResult;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.w3c.dom.*;
    import org.w3c.dom.ranges.*;
    import com.inqmy.lib.jaxp.*;
    import com.inqmy.lib.xml.*;
    import com.inqmy.lib.xml.parser.*;
    import com.inqmy.lib.xml.dom.*;</i>
    And these are the Global vars Im using:
    <i>     // declare Global vars
         private Map systemParams;
         private InputStream in;
         private OutputStream out;
         private DocumentBuilderFactory domFactory;     
         private DocumentBuilder documentBuilder;
         private Document mainDocument;
         private String path;
         private String separator;
         private File folder;</i>
    And finally this is the way I start my mapping/parsing process:
    <i>               ClassLoader cl = Thread.currentThread().getContextClassLoader();
                   Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
    domFactory = DocumentBuilderFactoryImpl.newInstance();
                   Thread.currentThread().setContextClassLoader(cl);
    // Optional: set various configuration options
                   domFactory.setIgnoringComments(true);
                   domFactory.setIgnoringElementContentWhitespace(true);
    domFactory.setValidating(false);
    domFactory.setCoalescing(false);
    // Create and set documentBuilder
    documentBuilder = domFactory.newDocumentBuilder();
    // parse the input file
    mainDocument = documentBuilder.parse(in);
    </i>

  • Need help on guide of java mapping

    HI,
    I want to learn java mapping. I searched in blogs but I am not comfortable to understand. Can anyone explain me the step by step process.
    Thanks,
    Enivass

    Hi enivas,
    Having basic understanding about J2SE will be great help for you. Please check these links about Java Mapping step by step
    Implementing a Java Mapping in SAP PI /people/carlosivan.prietorubio/blog/2007/12/21/implementing-a-java-mapping-in-sap-pi
    XI Java Mapping Helper (DOM) /people/alessandro.guarneri/blog/2007/03/25/xi-java-mapping-helper-dom
    Debugging Java Mappings using SAP Netweaver Developer Studio /people/christian.drumm/blog/2008/09/30/debugging-java-mappings-using-sap-netweaver-developer-studio
    Handling and Tracing Runtime Exceptions in Java Mapping /people/prasannakrishna.mynam/blog/2009/07/21/handling-and-tracing-runtime-exceptions-in-java-mapping
    SAP PI Java API has changed a lot from PI7.0 to PI7.1. http://wiki.sdn.sap.com/wiki/display/XI/UsingPI7.1APIforJavamapping
    Check them out in this link Javadocs Index http://www.sdn.sap.com/irj/sdn/javadocs. Blogs mentioned use old API, but once you get idea about Java mapping switching to new API will be easy. Java help is easily available on net, use Google more. Happy learning.
    Regards,
    Raghu_Vamsee

  • XML not well formed - Java Mapping, Webservice to RFC Scenario

    Hello All Experts,
    I have facing a strange type of error. I have written a Java Mapping which implements a DOM parser to take a request from a Webservice and validate it on the basis of some prerequisites. i.e. If data in the incoming request is valid, it creates a message of the same structure type as the input. If the incoming data is incorrect or incomplete; It generates an Error response structure.
    When I run and test the same mapping program using Editplus Java editor for the error scenario; it executes perfectly and creates the correct error XML structure. (I checked it by importing the structure in the XI Message mapping test tab). But when I create jar of my java mapping program and test it in my interface mapping, it gives me "XML not well formed error" (Problem while building the tree).
    Any idea as to why is it behaving in such a way? There are 2 reasons which come to my mind as of now:
    1. The initilization of my input and output streams in the public static void main:
                InputStream in = new FileInputStream(new File("Input.xml"));
               OutputStream out = new FileOutputStream(new File("Output.xml"));
               validateXML myMapping = new ValidateXML();
                myMapping.execute(in, out);
    The Output.xml has the xml structure for the correct case, do I have to initialize my outputstream for the error file? say error.xml
    2. My Webservice interface is a sychronous interface (Request / Response) and output of the Java mapping program are two asynchronous interface. (I'll use a synch-asynch bridge when this works) - Is that causing a problem?
    Please help.
    Best regards,
    Varun

    Hello Varun,
    it gives me "XML not well formed error" (Problem while building the tree).
    I have come across the same error message while testing in interface mapping. My problem was when an exception occured in java mapping, the execution terminates with the messages XML not well formed error". In order to solve this issue what i did was catch the exception type TransformerException and in that catch block throw StreamTransformationException exception in main methos of mapping program i.e execute().
    eg:-                                                                               
    catch (TransformerException e) {
                   throw new StreamTransformationException("Can not write XML.", e);
    By doing this you will see the exception raised , because some times when you execute your mapping with mail() method, though it create the file, when you try to open it will give error if any exceptions occured in mapping. By using the above notation you can handle those in java mapping.
    Hope you have gone through this blog.
    [Handling and Tracing Exceptions in java mapping|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417700)ID1055371050DB01666765031379427182End?blog=/pub/wlg/15061]
    Regards,
    Prasanna

  • Error  in PI mapping "nested exception is: java.lang.OutOfMemoryError "

    Hi Experts ,
    I encounter an error in the PI mapping while calling a Java Mapping (Mercator Map)
    Error Message as ::-
    java.lang.RuntimeException: RemoteException in setMercGeneral: Error occurred in server thread; nested exception is: java.lang.OutOfMemoryError at com.philips.xi.mercator.MercatorCall.execute(MercatorCall.java:90) at
    Could anyone suggest , how we can overcome  this error message
    I have  also tried  to restart the  RMI Server , but that was not not helpful.
    Regards,
    Shweta

    Sweta,
    Is this a java mapping or Graphical, If Java, you should not run into this issue as you dont load the nested XSD`s.
    Also the error message indicates outofMemory in mercator side when posting your Large message.
    java.lang.OutOfMemoryError at com.philips.xi.mercator.MercatorCall.execute(MercatorCall.java:90) at
    Regards
    Ravi Raman
    Edited by: Ravi Raman on Jun 30, 2010 4:26 PM

  • Handling Java Mapping Exception in BPM Transformation step

    Dear SDN members,
    I have developed a File to File scenario using BPM as follows.
    Step 1:
    Sender file adapter picks the file from FTP server and using file content conversion mapped to XML structure.
    Step 2:
    BPM will recieve the XML payload , immediately in the block a transformation step is called with an interface mapping. In the interface mapping a Java mapping will be executed with certain data validations on the XML payload. If found any invalid data is there a suitable excptions will be raised . Here the transformation step should be catch the error and control should be sent to exception block to place the recived file as a error file.
    else if the transformation is executed with out any issues, the file will be placed in success folder.
    But in the transformation step, though java mapping thorwing exceptions, the control not going into exception block, instead it is continuing to next step i.e the file is placing in the success folder.
    Can anybody tell me, how to handle the exceptions raised in java mapping in the BPM transformation step?
    I have refered all the SDN blogs, forums related to this issue, but could not able to find the answer. Please help me?
    Thanks & Regards
    Vijayanand Poreddy

    Hi Abhishek,
    Once the file is picked from FTP server then sent to BPM,
    the BPM steps
    Step1:
    -->Recive
    Step 2:
    Block Starts
       ---Block Start: New Transaction
       ---Block End : New Transaction
       ---Exception : Error
    Step 3 
    Inside the Block
    Transformation Step
       --Interface Mapping: <IM Name>
       -- Check box ticked for Create New Transcation
       -- Exceptions
          --System Error: Error
       --Source Message: Message recieved in Recieve Step (Step 1)
    Step 4:
      --Send
      --Source Maessage: Output message from the Transformation Step
    Block End
    Inserted a Exception Branch for Block
    Steps inside Exception Branch
      -Control
        --Throw Alert
       --Alert Name
    In the above scenario
    The transformation step is not throwing error even my interface mapping going to error. The same transformation step if i place outside the block next to recieve step, then the transformation step is throwing error and BPM stops the process.
    Also, when transformation is inside the block, i have used the exception handling on the send step inside the block. here it is throwing error as the source message payload is empty. because in the preceding transformation step the interface mapping is failed due to which there the target will not be filled. But even though it is not entered into exception block.
    Regards
    Vijayanand Poreddy

  • Java mapping of application triggered an exception

    Hi,
    We have ascenario where a vendor will be sending us a cXML file which has the second line as <!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.009/InvoiceDetail.dtd">. If I open it in XMLSpy, it is saying the file as invalid. XI is unable to map this file. So we decided to remove that line using Java mapping and then do the regular graphical mapping.
    I took the java code from the SAP note 812966 and used the aii_map_api.jar, dom.jar, jaxp-api.jar to create the class of that java file and used that class file by importing that into XI as a jar file.
    I'm getting this error in the request message mapping of SXMB_MONI
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">STREAM_TRANSFORMATION_EX</SAP:Code>
      <SAP:P1>mypackage/DeleteDTDDeclarationWithDOM</SAP:P1>
      <SAP:P2>Failed to load resource from the context classloa~</SAP:P2>
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Java mapping of application triggered an exception</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    I'm new to this java mapping, Can you please provide me some details about what files need to be loaded into the XI along with the class file.
    Appreciate you help.
    Thanks,
    MT.

    Hi Prateek,
    Thanks for your quick reply. Yes I have downloaded the aii_map_api.jar from <SAP_install_dir>/<system_name>/<instance_name>/j2ee/cluster/server<number>/apps/sap.com/com.sap.xi.services/
    And also I have compiled my java code using the dom.jar, sax.jar, jaxp-api.jar and aii_map_api.jar.
    I took the class file of my javacode and all the class files of the above mentioned jar files and prepared one single jar file, which I imported into XI.
    It is not allowing me to make a single jar of the actual class file and all the supporting jar files.
    What is the actual method of doing it.
    Appreciate all your help. Thanks very much.
    Thanks,
    Maulik.

  • XI AF API call failed. Module exception: Java Mapping

    Hi Experts,
    I have faced a typical error for one of my interface. The Scenario is SOAP to SOAP and we are performing SOAP Lookup  before sending the data to Target web service. We are using one Java Mapping  'FileIns_lookupLoad.java --- com/fi/' and performing the SOAP Lookup from within the code. In the Lookup Communication channel we are using 'Axis' as message protocol and passing couple of values through Module Key parameters. We have same ESR and ID objects in Development, Quality and Production (as per Version ID and History).
    Now the problem is Lookup is failing only in Development but Quality and Production is working fine. I have replaced Quality CC URL with the development WSDL URL, but that worked fine. That means Development Web Service is good. We are getting the below error in Dev:
    <SAP:Stack>StreamTransformationException triggered by application mapping program com/fi/FileIns_lookupLoad; Look Up Failed</SAP:Stack>
    Trace : *
    <Trace level="1"
    type="T"> Some Thing Wrong in LookUpError when calling an adapter by using the communication channel CC_IN_SOAP_GEInsuranceLoadLookup1 (Party: , Service: BusService_GE, Object ID: 4214805c52893ef9b0b3f0ef0902fe9e) XI AF API call failed. Module exception: 'while trying to invoke the method org.apache.axis.types.URI.toString() of an object returned from com.sap.xi.XI.Message._30.QualifiedName.getNamespace()'. Cause Exception: 'while trying to invoke the method org.apache.axis.types.URI.toString() of an object returned from com.sap.xi.XI.Message._30.QualifiedName.getNamespace()'. </Trace>
      <Trace level="1" type="T">*** END APPLICATION TRACE ***</Trace>
      <Trace level="1" type="T">Java mapping com/fi/FileIns_lookupLoad has thrown a StreamTransformationException. Thrown: com.sap.aii.mapping.api.StreamTransformationException: Look Up Failed at com.fi.FileIns_lookupLoad.execute(FileIns_lookupLoad.java:282) at com.fi.FileIns_lookupLoad.transform(FileIns_lookupLoad.java:74) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:92) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep.................................................
    ................................................................................<Trace level="1" type="T">Application mapping program com/fi/FileIns_lookupLoad throws a stream transformation exception: Look Up Failed Thrown: com.sap.aii.ib.core.mapping.execution.ApplicationException: Application mapping program com/fi/FileIns_lookupLoad throws a stream transformation exception: Look Up Failed at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:95) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.SequenceMapping.executeStep(SequenceMapping.java:40) at com.sap.aii.ib.server.mapping.execution.Mapping.execute
    I have already checked with Basis and as per them JDK and Java versions are identical in Dev, QAS and Prod. It seems something is wrong with 'XI AF API' which we are calling from the channel. If we totally ignore Lookup process and send direct data, it is working fine. Target CC is also using Axis.
    Sequence in CC: afreq ->xireq ->wssec2 ->xires ->afres
    For any more information please let me know.
    Thanks,
    Nabendu.

    Hi Anupam,
    The Java Mapping code is same in Dev , QAS and Prod. Also the versions of the JAR is same.
    Please find the code below.
    package com.fi;
    import java.util.HashMap;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformation;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.MappingTrace;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.DynamicConfiguration;
    import com.sap.aii.mapping.api.DynamicConfigurationKey;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.*;
    import org.w3c.dom.views.AbstractView;
    import org.xml.sax.SAXException;
    import java.io.ByteArrayInputStream;
    import com.sap.aii.mapping.lookup.*;
    /*import com.sap.aii.utilxi.hmis.server.HmisEnvironment.Accessor;
    //import com.sap.aii.utilxi.lock.api.LockServiceException;
    //import com.pmintl.pppimes.RFCLookup.javamapping.*;
    //import java.io.FileInputStream;
    //import java.io.FileOutputStream;*/
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    //import java.text.ParseException;
    import java.util.Date;
    import java.io.*;
    public class FileIns_lookupLoad extends AbstractTransformation{
            private Map param = null;
            private AbstractTrace trace = getTrace();
            String senderService = null;
           String inParamChannel = null;
           String inParamBusService = null;
              //3. Each JAVA Mapping using program 7.1 API must implement the method
              // transform(TransformationInput in, TransformationOutput out)
              // as oppose to execute Method in earlier version.
               public void transform(TransformationInput arg0, TransformationOutput arg1) throws StreamTransformationException {
              // TODO Auto-generated method stub
              //4. An info message is added to trace. An instance of trace of object is obtained by calling
              // the getTrace method of class AbstractTransformation
                    inParamChannel = arg0.getInputParameters().getString("COMM_CHANNEL");
                    inParamBusService = arg0.getInputParameters().getString("BUS_SERVICE");
                    getTrace().addInfo("Input Parameter: " + inParamChannel);
                    getTrace().addInfo("Input Parameter: " + inParamBusService);
                    this.execute(arg0.getInputPayload().getInputStream(),
                          arg1.getOutputPayload().getOutputStream());
              //5. Input payload is obtained by using arg0.getInputPayload().getInputStream()
          * @param args
         public static void main(String[] args) {
                // TODO Auto-generated method stub
         public void execute(InputStream in, OutputStream out)
                   throws StreamTransformationException {
              // TODO Auto-generated method stub
              try
                   //Get The Trace
    //               trace = (AbstractTrace)param.get(StreamTransformationConstants.MAPPING_TRACE );
                   trace = getTrace();
                  getTrace().addInfo("Java Mapping Started");
                   DocumentBuilderFactory ifactory = DocumentBuilderFactory.newInstance();
                   DocumentBuilder ibuilder = ifactory.newDocumentBuilder();
                   Document IDoc  = ibuilder.parse(in);
                   Document TDoc = ibuilder.newDocument();
                   String mrnVal = "";
                   trace.addInfo("Preparing Target Doc");
                   Element message = TDoc.createElementNS("urn:Medtronic.com:CATS_Patient_Transactions","n1:Mt_Insurance");
                   Node tRoot = TDoc.appendChild(message);
                   //trace.addInfo(tRoot.getNodeName());
                   Element sRoot = (Element)IDoc.getFirstChild();
                   //trace.addInfo(sRoot.getNodeName());
                   NodeList nl = sRoot.getChildNodes();
               // trace.addInfo("Len"+nl.getLength());
    ////               for(int i=0;i<nl.getLength();i++)
    //                    Node n1 = TDoc.importNode(nl.item(i), true);
    //                    trace.addInfo("Adding Child Nodes");
    //                    trace.addInfo(nl.item(i).getNodeName());
    //                    tRoot.appendChild(n1);
                   NodeList lmrn = sRoot.getElementsByTagName("Mrn");
                   if(lmrn != null)
                        Node n1 = TDoc.importNode(lmrn.item(0), true);
                        Element e1 = (Element)lmrn.item(0);
                        //trace.addInfo(e1.getNodeName());
                        mrnVal = e1.getTextContent();
                        tRoot.appendChild(n1);
                   NodeList lfsc = sRoot.getElementsByTagName("Fsc");
                   if(lfsc != null)
                        for(int i=0;i<lfsc.getLength();i++){
                             Element n1=TDoc.createElement(lfsc.item(i).getNodeName());
                             tRoot.appendChild(n1);
                             Node fieldch = TDoc.createElement("Fields");
                             n1.appendChild(fieldch);
                             NodeList chl = lfsc.item(i).getChildNodes();
                             trace.addInfo("len11"+chl.getLength());
                             for(int j=0;j<chl.getLength();j++){
                                  if(!chl.item(j).getNodeName().equals("FscNumber")&&!chl.item(j).getNodeName().equals("Priority")){
                                       if(chl.item(j).hasChildNodes()){
                                            trace.addInfo(chl.item(j).getNodeName());
                                       Element fscfield = TDoc.createElement("FSCField");
                                       fieldch.appendChild(fscfield);
                                       NodeList FUQl = chl.item(j).getChildNodes();
                                       for(int p =0;p<FUQl.getLength();p++){
                                            //trace.addInfo(" i: "+i+" J: "+j+" P: "+p);
                                            if(FUQl.item(p).getNodeName().equals("FUQNumber")){
                                                 //Node tFUQ = TDoc.createElement("FUQNumber");
                                                 //tFUQ.setTextContent(FUQl.item(p).getTextContent());
                                                 fscfield.setAttribute("FUQNumber", FUQl.item(p).getTextContent());
                                            if(FUQl.item(p).getNodeName().equals("Value")){
                                                 Node tVal = TDoc.createElement("Value");
                                                 tVal.setTextContent(FUQl.item(p).getTextContent());
                                                 fscfield.appendChild(tVal);
                                                 //Node tName = TDoc.createElement("Field");
                                                 //tName.setTextContent(chl.item(j).getNodeName());
                                                 fscfield.setAttribute("Field", chl.item(j).getNodeName());
    //                                   Node fuqch = chl.item(j).getFirstChild();
    //                                   Node valch = fuqch.getNextSibling();
    //                                   if(fuqch!=null){
    //                                        Node tFUQ = TDoc.createElement("FUQNumber");
    //                                        tFUQ.setTextContent(fuqch.getTextContent());
    //                                        fscfield.appendChild(tFUQ);
    //                                   if(valch!=null){
    //                                        Node tVal = TDoc.createElement("Value");
    //                                        tVal.setTextContent(valch.getTextContent());
    //                                        fscfield.appendChild(tVal);
    //                                        Node tName = TDoc.createElement("Filed");
    //                                        tName.setTextContent(chl.item(j).getNodeName());
    //                                        fscfield.appendChild(tName);
                                  else{
                                       //Node numch =TDoc.importNode(chl.item(j), true);
                                       //Element e1 =(Element)n1;
                                       if(chl.item(j).getNodeName().equals("FscNumber")){
                                            n1.setAttribute("Number", chl.item(j).getTextContent());
                                       if(chl.item(j).getNodeName().equals("Priority")){
                                            n1.setAttribute("Priority", chl.item(j).getTextContent());
                             //tRoot.appendChild(lfsc.item(0));
    //                         Element e1 = (Element)lfsc.item(0);
    //                         trace.addInfo(e1.getNodeName());
    //                         mrnVal = e1.getNodeValue();
    /////Start of Look Up Code////
                   //Preparing Input String
                   String lookUpRequest = "<LoadPatientFullInsuranceDetail><Mrn>"+mrnVal+"</Mrn></LoadPatientFullInsuranceDetail>";
                   trace.addInfo("Request");
                   trace.addInfo(lookUpRequest);
                        SystemAccessor acc;
                        Channel channel;
                        Payload lookupResult;     
                        try
                             channel = LookupService.getChannel(inParamBusService, inParamChannel);
                             trace.addInfo("Got the channel");
                             acc = LookupService.getSystemAccessor(channel);
                             trace.addInfo("Got The Channel and Accessor");
                             InputStream ist = new ByteArrayInputStream(lookUpRequest.getBytes());
                             XmlPayload payload = LookupService.getXmlPayload(ist);
                             if(acc != null){
                                  trace.addInfo("Got The Channel and Accessor");
                                  trace.addInfo("Executing The Webservice");
                                  lookupResult = acc.call(payload);
                                  trace.addInfo("End of Executing The Webservice");
                                  trace.addInfo(lookupResult.toString());
                             if(lookUpRequest!=null){
                                  trace.addInfo("Responce is not null");
                                  InputStream rist = lookupResult.getContent();
                                  Document lresDoc = ibuilder.parse(rist);
                                  Node n1 = lresDoc.getFirstChild();
                                  trace.addInfo(n1.getNodeName());
                                  if(n1.getNodeName().endsWith("LoadPatientFullInsuranceDetailResponse"))
                                       Node ch1 = n1.getFirstChild();
                                       trace.addInfo(ch1.getNodeName());
                                       NodeList lookupnl = ch1.getChildNodes();
                                       //trace.add
                                       for(int i=0;i<lookupnl.getLength();i++)
                                            Node n2 = TDoc.importNode(lookupnl.item(i), true);
                                            trace.addInfo("Adding Child Nodes");
                                            trace.addInfo(lookupnl.item(i).getNodeName());
                                            tRoot.appendChild(n2);
                                  else{
                                  throw new StreamTransformationException("Error in Look Up"+n1.getTextContent());
                                   //while(ch1.hasChildNodes() && !ch1.getNodeName().equals("FSCS")){
                             else{
                                  trace.addWarning("Responce is null");
                                 throw new LookupException();
                        catch(LookupException le)
                             trace.addWarning("Some Thing Wrong in LookUp"+le.getMessage());
                             throw new StreamTransformationException("Look Up Failed");                         
                           Transformer transformer = TransformerFactory.newInstance().newTransformer();
    //                       StreamResult reqResult = new StreamResult(new StringWriter());
                           DOMSource source = new DOMSource(TDoc);
                           Result result = new StreamResult(out);
                           transformer.transform(source,result);
              catch(StreamTransformationException ste)
               throw new StreamTransformationException(ste.getMessage());
              catch(Exception e){
                   trace.addInfo(e.getMessage());
              finally{

  • JAVA Mapping with SAX: Illegal character exception &

    Hi everybody,
    I use a SAX JAVA Mapping. It throws an error cause the xml that is parsed has a
    &amp;
    like in
    <D_3036>Company &amp; Co. KG</D_3036>
    Does anybody know how to solve the problem?
    I do not want to replace the
    &amp;
    Are there special settings/properties for the handler/parser?
    Thanks
    Regards
    Mario

    Hi all,
    thanks for your comments and suggestions. The error was not cause by the problem I describes.
    FYI:
    If there is an ampersand in the middle of a string, than the standard method
    characters
    in the handler is called three times!
    This let me asume the ampersand was the error.
    Regards Mario
    Edited by: Mario Müller on Dec 19, 2008 1:23 AM

  • PI 7.11 - How to create a System Error in SXMB_MONI using a Java Mapping

    Hi
    We ve go a  Java Mapping in a File-to-HTTP Scenario. It works perfect except of one error case: if an empty source file or a source file with the wrong structure is delivered. In this case our Java Mapping forwards an empty payload to the HTTP channel. So, for PI is the mapping successful.
    I'd like to recognize this case and invoke a system error in the SXMB_MONI, so that this mapping will be stopped and our alerting concept informs the users. I know, how to recognize the case in Java but need to know how to create the System Error Status in the PI System.
    Thanks in advance
    Michael

    Hi Michael,
    Please refer here for the mapping API description:
    http://help.sap.com/javadocs/NW04S/SPS09/pi/com/sap/aii/mapping/api/package-summary.html
    You can use the StreamTransformationException exception describet there to raise an error from your Java mapping. Direct link:
    http://help.sap.com/javadocs/NW04S/SPS09/pi/com/sap/aii/mapping/api/StreamTransformationException.html
    You might also consider using the "Empty-File Handling" option in sender file CC to avoid processing empty files by PI.
    Hope this helps,
    Greg

  • PI Java Mapping NullPointerException

    Hi Gurus,
    I'm having some troubles doing the mapping through java mapping in PI.
    I've done the java class in the SAP NWDS and imported it on PI through the ESR.
    Now i'm trying to test through the SOAP and i've found the following error in the "Communication Channel Monitor":
    500   Internal Server Error  SAP NetWeaver Application Server/Java AS 
    java.lang.NullPointerException: while trying to invoke the method com.sap.aii.af.sdk.xi.lang.Binary.getBytes() of a null object returned from com.sap.aii.af.sdk.xi.mo.xmb.XMBPayload.getContent()
    And the following error in the SXMB_MONI:
    <SAP:Category>XIServer</SAP:Category>
      <SAP:Code area="INTERNAL">CLIENT_SEND_FAILED</SAP:Code>
      <SAP:P1>500</SAP:P1>
      <SAP:P2>Internal Server Error</SAP:P2>
      <SAP:P3>(See attachment HTMLError for details)</SAP:P3>
      <SAP:P4 />
      <SAP:AdditionalText />
      <SAP:Stack>Error while sending by HTTP (error code: 500 , error text: Internal Server Error) (See attachment HTMLError for details)</SAP:Stack>
    I've developed the code below:
    public class PI_Mapping_IF extends AbstractTransformation {
      public void transform(TransformationInput in, TransformationOutput out)    throws StreamTransformationException  {  
      this.execute(in.getInputPayload().getInputStream(), out.getOutputPayload().getOutputStream()); 
      public void execute(InputStream in, OutputStream out)  throws StreamTransformationException { 
      try  
      // Inicio do java mapping
      getTrace().addInfo("JAVA Mapping Iniciado"); //Log para o PI/XI
      // Declarações referentes ao XML de entrada
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document xml_in = db.parse(in);
      // Declarações referentes ao XML de saída
      Document xml_out = db.newDocument();
      TransformerFactory transformerFactory = TransformerFactory.newInstance();
      Transformer transformer = transformerFactory.newTransformer();
      // Remove o standalone
      xml_in.setXmlStandalone(true);
      // Declara a estrutura que a RFC irá receber
      Element root = xml_out.createElement("ns1:ZFSD_VMOI_UPLOAD_CF_PG");
      root.setAttribute("xmlns:ns1","urn:sap-com:document:sap:rfc:functions");
      xml_out.appendChild(root);
      Element i_cenario = xml_out.createElement("I_CENARIO");
      root.appendChild(i_cenario);
      Element t_input = xml_out.createElement("T_INPUT");
      root.appendChild(t_input);
      Element item = xml_out.createElement("ITEM");
      t_input.appendChild(item);
      Element STRING = xml_out.createElement("STRING");
      item.appendChild(STRING);
      Element t_return = xml_out.createElement("T_RETURN");
      root.appendChild(t_return);
      Element item_r = xml_out.createElement("ITEM");
      t_return.appendChild(item_r);
      Element message = xml_out.createElement("MESSAGE");
      item_r.appendChild(message);
      // Verifica se existe algum filho no nó
      NodeList nodos = xml_in.getChildNodes(); 
      if (nodos.item(0) != null)
      getTrace().addInfo("O nó(XML) possui filhos"); //Log para o PI/XI
      // Declaração de variáveis
      String ident = ""; // <Ident>
      String buyer = ""; // <BuyerLineItemNum>
      String result = ""; // <Ident>;<BuyerLineItemNum>;<Date>;<QuantityValue>
      // Inicia a extração das informações do XML
      try{
      // Recupera o nó ShipToParty
      NodeList nodeShip = xml_in.getElementsByTagName("ns0:ShipToParty");
      Node node = nodeShip.item(0);
      Element elemXML = (Element) node;
      try{
      NodeList nodeIdent = elemXML.getElementsByTagName("ns0:Ident");
      Element nameElement = (Element) nodeIdent.item(0);
      nodeIdent = nameElement.getChildNodes();
      // Recupera o valor da chave <Ident>
      ident = PI_Mapping_IF.VerifyNull(((Node) nodeIdent.item(0)).getNodeValue());
      }catch(Exception e){
      result += "0.0;";
      // Recupera o nó ListOfMaterialGroupedPlanningDetail
      NodeList nodeBuyer  = xml_in.getElementsByTagName("ns0:MaterialGroupedPlanningDetail");
      for (int i = 0; i < nodeBuyer.getLength(); i++) {
      node = nodeBuyer.item(i);
      elemXML = (Element) node;
      try{
      // Preenche a chave BuyerLineItemNum
      NodeList nodeBuyerLine = elemXML.getElementsByTagName("ns0:BuyerLineItemNum");
      Element elemBuyerLine = (Element) nodeBuyerLine.item(0);
      nodeBuyerLine = elemBuyerLine.getChildNodes();
      buyer = PI_Mapping_IF.VerifyNull(((Node) nodeBuyerLine.item(0)).getNodeValue());
      }catch(Exception e){
      buyer += "0;";
      result = ident+";"+buyer+";";
      Node nodeDt_Qnt = nodeBuyer.item(i);
      Element elemDt_Qnt = (Element)nodeDt_Qnt;
      NodeList nodeValores = elemDt_Qnt.getElementsByTagName("ns0:ScheduleDetail");
      for (int j = 0; j < nodeValores.getLength(); j++) {
      node = nodeValores.item(j);
      elemXML = (Element) node;
      try{
      // Preenche a chave Date
      NodeList modelExtra = elemXML.getElementsByTagName("ns0:Date");
      Element extraElement = (Element) modelExtra.item(0);
      modelExtra = extraElement.getChildNodes();
      result += PI_Mapping_IF.VerifyNull(((Node) modelExtra.item(0)).getNodeValue())+";";
      }catch(Exception e){
      result += "//;";
      try {
      // Preenche a chave QuantityValue
      NodeList modelURL = elemXML.getElementsByTagName("ns0:QuantityValue");
      Element urlElement = (Element) modelURL.item(0);
      modelURL = urlElement.getChildNodes();
      result += PI_Mapping_IF.VerifyNull(((Node) modelURL.item(0)).getNodeValue())+";";
      } catch (Exception e) {
      result += "0.0;";
      // Marca o final do registro
      result += "||";
      // Preenche os nós itens
      Text srcxml = xml_out.createTextNode(result);
      STRING.appendChild(srcxml);
      result = "";
      buyer = "";
      }catch(Exception e){
      // Remove o standalone
      xml_out.setXmlStandalone(true);
      // Preenche o Cenario
      Text cenario = xml_out.createTextNode("P&G");
      i_cenario.appendChild(cenario);
      // Preenche mensagem de retorno
      Text msgxml = xml_out.createTextNode("XML lido com sucesso!");
      message.appendChild(msgxml);
      // Escreve a saida do XML            
      transformer.transform(new DOMSource(xml_out), new StreamResult(out));
      getTrace().addInfo("Fim da execução do Java Mapping");
      } catch (ParserConfigurationException e) {
      getTrace().addWarning(e.getMessage());
      throw new StreamTransformationException("Can not create DocumentBuilder.", e);
      } catch (SAXException e) {
      e.printStackTrace();
      } catch (IOException e) {
      e.printStackTrace();
      } catch (TransformerConfigurationException e) {
      e.printStackTrace();
      } catch (TransformerException e) {
      e.printStackTrace();
    Am i doing anything wrong in the code? Where can this nullpointerexception be triggered?
    Thanks.

    These three xml are the same:
    <?xml version="1.0"?><a:xml xmlns:a="urn:123">root</a:xml>
    <?xml version="1.0"?><xml xmlns="urn:123">root</xml>
    <?xml version="1.0"?><ns0:xml xmlns:ns0="urn:123">root</ns0:xml>
    But your code will work only with last one, because it doesn't bound namespace to prefix ns0.

  • DAC ERROR EXCEPTION CLASS::: java.lang.NullPointerException

    hello guru,
    when i creating a execution plan in my local envt for testing
    I have assemble the subject area
    but while building the execution plan i am getting below error:
    SHTEST-TEST
    EXCEPTION CLASS::: java.lang.NullPointerException
    com.siebel.analytics.etl.execution.ExecutionParameterHelper.substituteNodeTables(ExecutionParameterHelper.java:174)
    com.siebel.analytics.etl.execution.ExecutionParameterHelper.parameterizeTask(ExecutionParameterHelper.java:141)
    com.siebel.analytics.etl.execution.ExecutionPlanDesigner.getExecutionPlanTasks(ExecutionPlanDesigner.java:738)
    com.siebel.analytics.etl.execution.ExecutionPlanDesigner.design(ExecutionPlanDesigner.java:1267)
    com.siebel.analytics.etl.client.util.tables.DefnBuildHelper.calculate(DefnBuildHelper.java:169)
    com.siebel.analytics.etl.client.util.tables.DefnBuildHelper.calculate(DefnBuildHelper.java:119)
    com.siebel.analytics.etl.client.view.table.EtlDefnTable.doOperation(EtlDefnTable.java:169)
    com.siebel.etl.gui.view.dialogs.WaitDialog.doOperation(WaitDialog.java:53)
    com.siebel.etl.gui.view.dialogs.WaitDialog$WorkerThread.run(WaitDialog.java:85)
    can anyone help on this.
    thanks

    Hello Shiva,
    I have tried to generate the paramenter index in going into execute tab.
    Acutally I have two database one is SH(for sales fact table) as source and other is SHTST (for target w_sales_F).
    when i go into that it try to click on generate button it shows only for SHTST not for SH
    more over in SHTST the value is coming as Informatica folder Sales where i created all mapping.
    SH and SHTST both are in same database oracle 10g.
    please help

Maybe you are looking for