cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Getting connection using MDM JAVA API..?

Former Member
0 Kudos

Hi Experts,

I am new to MDM.Recently I was shifted from java to MDM.I got the below problem when i run my application for getting connection.I got coneection but display some error message.Please see my code and problem.

problem

-


Exception in thread "main" java.lang.NullPointerException com.sap.mdm.server.commands.GetServerVersionCommand.getVersion

code

-


import com.sap.mdm.commands.*;

import com.sap.mdm.net.ConnectionException;

import com.sap.mdm.net.SimpleConnection;

import com.sap.mdm.net.SimpleConnectionFactory;

import com.sap.mdm.server.commands.GetServerVersionCommand;

public class Application2 {

public static void main(String[] args){

System.out.println("-Connection not yet created--");

String connectionTag = "MDMServer";

SimpleConnection connection = null;

try {

connection = SimpleConnectionFactory.getInstance(connectionTag);

System.out.println("-Connection created--");

System.out.println("---Host Name -


" + connection.getHostname());

System.out.println("---Port No -


" + connection.getPort());

System.out.println("---Identity -


" + connection.getIdentity());

System.out.println( "---ConnectionSource -


" + connection.getConnectionSource());

System.out.println( "-Connection is ready--" + connection.isReady());

} catch (ConnectionException e) {

e.printStackTrace();

System.out.println("Version problem:"+e);

return;

}

GetServerVersionCommand cmd = new GetServerVersionCommand(connection);

System.out.println("MDM server Class: " + cmd.getClass());

System.out.println("MDM server Class: " + cmd.getSession());

System.out.println("MDM server Class: " + cmd.getVersion());

}

}

can anybody helm me out in these issues

Regards

Satish

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You need to set the Server session. Please check the below code

CreateServerSessionCommand createSerSesCmd = new CreateServerSessionCommand(simpleConnection);

createSerSesCmd.execute();

session = createSerSesCmd.getSession();

assign this session to cmd object i.e. cmd.setSession(session)

Now try to run the code.

Note: Session is nothing but a String variable

Regards,

Jitesh Talreja