cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.UnsupportedClassVersionError by testing java Mapping in PI 1.7

Former Member
0 Kudos

hi,

i get the error "java.lang.UnsupportedClassVersionError" by testing my java mapping in PI 1.7 and i have installed JDK 1.5.

can somebody tell me how i can solve the problem?

Accepted Solutions (0)

Answers (6)

Answers (6)

arthur_fuscella
Participant
0 Kudos

Hello Aziziyan,

If you're using SAP PI 7.1, then you must change your JRE library to 1.5 version.

Go to your NWDS project and changes JRE library.

- Right-Click on your project and select Properties option;

- Java Build Path;

- Click on JRE library then press Edit button;

- Choose appropriate JRE(1.5);

- Recreate your .jar file and then import to PI system.

I faced the same problem and it worked to me.

Regards

Arthur Fuscella

Former Member
0 Kudos

When i use this code, i get the same error.

import java.io.FileInputStream;

import java.io.FileOutputStream;

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

import java.io.*;

import java.util.Map;

import javax.xml.parsers.*;

import org.xml.sax.*;

import org.xml.sax.helpers.*;

/*IMPORT statement imports the specified classes and its methods into the program */

/Every Java mapping program must implement the interface StreamTransformation and its methods execute() and setParameter() and extend the class DefaultHandler./

public class Mapping extends DefaultHandler implements StreamTransformation {

/*

  • Below is the declaration for all the variables we are going to use in the

  • subsequent methods.

*/

private Map map;

private OutputStream out;

private boolean input1 = false;

private boolean input2 = false;

private int number1;

private int number2;

private int addvalue;

private int mulvalue;

private int subvalue;

String lineEnd = System.getProperty("line.separator");

/*

  • setParamater() method is used to store the mapping object in the variable

  • "map"

*/

public void setParameter(Map param) {

map = param;

}

public void execute(InputStream in, OutputStream out)

throws com.sap.aii.mapping.api.StreamTransformationException {

DefaultHandler handler = this;

SAXParserFactory factory = SAXParserFactory.newInstance();

try {

SAXParser saxParser = factory.newSAXParser();

this.out = out;

saxParser.parse(in, handler);

} catch (Throwable t) {

t.printStackTrace();

}

}

/*

  • As seen above execute() method has two parameters "in" of type

  • InputStream and "out" of type OutputStream. First we get a new instance

  • of SAXParserFactory and from this one we create a new Instance of

  • SAXParser. To the Parse Method of SaxParser, we pass two parameters,

  • inputstream "in" and the class variable "handler".

*/

/*

  • Method "write" is a user defined method, which is used to write the

  • string "s" to the outpurstream "out".

*/

private void write(String s) throws SAXException {

try {

out.write(s.getBytes());

out.flush();

} catch (IOException e) {

throw new SAXException("I/O error", e);

}

}

public void startDocument() throws SAXException {

write("");

write(lineEnd);

write("");

write(lineEnd);

}

public void endDocument() throws SAXException {

write("");

try {

out.flush();

} catch (IOException e) {

throw new SAXException("I/O error", e);

}

}

public void startElement(String namespaceURI, String sName, String qName,

Attributes attrs) throws SAXException {

String eName = sName;

if ("".equals(eName))

eName = qName;

if (eName.equals("NUMBER1"))

input1 = true;

if (eName.equals("NUMBER2"))

input2 = true;

}

public void endElement(String namespaceURI, String sName, String qName)

throws SAXException {

String eName = sName;

if ("".equals(eName))

eName = qName;

if (eName.equals("NUMBER1"))

input1 = false;

if (eName.equals("NUMBER2"))

input2 = false;

}

public void characters(char[] chars, int startIndex, int endIndex)

throws SAXException {

String dataString = new String(chars, startIndex, endIndex).trim();

if (input1) {

try {

number1 = Integer.parseInt(dataString);

} catch (NumberFormatException nfe) {

}

}

if (input2) {

number2 = Integer.parseInt(dataString);

}

if (input2 == true) {

addvalue = number1 + number2;

mulvalue = number1 * number2;

subvalue = number1 - number2;

write("" + addvalue + "");

write(lineEnd);

write("" + mulvalue + "");

write(lineEnd);

write("" + subvalue + "");

write(lineEnd);

}

}

}

Former Member
0 Kudos

I get this problem when i test the mapping programm in PI (operation mapping)

Former Member
0 Kudos

Hi Gabriel,

thank you very much!

i have checked the compiler compliance level and it was 6.0. I have changed it and i don`t get the error.

But now i get the error :

"Unable to display tree view; Error when parsing an XML document (Content is not allowed in prolog.)"

This is my java-code:

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

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

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

import java.io.InputStream;

import java.io.OutputStream;

import java.io.PrintWriter;

import java.util.Iterator;

import java.util.Map;

import org.jdom.Document;

import org.jdom.Element;

import org.jdom.input.SAXBuilder;

import javax.xml.transform.*;

public class Mapping2 implements StreamTransformation {

private String party = "";

public void setParameter(Map map) {

party = (String) map.get(StreamTransformationConstants.RECEIVER_PARTY);

}

public void execute(InputStream inputStream, OutputStream outputStream)

throws StreamTransformationException {

try {

SAXBuilder sb = new SAXBuilder();

Document doc = sb.build(inputStream);

PrintWriter out = new PrintWriter(outputStream);

out.print(doc);

out.flush();

out.close();

} catch (Exception e) {

throw new StreamTransformationException(e.getMessage());

}

}

}

I don`t know what is now the problem?

GabrielSagaya
Active Contributor
0 Kudos

check stephen's reply

stefan_grube
Active Contributor
0 Kudos

> I don`t know what is now the problem?

This code is total nonsense.

Do you really think you can write a sax parser with just three lines of code?

You find plenty of exmples in SDn as weblogs or artikel.

Write some good piece of code, then come back.

Former Member
0 Kudos

Hi Gabriel,

i have checked this Link and i am sure that i use JDK 1.5

but i even so get this error.

GabrielSagaya
Active Contributor
0 Kudos

In order to help you with this problem,

Please go to NWDS -> Preferences -> Java ->

Click on "Compiler" and let me know what is the "Compiler compliance level" you have.

It has to be 5.0 because our product is working with 5.0.

The next thing I want you to check is the JDK you have -> Please use the Windows Explorer to go to the folder where is your JDK (for example C:\Program Files\Java) and let me know if you have folders like jdk1.6.0_xx or you have only jdk1.5.0_xx.

Also check this thread

GabrielSagaya
Active Contributor
0 Kudos

Make sure that you use JDK 1.5 and not 1.6 for compiling

Also Please check this wiki

http://wiki.sdn.sap.com/wiki/display/Java/NetWeaverDeveloperStudio+%28NWDS%29