on 06-18-2015 4:03 AM
Hi,
For this File to File scenario java coding is working fine while executing it in command prompt.
But when the jar file or zip file is imported in Imported Archives i get below error "Unable to display class; byte code format invalid"
I have tried with below two command in cmd for generating jar file.
jar cfm FiletoFile.jar manifest.txt FiletoFile.class
jar -cf FiletoFile.jar FiletoFile.class
Attached java code.
Please guide me to resolve this issue.
Thanks & Regards,
Vinoth
Hi Vinoth,
Did you attach your jar file which is having both java file and class file into your imported archive in PI.
Also, make sure that you have compiled the java file with the jdk version less than or equal to your PI jdk version.
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vishnu,
Thanks for your reply.
Yes. Jar file having both java and class. When i double click the class again it is throwing "Unable to display class; byte code format invalid"
Java file is visible:
And i have compiled it jdk 1.6 wherein PI jdk is 1.4
Error message while testing:
Thanks & Regards,
Vinoth
Hi Vishnu,
Thanks for your reply.
Now i have compiled the java code in PI jdk version(1.4.2_19).
While testing the code below error occurred.
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
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.Node;
import org.w3c.dom.NodeList;
public class FiletoFile {
public static void main(String[] args) {
//created a DOM class
FiletoFile domParse=new FiletoFile();
try
{
//FileInputStream in = new FileInputStream("C:\\H_Back\\Java\\send/input.xml");
// FileOutputStream out = new FileOutputStream("C:\\H_Back\\Java\\receive/output.xml");
//domParse.execute(in, out);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void execute(InputStream in, OutputStream out)
{
try{
String fullName="";
/* transforms source to destination object*/
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
/*creates new instance of parser*/
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
//ignore whitespace within document
factory.setIgnoringElementContentWhitespace(true);
//parser is aware of namespace
factory.setNamespaceAware(true);
DocumentBuilder builderel=factory.newDocumentBuilder();
/*input document in form of XML*/
Document docIn=builderel.parse(in);
Node temp,x,root,text;
NodeList l;
//get all nodes with specific tag
l=docIn.getElementsByTagName("name");
for(int i=0;i<l.getLength();++i)
{
//get the root element
root=l.item(i);
for(temp=root.getFirstChild();temp!=null;temp=temp.getNextSibling())
{
//find the tag with name country
if(temp.getNodeName().equals("country"))
{
if(temp.getFirstChild().getNodeValue().equalsIgnoreCase("India"))
{
Node p;
fullName="";
//get firstname
p=temp.getParentNode();
p=p.getFirstChild();
if(p.getFirstChild()!=null)
{
fullName=p.getFirstChild().getNodeValue()+" ";
}
//get lastname
p=p.getNextSibling();
//create full name
if(p.getFirstChild()!=null)
{
fullName+=p.getFirstChild().getNodeValue();
}
//create element fullname
x=docIn.createElement("fullname");
text=docIn.createTextNode(fullName);
x.appendChild(text);
//append it to root element "employee"
root.getParentNode().appendChild(x);
}
}
}
}
//now traversing the tree the children of root "employee" from right to left
for(temp=docIn.getElementsByTagName("employee").item(0).getLastChild();temp!=null;)
{
//delete all nodes with name "name"
if(temp.getNodeName().equals("name"))
{
x=temp.getPreviousSibling();
temp.getParentNode().removeChild(temp);
temp=x;
//normalize structure after deletion
docIn.normalize();
}
else
{
temp=temp.getPreviousSibling();
}
}
//creating target xml
transform.transform(new DOMSource(docIn), new StreamResult(out));
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void setParameter(Map arg0) {
}
}
Thanks & Regards,
Vinoth
Hi Vinoth,
You need to use PI mapping jar file as it is mandate that every java code which will be written in PI should extend the class StreamTransformation for PI <7.1 or AbstractTransformation for PI>=7.1
Please find below sample java mapping code written in SCN Wiki:
Sample JAVA Mapping code using PI 7.1 API - Process Integration - SCN Wiki
Please use this as reference and accordingly adjust your java code.
Regards
Vishnu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vinoth,
The problem could be in your java version. Download java 1.5 and if you don't want to download the NWDS, at least you can get eclipse and to generate the .class and the jar from there.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.