cancel
Showing results for 
Search instead for 
Did you mean: 

JavaMapping Error

0 Kudos

Hi all,

I’m testing JavaMapping using the code from this blog: /people/ravikumar.allampallam/blog/2005/06/24/convert-any-flat-file-to-any-idoc-java-mapping

I’ve created two data types (DT_row and MRI_ABSTRACT) and the corresponding Message Interfaces structured as in the example. And I’ve created jar file MMapping.jar with the code in the weblog and imported into XI. Now I’m testing the mapping program in the interface mapping test tab and I’m getting the following error:

======================================================

13:37:37 Start of test

Creating Java mapping com/guarneri/xi/javamap/MRIGenToHierMap

Loaded class com.guarneri.xi.javamap.MRIGenToHierMap

java.lang.IllegalAccessExceptionat JavaMapping.instantiate(): Could not instantiate class: com/guarneri/xi/javamap/MRIGenToHierMapClass com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping can not access a member of class com.guarneri.xi.javamap.MRIGenToHierMap with modifiers ""

13:37:38 End of test

======================================================

I think the problem is something related to classpath or similar, but I can’t find the solution.

Can anybody help me?

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

That drove me almost crazy:

Here:

//Specify the Hirearchial Structure
class MRIGenToHierMap implements StreamTransformation
{

This must be PUBLIC

<b>public class MRIGenToHierMap implements StreamTransformation</b>

Change your code according to this, that should work.

Have a nice week end

Stefan

0 Kudos

Wow!! It was difficult !! That worked fine. Somebody should tell Ravikumar Allampallam that the example is wrong. Thanks to everybody. Especially RAJEEV GUPTA.

Thanks Stefan!

Former Member
0 Kudos

Hi,

give public attribute to each of your 3 classes......in Relation class also give :

public class Relation

Thanks,

Rajeev Gupta

Former Member
0 Kudos

Hi,

Cheers...........:))))))))))))))))))

Thanks,

Rajeev Gupta

stefan_grube
Active Contributor
0 Kudos

That is not necessary, as classes can use other classes of the same package anyway.

Only MRIGenToHierMap needs to be public.

Regards

Stefan

stefan_grube
Active Contributor
0 Kudos

> Somebody should tell Ravikumar Allampallam that the example is wrong.

Done.

Feel free to add any comments to Weblogs by your own.

Regads

Stefan

Answers (4)

Answers (4)

stefan_grube
Active Contributor
0 Kudos

deleted

Message was edited by:

Stefan Grube

0 Kudos

So how do I have to modify the code?

Former Member
0 Kudos

Hi,

remove the MRIGenToHierMap rel = new MRIGenToHierMap(); line from MRIGenToHierMap.java execute function. remove the rel object from this function..test it in NWDS......when its okay, then import its jar file in XI.....

Thanks,

Rajeev Gupta

0 Kudos

I've changed the method as follows:

public void execute(InputStream in, OutputStream out) throws com.sap.aii.mapping.api.StreamTransformationException

{

//MRIGenToHierMap rel = new MRIGenToHierMap();

//MRIGenToHierMap rel = this;

//rel.buildXsd();

this.buildXsd();

new GenToHierMap(in,out,this.v,"MRI_ABSTRACT","urn:horzon:MRI");

}

but the problem persists....

Former Member
0 Kudos

Hi,

just replace

new GenToHierMap(in,out,this.v,"MRI_ABSTRACT","urn:horzon:MRI");

with

new GenToHierMap(in,out,this.v,"MRI_ABSTRACT",<x>);

Where <x> is your target namespace means the namespace in which you have defined your scenario in IR........Change code in NWDS.......Test it....the output should come with your namespace in NWDS......generate its jar.....import in archive.........edit interface mapping......reslect the java class.......save mapping and activate it.....then test the mapping..........

Thanks,

Rajeev Gupta

prabhu_s2
Active Contributor
0 Kudos

For testing the java mapping standalone main method is used. For runtime this is not req in all the java files. Test it by removing the main method.

0 Kudos

Hi,

I've commented the main method, export the jar file and imported into XI. What I see in my Imported Archives is:

Name......................................... Path

GenToHierMap.class....................(nothing)

GenToHierMap.java......................(nothing)

MRIGenToHierMap.class..............(nothing)

MRIGenToHierMap.java................(nothing)

Relation.class.............................(nothing)

Relation.java...............................(nothing)

default.txvpck..............................MMaping/

But the test fails again.

I have the file in this location: aii_map_api.jar

/usr/sap/XID/DVEBMGS90/j2ee/cluster/server0/apps/sap.com/com.sap.xi.services

Best Regards,

Roger Allué Vall

Former Member
0 Kudos

Hi,

just now open a new Java prj..........create a package in it.....in this package add all your 3 java files......compile it...........

create jar file....open in winzip except following:

GenToHierMap.class

GenToHierMap.java

MRIGenToHierMap.class)

MRIGenToHierMap.java

Relation.class

Relation.java

delete any other file from it.

import in archive in XI......see the package path will come in path instead of nothing....activate archive........

then test interface mapping .........

Thanks,

Rajeev Gupta

prabhu_s2
Active Contributor
0 Kudos

there shud be a path seen...hope u had selected the java class of the coresponding mapping prgm.

if still the issue persist just for a refe u can view this

though not much relavant chec this also

are u able to access RWB, exchange profile etc? jsut to check if error of this kind is throwing up

0 Kudos

Do I have to include the main method or not?

Best regards!

Roger Allué Vall

prabhu_s2
Active Contributor
0 Kudos

not req

Former Member
0 Kudos

Hi,

You can comment the main method in all the java files.

Thanks,

Rajeev Gupta

0 Kudos

Ok, I've created a new project JavaMapping, I've created the package javaMapping and included my 3 java files on it. I've compiled and exported to a jar file. Then I imported it into XI as and Imported Archive:

GenToHierMap.class javaMapping/

GenToHierMap.java javaMapping/

MRIGenToHierMap.class javaMapping/

MRIGenToHierMap.java javaMapping/

Relation.class javaMapping/

but the test stills giving:

15:55:23 Start of test

Creating Java mapping javaMapping/MRIGenToHierMap

Loaded class javaMapping.MRIGenToHierMap

java.lang.IllegalAccessExceptionat JavaMapping.instantiate(): Could not instantiate class: javaMapping/MRIGenToHierMapClass com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping can not access a member of class javaMapping.MRIGenToHierMap with modifiers ""

15:55:23 End of test

Best Regards.

Former Member
0 Kudos

Hi,

just to check again........put the main function in MRIGenToHierMap.java file in NWDS JAVA PRJ..............test this java file.......with the input XML of blog...Does output of blog comes.........

have you activated your imported archive again....

while testing mapping, are you giving the same source XML file of blog or not...

Can you also tell what data you have specified in your interface mapping...

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

prabhu_s2
Active Contributor
0 Kudos

also try to have this aii_util_xml.jar file also in NWDS

prabhu_s2
Active Contributor
0 Kudos

is the calss MRIGenToHierMap selected in IM?

0 Kudos

I've included all the classes in the package: com.sap.javaMapping. I've uncommented the main method and I've executed the function in NWDS again with the same xml file that I use in the test. It worked fine.

All my objects in XI are active in every test I make and every time I import a new jar. I have this files as External JARs in NWDS:

C:aii_map_api.jar

C:aii_util_xml.jar

In my interface mapping I've defined the following:

Source Interface: MI_row_outbound

Target Interface: MI_MRI_ABSTRACT_inbound

Mapping Program: Java Class --> com/sap/javaMapping/MRIGenToHierMap --> javaMapping

Regards,

Roger allué Vall

Former Member
0 Kudos

Hi,

just copy-paste your Source XML of testing of IM........

Thanks,

Rajeev Gupta

prabhu_s2
Active Contributor
0 Kudos

are u able to test the mapping by taking the xml file?

0 Kudos

<?xml version="1.0" encoding="UTF-8" ?>

<ns3:DT_row xmlns:ns3="http://gencat.cat/ics/compresLogistica">

<recordset>

<DATA>

<ROW>"A00"#!1#!2#!3#!4#!5#!6</ROW>

<ROW>"U06"#!1#!2#!3#!4#!5#!6#!7</ROW>

<ROW>"K15"#!1#!2#!3#!4</ROW>

<ROW>"N90"#!1#!2#!3#!4#!5#!6#!8#!9#!10#!11#!12#!13#!14#!15#!16#!17</ROW>

<ROW>"K15"#!1#!2#!3#!4#!5</ROW>

</DATA>

</recordset>

</ns3:DT_row>

0 Kudos

I'm able to test the mapping from NWDS using this input xml file:

<?xml version="1.0" encoding="UTF-8" ?>

<ns3:DT_row xmlns:ns3="http://gencat.cat/ics/compresLogistica">

<recordset>

<DATA>

<ROW>"A00"#!1#!2#!3#!4#!5#!6</ROW>

<ROW>"U06"#!1#!2#!3#!4#!5#!6#!7</ROW>

<ROW>"K15"#!1#!2#!3#!4</ROW>

<ROW>"N90"#!1#!2#!3#!4#!5#!6#!8#!9#!10#!11#!12#!13#!14#!15#!16#!17</ROW>

<ROW>"K15"#!1#!2#!3#!4#!5</ROW>

</DATA>

</recordset>

</ns3:DT_row>

Bet Regards,

prabhu_s2
Active Contributor
0 Kudos

okie seems there is problem with #. the separator is comma and the text(strings) are encodede with doubel quotes but not numerics

Message was edited by:

Prabhu S

0 Kudos

I've changed the code because I want the separator to be: #!

Best regards!

prabhu_s2
Active Contributor
0 Kudos

i fear it might have some issue...just try a comma separator and execute the program....might u need to change the code. we can figure out if this is causing the issue

<?xml version="1.0" encoding="UTF-8" ?>

<ns3:DT_row xmlns:ns3="http://gencat.cat/ics/compresLogistica">

<recordset>

<DATA>

<ROW>"A00",1,2,3,4,5,6</ROW>

<ROW>"U06",1,2,3,4,5,6,7</ROW>

<ROW>"K15",1,2,3,4</ROW>

<ROW>"N90",1,2,3,4,5,6,8,9,10,11,12,13,14,15,16,17</ROW>

<ROW>"K15",1,2,3,4,5</ROW>

</DATA>

</recordset>

</ns3:DT_row>

Former Member
0 Kudos

Hi,

Just edit your interface mapping..........go to java mapping.......again select the MRIGenToHierMap class file.......activate the mapping and again test the mapping.....

Thanks,

Rajeev Gupta

0 Kudos

I've changed the code to use comma as separator but It still goes wrong...

Former Member
0 Kudos

Hi,

Have you put all the 3 java files in your .jar file....... Have you activated your imported archives java mapping..........

Thanks,

Rajeev Gupta

0 Kudos

I've imported aii_map_api.jar and aii_util_xml.jar to the project as External JARs. The exported jar file (MMapping.jar) do not contain neither aii_map_api.jar nor aii_util_xml.jar. Do I have to include them in my jar? I think I read something in a post that this is not necessary because the jar files aii_map_api.jar and aii_util_xml.jar are in the server.

All my modifications in XI are activated.

Thanks in advance.

Roger Allué Vall

prabhu_s2
Active Contributor
0 Kudos

The content of the jar file have to be all classes and libraries you need for the mapping program to run and which are not part of the J2EE installation.

You need not bind the libraries aii_map_api.jar and inqmyxml.jar (for ex), as they are part of the standard J2EE installation.

prabhu_s2
Active Contributor
0 Kudos

<i>All the 3 files have to be kept in the same directory and the generic java files should be compiled</i>

Former Member
0 Kudos

Hi,

just to check - in your java prj where you created these 3 java files and compiled them, then on giving an input to MRIGenToHierMap class by executing its main function and giving the source XML file as in the blog - does the target XML as in the blog was output.

when you imported your .jar file in imported archives, can you see the name of all the 3 java files and their classes in imported archive.

If both of the above things are there, then in interface mapping, the JAVA prg you have said is MRIGenToHierMap or not.

If all of the above things are there, then giving the sourc XML file of blog in test of interface mapping, you should get the target XML of blog.

Thanks,

Rajeev Gupta

0 Kudos

Ok, so as I understand I need aii_map_api.jar, aii_util_xml.jar and which is the other one?

all these files must be in the same directory as my classes?

Thank you in advance!

Former Member
0 Kudos

Hi,

you need aii_map_api.jar for java mapping.......

just create a package for your java prj.........

in this package, then create all the 3 java files of the blog.........

run MRIGenToHierMap class to test the mapping......

Thanks,

Rajeev Gupta

Former Member
0 Kudos

By 3 files, Ravikumar (the author of the blog)means the 3 java files....

Regards,

Jai Shankar

prabhu_s2
Active Contributor
0 Kudos

when u create a mapping program in the editor u whud shud have imported these jar files(aii_map_api.jar etc). once u are finished with the mapping all u need is to create a jar file with all the three files(as in blog) specified in the same location,

<b>Ok, so as I understand I need aii_map_api.jar, aii_util_xml.jar and which is the other one?</b>

You find these files in the file system of the J2EE engine, where your XI is running (see note 636447). not req to again have this is the jar file which u will be creating and exporting into the IR

0 Kudos

I tried it and works fine. But when I import it to XI it doesn't work. How can I include this jar files into my jar file in the SAP NetWeaver Developer Studio?

Best Regards.

Former Member
0 Kudos

Hi,

so in NWDS it works fine.......good

now how are you creating the jar file.....select your java project..go to file -> export .....choose jar file..choose the options of export sourc files and generated classes..create your jar file with all the 3 source files and their classes......

now import this jar file in XI.........can you see all the 3 java files and its classes in the imported archive...........

now test your Interface Mapping........

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

0 Kudos

Ok,

I've recreated the project, included the files in my jar file and imported it into XI. What I see in Imported Archive is this:

Name......................................... Path

GenToHierMap.class....................(nothing)

GenToHierMap.java......................(nothing)

MRIGenToHierMap.class..............(nothing)

MRIGenToHierMap.java................(nothing)

Relation.class.............................(nothing)

Relation.java...............................(nothing)

.classpath..................................(nothing)

.project......................................(nothing)

aii_map_api.jar...........................(nothing)

aii_util_xml.jar............................(nothing)

And I'm still getting:

14:40:38 Start of test

Creating Java mapping MRIGenToHierMap

Loaded class MRIGenToHierMap

java.lang.IllegalAccessExceptionat JavaMapping.instantiate(): Could not instantiate class: MRIGenToHierMapClass com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping can not access a member of class MRIGenToHierMap with modifiers ""

14:40:39 End of test

Best regards,

Roger Allué Vall

Former Member
0 Kudos

Hi,

open your jar file with winzip.

delete following:

.classpath

.project

aii_map_api.jar

aii_util_xml.jar

from the jar file.

again import the jar file in XI.

Now activate the imported archive.

now test the interface mapping.

Thanks,

Rajeev Gupta

Message was edited by:

RAJEEV GUPTA

prabhu_s2
Active Contributor
0 Kudos

are u having the method <i><b>public void execute</b></i>?...just a check as when u are testing in NWDS u would have commented it

Message was edited by:

Prabhu S

0 Kudos

So, what I have to Include in my jar file? Only my classes and if I want java files? That's what I had at the beginning of the post. An this is not working properly.

Now I have a jar file MMApping.jar that contains the following files:

META-INF

MRIGenToHierMap.class

MRIGenToHierMap.java

GenToHierMap.class

GenToHierMap.java

Relation.class

Relation.java

But the error persists.

Any idea?

Best regards,

Roger Allué Vall

0 Kudos

Hi Prabhu S,

Yes I have the following as you can see in the weblog:

public void execute(InputStream in, OutputStream out) throws com.sap.aii.mapping.api.StreamTransformationException

{

MRIGenToHierMap rel = new MRIGenToHierMap();

rel.buildXsd();

new GenToHierMap(in,out,rel.v,"MRI_ABSTRACT","urn:horzon:MRI");

}

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

{

try

{

MRIGenToHierMap rel = new MRIGenToHierMap();

FileInputStream in = new FileInputStream ("C:/MMApping/DOM_IN.xml");

FileOutputStream out = new FileOutputStream ("C:/MMApping/DOM_OUT.xml");

rel.buildXsd();

new GenToHierMap(in,out,rel.v,"MRI_ABSTRACT","urn:horzon:MRI");

}catch(Exception e) {e.printStackTrace();}

}

}

Best Regards,

prabhu_s2
Active Contributor
0 Kudos

remove

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

{

try

{

MRIGenToHierMap rel = new MRIGenToHierMap();

FileInputStream in = new FileInputStream ("C:/MMApping/DOM_IN.xml");

FileOutputStream out = new FileOutputStream ("C:/MMApping/DOM_OUT.xml");

rel.buildXsd();

new GenToHierMap(in,out,rel.v,"MRI_ABSTRACT","urn:horzon:MRI");

}catch(Exception e) {e.printStackTrace();}

}

Former Member
0 Kudos

Hi,

go to /usr/sap/<system_name>/<instance_name>/j2ee/cluster/server<number>/apps/sap.com/com.sap.xi.services/ directory of your XI server......

this folder should have the aii_map_api.jar file in it......does it have this file

Thanks,

Rajeev Gupta

stefan_grube
Active Contributor
0 Kudos

> What I see in Imported Archive is this:

>

> Name......................................... Path

> GenToHierMap.class....................(nothing)

> GenToHierMap.java......................(nothing)

> MRIGenToHierMap.class..............(nothing)

> MRIGenToHierMap.java................(nothing)

> Relation.class.............................(nothing)

> Relation.java...............................(nothing)

>

> .classpath..................................(nothing)

>

> .project......................................(nothing

> )

> aii_map_api.jar...........................(nothing)

> aii_util_xml.jar............................(nothing)

Why is path nothing? It must be the package path like com\sap\sample

Do not add the aii_map_api.jar and aii_util_xml.jar. You cannot add a jar into another jar, this wouldn't work.

Regards

Stefan

prabhu_s2
Active Contributor
0 Kudos

when u created the java maaping program did u have the .JAR file imported for java mapping>?

prabhu_s2
Active Contributor
0 Kudos

aii_map_api.jar ?????