cancel
Showing results for 
Search instead for 
Did you mean: 

Error while generating parser for determining name of request Error while parsing an XML stream: 'closing '"' expected'

0 Kudos

Dear All,

I had a requirement , where the File should go as an attachment to SAP(ECC). Scenario is File to Proxy.

  For this requirement , used a java mapping.

  But facing the following error

Please let me know , where i am doing the mistake.

Java-map has been attached.

Regards,

Samir

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi,

  Can any one throw some light on this..

thanks in advance,

Irfan

nitindeshpande
Active Contributor
0 Kudos

Hi Irfan,

Can you provide the screenshot of the complete error? I feel the error screenshot mentioned above is not complete.

Regards,

Nitin

0 Kudos

Hi Nitin,

*****************************************************************************************************************************************

<Trace level="1" type="T">*** START APPLICATION TRACE ***</Trace>

<Trace level="3" type="T">Cannot cast class com.sun.org.apache.xerces.internal.dom.DocumentImpl to interface javax.swing.text.Document</Trace>

<Trace level="1" type="T">*** END APPLICATION TRACE ***</Trace>

<Trace level="1" type="T">Java mapping com//addAttachment has thrown a StreamTransformationException. Thrown: com.sap.aii.mapping.api.StreamTransformationException: Cannot cast class com.sun.org.apache.xerces.internal.dom.DocumentImpl to interface javax.swing.text.Document at com.addAttachment.transform(addAttachment.java:63) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:112) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:87) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:71) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:123) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:73) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at sun.reflect.GeneratedMethodAccessor590.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:47) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:50) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:37) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:21) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_MethodRetry.invoke(Interceptors_MethodRetry.java:46) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:191) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:23) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:25) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:17) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:138) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:172) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:99) at com.sun.proxy.$Proxy600.processFunction(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:183) at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run(RFCJCOServer.java:267) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:185) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:302)</Trace>

<Trace level="1" type="T">Application mapping program com/addAttachment throws a stream transformation exception: Cannot cast class com.sun.org.apache.xerces.internal.dom.DocumentImpl to interface javax.swing.text.Document Thrown: com.sap.aii.ib.core.mapping.execution.ApplicationException: Application mapping program com/addAttachment throws a stream transformation exception: Cannot cast class com.sun.org.apache.xerces.internal.dom.DocumentImpl to interface javax.swing.text.Document at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:115) at com.sap.aii.ib.server.mapping.execution.Mapping.execute(Mapping.java:60) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:87) at com.sap.aii.ib.server.mapping.execution.MappingHandler.map(MappingHandler.java:71) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleMappingRequest(MappingRequestHandler.java:123) at com.sap.aii.ibrun.sbeans.mapping.MappingRequestHandler.handleRequest(MappingRequestHandler.java:73) at com.sap.aii.ibrun.sbeans.mapping.MappingServiceImpl.processFunction(MappingServiceImpl.java:79) at sun.reflect.GeneratedMethodAccessor590.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:47) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:50) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:37) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:21) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_MethodRetry.invoke(Interceptors_MethodRetry.java:46) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:191) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:23) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:25) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:17) at com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179) at com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:138) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:172) at com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:99) at com.sun.proxy.$Proxy600.processFunction(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sap.engine.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:183) at com.sap.engine.services.rfcengine.RFCJCOServer$J2EEApplicationRunnable.run(RFCJCOServer.java:267) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:185) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:302) Caused by: com.sap.aii.mapping.api.StreamTransformationException: Cannot cast class com.sun.org.apache.xerces.internal.dom.DocumentImpl to interface javax.swing.text.Document at com.addAttachment.transform(addAttachment.java:63) at com.sap.aii.ib.server.mapping.execution.JavaMapping.executeStep(JavaMapping.java:112) ... 41 more</Trace>

****************************************************************************************************************************************************************************

Regards

former_member182412
Active Contributor
0 Kudos

Hi Shaik,

Based on the error message you used the wrong Document interface in the java mapping, it should be org.w3c.dom.Document not javax.swing.text.Document.


Java mapping com//addAttachment has thrown a StreamTransformationException. Thrown: com.sap.aii.mapping.api.StreamTransformationException: Cannot cast class com.sun.org.apache.xerces.internal.dom.DocumentImpl to interface javax.swing.text.Document at com.addAttachment.transform(addAttachment.java:63)


import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

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;

import org.w3c.dom.Element;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.Attachment;

import com.sap.aii.mapping.api.DynamicConfiguration;

import com.sap.aii.mapping.api.DynamicConfigurationKey;

import com.sap.aii.mapping.api.OutputAttachments;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

Make sure above import statements in your java mapping.

Regards,

Praveen.

former_member182412
Active Contributor
0 Kudos

Hi Shaik,

Use below java mapping, instead of hard coding the target xml in the code, you can use DOM parser to generate the xml.


public class AddAttachmentJavaMap extends AbstractTransformation {

  @Override

  public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput)

  throws StreamTransformationException {

  try {

  DynamicConfiguration conf = transformationInput.getDynamicConfiguration();

  DynamicConfigurationKey FILE_NAME_KEY = DynamicConfigurationKey

  .create("http://sap.com/xi/XI/System/File", "FileName");

  String fileName = conf.get(FILE_NAME_KEY);

  OutputAttachments outputAttachments = transformationOutput.getOutputAttachments();

  InputStream inputStream = transformationInput.getInputPayload().getInputStream();

  byte[] b = new byte[inputStream.available()];

  inputStream.read(b);

  Attachment newAttachment = outputAttachments.create(fileName, "application/excel", b);

  outputAttachments.setAttachment(newAttachment);

  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

  DocumentBuilder builder = factory.newDocumentBuilder();

  factory.setIgnoringElementContentWhitespace(true);

  Document outputDoc = builder.newDocument();

  Element outMsgType = outputDoc.createElement("ns0:MT_Payload");

  outMsgType.setAttribute("xmlns:ns0", "http://test.com/test");

  outputDoc.appendChild(outMsgType);

  Element fileNameElement = outputDoc.createElement("FileName");

  fileNameElement.setTextContent(fileName);

  outMsgType.appendChild(fileNameElement);

  TransformerFactory tFactory = TransformerFactory.newInstance();

  Transformer transformer = tFactory.newTransformer();

  transformer.setOutputProperty("indent", "yes");

  DOMSource source = new DOMSource(outputDoc);

  StreamResult result = new StreamResult(transformationOutput.getOutputPayload().getOutputStream());

  transformer.transform(source, result);

  } catch (Exception e) {

  getTrace().addDebugMessage(e.getMessage());

  throw new StreamTransformationException(e.getMessage());

  }

  }

Regards,

Praveen.

0 Kudos

Apologize for the late reply Praveen,

I had tried with the above code,

  and facing the  following error,

Kindly help.

Regards,

Irfan

Former Member
0 Kudos

            fresult = fresult.concat("<ns0:MT_Payload xmlns:ns0=\"http://test.com/test");

Missing ">" at the end of the line

it should be

            fresult = fresult.concat("<ns0:MT_Payload xmlns:ns0=\"http://test.com/test\">");

0 Kudos

Hi Ganesh,

Thanks for the reply.

Stuck up with another work,so delay in response.

I had changed to    fresult = fresult.concat("<ns0:MT_Payload xmlns:ns0=\"http://test.com/test\">");.

  But now i am facing the following error

Kindly help.

Regards,

Irfan