cancel
Showing results for 
Search instead for 
Did you mean: 

IConnection-get|ConnectionEx(spec) throwing null pointer exception

Former Member
0 Kudos

Hi,

I closed a thread recenly and here is another one.

I have to fetch some data from MDM and bring it to my Web Dynpro application.


		IConnectionSpec spec = connectionFactory.getConnectionSpec();

		spec.setPropertyValue("UserName", "User");
		spec.setPropertyValue("Password", "User");
		spec.setPropertyValue("Server", "<IP ADDress>");
		spec.setPropertyValue("Port", "XXXX");
		spec.setPropertyValue("RepositoryLanguage", "English[US]");
	
		try{
			IConnection connection = connectionFactory.getConnectionEx(spec);
		}
		catch(ConnectionFailedException cfe){
		}
		catch(ConnectorException ce){
		}
		catch(Exception e){
			throw new Exception(e.toString());
		}

I am getting Null Pointer exception..

Does it mean that properties i am hardcoding are wrong?

Kindly let me know what could possibly be wrong here...

Accepted Solutions (1)

Accepted Solutions (1)

sridhar_k2
Active Contributor
0 Kudos

Hi,

This may be useful to you.

http://help.sap.com/saphelp_nw04s/helpdata/en/89/8a185c148e4f6582560a8d809210b4/content.htm

For more info go thru this link.

- Sridhar

Former Member
0 Kudos

Hi,

In one of these threads, i came across a statement that "I checked from portal and connection tests to MDM server passed". How can i check this?

I have a similar scenario, and have already added MDM4j etc to the portal server, but do not know how to confirm the connectivity, this can be useful for me...

Any pointers?

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

Hi,

I guess on IConnectionSpec. Check with notnull, so that you can findout where exactly you have the error.

Regards,

Sridhar

Former Member
0 Kudos

Hi Sridhar,

I checked it before only and spec is not null...

Errir is coming in IConnection and when i pass spec as a parameter....

But dont know what exactly is the cause...

sridhar_k2
Active Contributor
0 Kudos

hi,

You can make use the below code. It is running for me.

public static IConnection getConnection()throws Exception {

Context ctx = null;

String username = "";

String password = "";

String server = "";

String port = "";

String language = "";

try {

ctx = new InitialContext();

} catch (NamingException nex) {

throw new NamingException(nex.toString());

}

IConnectionFactory connectionFactory = null;

try {

connectionFactory =

(IConnectionFactory) ctx.lookup(

Messages.getString("MDM_FACTORY"));

} catch (NamingException nex) {

throw new NamingException(nex.toString());

}

IConnectionSpec spec = null;

try {

spec = connectionFactory.getConnectionSpec();

} catch (ConnectorException cex) {

throw new ConnectorException(cex.toString());

}

spec.setPropertyValue("UserName", username);

spec.setPropertyValue("Password", password);

spec.setPropertyValue("Server", server);

spec.setPropertyValue("Port", port);

IConnection connection = null;

try {

connection = connectionFactory.getConnectionEx(spec);

} catch (NullPointerException npex) {

throw new NullPointerException("Could not able to make connection to server :" + server + " port :" + port);

} catch (ConnectionFailedException cfex) {

throw new ConnectionFailedException(cfex.toString());

} catch (ConnectorException cex) {

throw new ConnectorException(cex.toString());

}

return connection;

}

Regards,

Sridhar

Former Member
0 Kudos

Similar code is being used by me.. but its throwing a null pointer... seems that one of the values is improper... is my assumption rite... ?