cancel
Showing results for 
Search instead for 
Did you mean: 

Exception while perfroming Java mapping in XI

Former Member
0 Kudos

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();

}

}

}

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Rob,

well, your second question kind of answers your first one You are using their implementation of the DOM parser.

What you have to realize is that XI is basically running on top of the WAS. If you want the xml classes just access the filesystem of your WAS installation and look for inqmyxml.jar it can be found in server/additional-lib/ folder.

A vaguely remember having similar problems last year, but can't remember the details. Just try first with just using that library and then post more questions if you can't still figure it out.

Good Luck,

Kalle

Former Member
0 Kudos

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>