cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA mapping error

Former Member
0 Kudos

Hi All,

I am getting the below error while executing a JAVA mapping.

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

<SAP:Category>Application</SAP:Category>

<SAP:Code area="MAPPING">LINKAGE_ERROR</SAP:Code>

<SAP:P1>XMLNSTagCreate1/XMLNSTagCreate1</SAP:P1>

<SAP:P2>java.lang.NoClassDefFoundError: XMLNSTagCreate1/XM</SAP:P2>

<SAP:P3>LNSTagCreate1 (wrong name: XMLNSTagCreate1)</SAP:P3>

<SAP:P4 />

<SAP:AdditionalText />

<SAP:Stack>Linkage error while loading class XMLNSTagCreate1/XMLNSTagCreate1; java.lang.NoClassDefFoundError: XMLNSTagCreate1/XMLNSTagCreate1 (wrong name: XMLNSTagCreate1)</SAP:Stack>

<SAP:Retry>M</SAP:Retry>

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

I have tried compiling the code in the same JRE as the one in PI. Still it is not working.

Please suggest.

Regards,

Yashwanth

Edited by: YashwanthSVK on Aug 17, 2011 8:38 PM

Accepted Solutions (1)

Accepted Solutions (1)

VijayKonam
Active Contributor
0 Kudos

Does your target contains such an element? XMLNSTagCreate1/XMLNSTagCreate1?

Looks like Java is complaining about the class related to this name is not present. Are you not using XML DOM or some other supported parser to create the XML?

VJ

Former Member
0 Kudos

Hi all... thank you for the replies.. I have compiled the code in the same version of JRE as the PI version...

Hi Vijay,

I also felt the same but as I do not have much knowledge in JAVA, i could not track it further.

below is the code for the mapping... would you mind if I ask you to have a look at it and let me know where the error is..

thank you so much ...

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

import java.io.*;

import java.util.Map;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.parsers.ParserConfigurationException;

import javax.xml.transform.TransformerFactory;

import org.w3c.dom.Element;

import org.w3c.dom.NamedNodeMap;

import org.xml.sax.SAXException;

import org.xml.sax.helpers.DefaultHandler;

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

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

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

import javax.xml.transform.OutputKeys;

import javax.xml.transform.TransformerConfigurationException;

import javax.xml.transform.TransformerException;

import javax.xml.transform.TransformerFactoryConfigurationError;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import java.io.FileWriter;

/**

  • This mapping creates xmlns attribute to send to Tradeplace

*/

public class XMLNSTagCreate1 extends DefaultHandler implements StreamTransformation {

private Map param;

private MappingTrace trace;

private OutputStream out;

public void execute(InputStream in, OutputStream out)

throws StreamTransformationException {

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();

try {

//trace.addWarning("Execute function starts here");

DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

try {

org.w3c.dom.Document doc = docBuilder.parse(in);

//Node TradeplaceMessage = doc.getFirstChild();

Element trade=(Element) doc.getFirstChild();

if(trade.hasAttribute("tag1"))

{

NamedNodeMap TradeplaceMessageAttributes = trade.getAttributes();

String xmlnsValue=trade.getAttribute("tag1");

String modeValue=trade.getAttribute("productionMode");

trace.addInfo("XMLNS Value:"+xmlnsValue);

trade.removeAttribute("tag1");

trade.removeAttribute("productionMode");

trade.setAttribute("xmlns",xmlnsValue);

trade.setAttribute("productionMode",modeValue);

}

javax.xml.transform.Transformer transformer = TransformerFactory.newInstance().newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");

StreamResult result = new StreamResult(new StringWriter());

DOMSource source = new DOMSource(doc);

transformer.transform(source, result);

String xmlString = result.getWriter().toString();

//System.out.println(xmlString);

out.write(xmlString.getBytes());

} catch (SAXException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (IOException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (TransformerConfigurationException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (TransformerFactoryConfigurationError e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (TransformerException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

} catch (ParserConfigurationException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

public static void main2(String[] args) throws Exception {

String xmlFile = "U:
Untitled.xml";

InputStream in = new BufferedInputStream(new FileInputStream(xmlFile));

XMLNSTagCreate1 test = new XMLNSTagCreate1();

//test.countOccurences(in);

}

public static void main(String[] args) throws Exception {

String xmlFile = "//NA.AD.WHIRLPOOL.COM//myApps//home//NA//qqjos1d//My Documents//TP2.xml";

InputStream in = new BufferedInputStream(new FileInputStream(xmlFile));

FileOutputStream out = new FileOutputStream("//NA.AD.WHIRLPOOL.COM//myApps//home//NA//qqjos1d//My Documents//DhanishTP2.xml");

XMLNSTagCreate1 test = new XMLNSTagCreate1();

test.execute(in, out);

OutputStreamWriter out1 = new OutputStreamWriter(out,"UTF-8");

}

/* (non-Javadoc)

  • @see com.sap.aii.mapping.api.StreamTransformation#setParameter(java.util.Map)

*/

public void setParameter(Map param) {

// TODO Auto-generated method stub

}

}

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Why do you have two main methods? only one main is allowed . Also make sure you close the curly braces accordingly. Do you see any compiler errors? Abhishek's error notification can be resolved at compiler level itself.

Answers (7)

Answers (7)

former_member192851
Active Participant
0 Kudos

Check what Ryan Crosby said.

How are you deploying the class file in the ESR?

I think problem is in jar file, that you export from your development environment.

Check your Imported Archive and path in it.

Redeploy class file.

Former Member
0 Kudos

The problem got solved. The error was that the class and the JAVA files were put in a folder and the folder was zipped. Hence the error.

The files together were zipped without the folder and it worked fine.

Thank you all for your replies.

Yash

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Yashwanth,

There are no errors in the above Java code. Please compile it with JDK1.4 (it compiled successfully for me). Please follow the 3rd screenshot in this [Link|http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-with-j2se50.htm], there select JDK 1.4.

Regards,

Raghu_Vamsee

Ryan-Crosby
Active Contributor
0 Kudos

Hi Yashwanth,

How are you deploying the class file in the ESR? The error you are getting is indicating that the expected compiled .class file cannot be found and thus cannot be executed at runtime. In your namespace definition you should look for an object under imported archives that contains your .class file. This file should be named XMLNSTagCreate1.class

Regards,

Ryan

former_member200962
Active Contributor
0 Kudos

it does not seem like a JRE issue neither a tag-name issue.....you seem to have a class by the name XMLNSTagCreate1 which the compiler is not able to find (or more like you are referencing class in a wrong way).

public class XMLNSTagCreate1 extends DefaultHandler implements StreamTransformation {
.
.
XMLNSTagCreate1 test = new XMLNSTagCreate1();
.
.
XMLNSTagCreate1 test = new XMLNSTagCreate1();
}

You sure that above statements are correct??

RaghuVamseedhar
Active Contributor
0 Kudos

Hi Yashwanth,

Compile with JDK 1.4, it should work.

If your Java Mapping is using JDK 1.5 classes, compile with lower release than PI JRE.

Regards,

Raghu_Vamsee

Former Member
0 Kudos

looks JRE version issue:

former_member181962
Active Contributor
0 Kudos

Hi Yashwant,

Check the java version of your JRE vs the java version that your PI system uses. They might be different.

Best Regards,

Ravi