cancel
Showing results for 
Search instead for 
Did you mean: 

PI 7.1 java mapping

former_member203631
Participant
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

former_member203631
Participant
0 Kudos

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.

}

former_member203631
Participant
0 Kudos

Hi Arvind,

According to your code we are not going to test the transform method locally ri8? instead we are testing using start method.

Former Member
0 Kudos

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

stefan_grube
Active Contributor
0 Kudos

I have done it with a trick:

/people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio

former_member203631
Participant
0 Kudos

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"

stefan_grube
Active Contributor
0 Kudos

what is the purpose of your java mapping?

former_member203631
Participant
0 Kudos

we are getting the xml data + flat file data as a source and we are getting this in single line.. we need to remove the xml header and then convert the flat content into structure xml format which will be an input for GM where exact business logic is implemented.

stefan_grube
Active Contributor
0 Kudos

Do you use any other library besides com.sap.xpi.ib.mapping.lib.jar?

Make sure that all libraries belong to PI 7.1 and eclipse is set to JDK 1.5

former_member203631
Participant
0 Kudos

Thanks

The problem is solved after putting only jar files related to PI 7.1

Answers (3)

Answers (3)

former_member203631
Participant
0 Kudos

Issue solved.

anupam_ghosh2
Active Contributor
0 Kudos

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

former_member203631
Participant
0 Kudos

Hi,

Thanks for your replies. As I said above im getting error only when Im trying to test locally in eclipse. i.e., unable to cast fileinputstream to transforminput and fileoutputstream to transformoutput parameters in transform() method.

rajasekhar_reddy14
Active Contributor
0 Kudos

You can test even in PI 7.1,same procedure what you have done in PI 7.0