cancel
Showing results for 
Search instead for 
Did you mean: 

MDM Java Connector : connection problem

Former Member
0 Kudos
73

Hi All,

I'm using MDM Java Connector to get a connection to MDM Repository. I have all the JAR files included and all the references given in the Web Dynpro Application. I get the connection with MDM repository perfectly and perform operations too.

But, the problem is if I run the same application 2-3 times it starts giving error like.."Login Method not executed properly". Does anyone know what could be the possible problem here??

The code I'm using,


//Obtain the initial JNDI context
 Context ctx = new InitialContext();
//Perform JDNI lookup to obtain connection factory
IConnectionFactory connectionFactory =(IConnectionFactory)ctx.lookup("deployedAdapters/MDM Factory/shareable/MDM Factory");
//Get Connection Spec to set connection properties
IConnectionSpec spec = ConnectionFactory.getConnectionSpec();
//Set Connection Properties
 spec.setPropertyValue("UserName", <username>);
 spec.setPropertyValue("Password", <password>);
 spec.setPropertyValue("Server", <server>);
 spec.setPropertyValue("Port", <por>);
 spec.setPropertyValue("RepositoryLanguage", <lang>);

//Get the Connection
IConnection connection = connectionFactory.getConnectionEx(spec);
		
wdComponentAPI.getMessageManager().reportSuccess("Connection Established");
		
//Retrieve Native inteface
 INative nativeInterface = connection.retrieveNative();
//Get the CatalogData the physical connection
 CatalogData catalog = (CatalogData)nativeInterface.getNative(CatalogData.class.getName());

Regards,

Mausam

View Entire Topic
AndreasSeifried
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mausam,

check whether you close the connection at the end:

connection.close();

Did you have a look at the connector monitor ?

Via Visual Admin -> Services -> Monitoring -> Services -> Connector Service -> ... -> MDM Factory.

Regards

Andreas

Former Member
0 Kudos

Hi Andreas,

Thanks for replying.

Yes, you are right. I didn't close the connection when application exits. I have put it now, but I think the previous connection still has some effects and still I'm not able to connect. Can you tell me, is there any place where I can go and manually free the connection??

One more thing, where should I close the connection in my application...once I get the CatalogData object or when the application exits??

Regards,

Mausam

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi Mausam,

One more way is you have restart the MDM Server to stop the earlier connection effects.

Close the connection at the end(once you done with all manipulation on catalogdata).

Regards

Suresh

AndreasSeifried
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

You should close the connection as soon as it is not immediately used by your program any more. This will return the connection back to the connection pool. Typically you react on some user input by opening the connection, doing some operations via the API, close the connection, return the results to the user.

In words and generally speaking: Close connections as often as you open new ones. If your application is "idle" (e.g. not processing any user request) it should not hold a connection open.

Does this make it clear ?

Andreas

Former Member
0 Kudos

Hi Andreas,

Thanks for clearing my doubt.

But the problem is still there. Here is what I'm doing.

I have a Web Dynpro application. In wdDoInit(), I'm opening a connection and getting the data from MDM. Once I finish with fetching data from MDM, I call "connection.close()" method. And it doesn't give any exception.

Now, when I run the same application again, I'm getting the error "Login method has not been successfully called."

I couldnt find any method in IConnection which can show the status of the connection like, isAlive or something. And even in VA Monitoring I can see that connection is still not broken. (I'm looking into "Used Managed Connection number")

So, is there any way out of this??

Thanks and Regards,

Mausam

AndreasSeifried
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Mausam,

first of all: Are you sure that you have the latest connector and mdm4j sda deployed ?

If yes, please try

connection.close();

connection = null;

catalog = null;

and try again. Remember: You must not call CatalogData.Logout() !

Does "Free managed connections number" increase from an initial 0 to at least 1 during program execution ?

(Remember to use "Update" in the right mouse button menue)

How does "Used managed connections number" change in detail ?

I you'd post more of your coding in wdDoInit, I could possibly investigate further.

Regards

Andreas

Former Member
0 Kudos

Great Andreas,

It seems making "null" afterwards has done the trick. Though I would like to test it properly, will get back to you on the same if it fails somewhere.

Thanks a lot. Now, I can "hibernate" till Monday.

Regards,

Mausam