on 03-08-2011 6:28 AM
Hi,
Till PI 7.0 I was able to test the java mapping locally by using main() method, but in PI 7.1
1. cant we do this local testing?
This is my main() method:
public static void main(String args[]) throws Exception
{
FileInputStream inFile = new FileInputStream("C:/SourceFile.txt");
FileOutputStream outFile = new FileOutputStream("C:/OutputFile.xml");
Javamapping xml = new Javamapping();
xml.transform(inFile,outFile);
System.out.println("Success");
}
When I try to test Iam getting the error at line
xml.transform(inFile,outFile);
i.e, typecasting problem from fileinputstream to transformationinput & fileoutputstream to transformationoutput.
How can i test locally?
Hi Kumar,
The transform function takes these two parameters, TransformationInput and TransformationOutput. Not FileInputStream, FileOutputStream.
If you want to test this locally. call a function inside transform which actually has the code logic for which you have opted the java mapping.
Example:
public void transform(TransformationInput Tip,TransformationOutput Top) throws StreamTransformationException
{
try
{
this.start(Tip.getInputPayload().getInputStream(),Top.getOutputPayload().getOutputStream());
}catch(Exception e)
{
System.out.println("error");
}
}
public void start(InputStream in,OutputStream out) throws StreamTransformationException
{
//write your logic here
}
And then inside the stand alone test void main function call this start function
public static void main(String args[]) throws Exception
{
FileInputStream inFile = new FileInputStream("C:/SourceFile.txt";);
FileOutputStream outFile = new FileOutputStream("C:/OutputFile.xml";);
Javamapping xml = new Javamapping();
//xml.transform(inFile,outFile); Instead of this
xml.start(inFile,outFile);
System.out.println("Success");
}
You can try this approach for testing you java mapping locally.
Regards,
Aravind
Edited by: ajnayak on Mar 8, 2011 8:09 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have implemented the logic in
transform(TransformationInput in,TransformationOutput out){
My logic implemented here
}
p s v main()
{
here for locally testing iam reading the data from sourcefile and wrinting the output data to some other file as shown in my main method above. so after taking source and target file path's Iam passing these source and target filestreams to transform() method as shown in above main method so Iam getting error druing this transform method call before going into exact transform method.
}
Hi Kumar,
Yes, by this we will be testing the start method. So you have to put you logic inside the start function. And then call start inside transform.
You cannot convert FileInputstream to TransformationInput or FileOutputStream to TransformationOutput
refer:
http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/TransformationInput.html
http://help.sap.com/javadocs/pi/SP3/xpi/com/sap/aii/mapping/api/TransformationOutput.html
I don't think there will be much changes in the code for you if you follow this. just copy the logic in transform to a new function start. and then call the start in transform.
And then to test locally just call the start function in void main which take FileInputStream and FileOutputStream as parameters.
Regards,
Aravind
Hi Stefen,
when i tried testing by making code similar to what you have mentioned in blog, iam getting the follwoing error
java.lang.SecurityException: class "com.sap.aii.mapping.api.StreamTransformationException"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
Issue solved.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shiva,
This does not appear to be a PI 7.1 problem. Since when we put the java mapping program in XI the main method is not called at all by PI. PI calls the method setparameter and execute. We use main method for local testing in eclipse or NWDS.
Are you able to get proper result when you are running this code in eclipse /NWDS? If you are not getting any errors but you are getting errors when you are deploying it in PI then you can check for proper JRE enviornment.
regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can test even in PI 7.1,same procedure what you have done in PI 7.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.