cancel
Showing results for 
Search instead for 
Did you mean: 

MDM Java API

Former Member
0 Kudos

HI All,

I am working with webdynpro and MDM java API. I had added the respecive jars and now i want to test whether i am able to make a connection to the MDM server.

Please provide me the sample code.

Thanks,

Jyothi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

I am using the below code given by you.

ConnectionPool simpleConnection;

RepositoryIdentifier repIdentifier;

String session;

String connection = "servername";

String repository = "repository";

DBMSType dbmsType = DBMSType.ORACLE;

try {

simpleConnection = ConnectionPoolFactory.getInstance(connection);

repIdentifier = new RepositoryIdentifier(repository, connection, dbmsType);

CreateServerSessionCommand createServerSessionCmd = new CreateServerSessionCommand(simpleConnection);

createServerSessionCmd.execute();

session = createServerSessionCmd.getSession();

AuthenticateServerSessionCommand auth= new AuthenticateServerSessionCommand(simpleConnection);

auth.setSession(session);

auth.setUserName("Admin");

auth.setUserPassword("****");

auth.execute();

session = auth.getSession();

} catch (ConnectionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (CommandException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

I am getting the error java.lang.NoClassDefFoundError: com/sap/mdm/commands/CommandException

Kindly suggest.

Former Member
0 Kudos

Hi,

You might have not copied all the jars in the Lib folder. Also have you imported all the jars in the Libraries?

Import MDM4j.jar as well

Regards,

Jitesh Talreja

Answers (8)

Answers (8)

Former Member
0 Kudos

Hi,

I have added all the jars

and the imports i am using are

import com.sap.mdm.commands.AuthenticateServerSessionCommand;

import com.sap.mdm.commands.CommandException;

import com.sap.mdm.commands.CreateServerSessionCommand;

import com.sap.mdm.net.ConnectionException;

import com.sap.mdm.net.ConnectionPool;

import com.sap.mdm.net.ConnectionPoolFactory;

import com.sap.mdm.server.DBMSType;

import com.sap.mdm.server.RepositoryIdentifier;

Thanks,

Jyothi

Former Member
0 Kudos

I had added the jar files and build the project.

And for the mdm and jar file the version and patch are same but hot fix is different. Does that matter?

Edited by: jyothi beera on Feb 13, 2009 10:17 AM

Former Member
0 Kudos

Hi,

I dont think hotfix will matter. Try to test it, if the program executes successfully that means you can continue using the jar files else you need to use the jar files of that hotfix.

Regards,

Jitesh Talreja

Former Member
0 Kudos

Hi Jitesh,

I am getting the below error when i use the code

java.lang.NoClassDefFoundError: com/sap/mdm/commands/CommandException

My MDM version is 5.5.62.33 and the jar file version is 5.5.62.63. is that the problem?

Kindly suggest.

Former Member
0 Kudos

Hi Jyothi,

It is mandatory to use the jars and MDM Server of same version. Also rebuild your webdynpro project.

Regards,

Jitesh Talreja

Former Member
0 Kudos

Hi,

I have used the above code by jitesh and i am getting the below error when i deploy my application.

I have added the jars

mdm-admin

mdm-common

mdm-core

mdm-date

mdm-extension

mdm-protocol.

java.lang.NoClassDefFoundError: com/sap/mdm/commands/CommandException

Is it because of version problem or is there some thing else i am missing.

Kindly suggest.

Former Member
0 Kudos

Hi Jyothi,

You need to copy the jar files in the lib folder of your webdynpro project.

Archive repository create .a2a file and you can move that file to any other MDM Server and UnArchive it. It is a transport mechanism to move the MDM repository from one server to another.

No need to print the output. If the execution of program is successful then you will get a file created in the folowing path

{MDM Installable directory|/Server/Archives

e.g.

C:\Program Files\SAP MDM\Server\Archives

Regards,

Jitesh Talreja

Former Member
0 Kudos

Hi Jitesh,

Can u tel me what is this archive repositorycommand and what is it's use

Thanks.

Former Member
0 Kudos

Hi Jitesh,

Thanks for the code.

And can you tell me something i can print from the above code to know that the connection to the repository is working.

Thanks,

jyothi

Edited by: jyothi beera on Feb 13, 2009 9:21 AM

Former Member
0 Kudos

Hi,

I just has used the below code just for testing. But it is giving me the error "No class def found error". Can you suggest me.

SimpleConnection connection=null;

String host="server:port";

try {

connection=SimpleConnectionFactory.getInstance(host);

} catch (ConnectionException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

wdComponentAPI.getMessageManager().reportSuccess("connection is"+connection);

connection.close();

Thanks,

Prasanthi

Former Member
0 Kudos

Hi Jyothi,

Check the below sample code for Archieving the repository

public class TestArchiveRepository

{

public static ConnectionPool simpleConnection;

public static RepositoryIdentifier repIdentifier;

public static String session;

public static String connection = "TEST";

public static String repository = "REPO_TEST";

public static DBMSType dbmsType = DBMSType.MS_SQL;

public static void main(String[] args)throws CommandException, ConnectionException

{

simpleConnection = ConnectionPoolFactory.getInstance(connection);

repIdentifier = new RepositoryIdentifier(repository, connection, dbmsType);

CreateServerSessionCommand createServerSessionCmd = new CreateServerSessionCommand(simpleConnection);

createServerSessionCmd.execute();

session = createServerSessionCmd.getSession();

AuthenticateServerSessionCommand auth= new AuthenticateServerSessionCommand(simpleConnection);

auth.setSession(session);

auth.setUserName("Admin");

auth.setUserPassword("Pass123");

auth.execute();

session = auth.getSession();

ArchiveRepositoryCommand archiveRepCmd = new ArchiveRepositoryCommand(simpleConnection);

archiveRepCmd.setArchiveFileName("REPO_TEST_ARC");

archiveRepCmd.setRepositoryIdentifier(repIdentifier);

archiveRepCmd.setSession(session);

archiveRepCmd.execute();

}

}

Regards,

Jitesh Talreja