cancel
Showing results for 
Search instead for 
Did you mean: 

API Connection Question

Former Member
0 Kudos

Hello Java API Experts,

I have a situation and I hope someone can provide an explanation. Here is a simple 3 line program to connect and disconnect from my local MDM server which leaves a message on my eclipse console. It would be a good idea to step through with a debugger and have the console running with the Connections records showing.

The MDM Server and API are the SP06 Patch 2 components that I downloaded on 3/28. However, I saw same results in SP06 Patch 1 components.

public class ConnectTest
{
	public static void main(String[ ] args)
	{
		// Check console:  how many connections currently exist to this repository prior to next statement? 
		// Press F5 in Console to refresh window.
		// My system just shows 1 connection...the 1 associated with Console.
		UserSessionContext usc = new UserSessionContext( "localhost", "Test_Repository", "Admin" );
		
		// Check console:  how many connections currently exist to this repository prior to next statement?
		// Press F5 in Console to refresh window.
	        // My system just shows 1 connection...the 1 associated with Console.  (this was expected)
		String session = SessionManager.getInstance( ).createSession( usc, SessionTypes.USER_SESSION_TYPE, "" );
		
		// Check console:  how many connections currently exist to this repository prior to next statement?
		// Press F5 in Console to refresh window.
		// My system shows that 2 connections were created by the previous statement.  Now 3 connections.
		SessionManager.getInstance( ).destroySessions( usc );
		
		// Check console:  how many connections currently exist to this repository prior to next statement?
		// Press F5 in Console to refresh window.
		// My system shows that the 2 connections created by createSession( ) method are now gone. 
		// Now just 1 connection.
	}
}

The program prints this message on the eclipse Console window:

Mar 31, 2008 9:31:07 AM com.sap.mdm.logging.MdmLogger error SEVERE: Can not find session for destroy. Session context: '<server=localhost serverUser=Admin repository=Test_Repository region=English [US] user=Admin>'

Why is this message being displayed on the console? Is there something wrong with the code above?

Best Regards,

Mark

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This code works without error:


public class ConnectTest {
	public static void main(String[] args) {
		UserSessionContext usc = new UserSessionContext("localhost", "Test_Repository", "Admin");
		String session = SessionManager.getInstance().createSession(usc, SessionTypes.USER_SESSION_TYPE, "");
		SessionManager.getInstance().destroySession(usc, SessionTypes.USER_SESSION_TYPE);
	}
}

I hope this helps.

Doug

Former Member
0 Kudos

Hi Doug,

Thanks for having a look at it. Using destroySession( ) instead of destroySessions( ) does work ( i.e. the error message doesn't show ).

Do you or anyone know why destroySessions( ) sends that error message to the console? It seems to me that calling the pural form of the method would still be valid even if I've only created one session.

Best Regards,

Mark

Former Member
0 Kudos

Mark,

That's a good question and one I don't have an answer for. What I have found is that these work (or, at least don't generate an error):


SessionManager.getInstance().destroyAllSessions();
SessionManager.getInstance().destroySession(usc, SessionTypes.REPOSITORY_SESSION_TYPE);

However,


SessionManager.getInstance().destroySessions(usc);

returns an error no matter what I try. Hopefully, someone can let us know.

Former Member
0 Kudos

Hi Doug,

Thanks again for staying in the game.

For anyone with power to fix the API itself, releaseSessions( ) method outputs roughly the same error message.

Best Regards,

Mark

Former Member
0 Kudos

The following from SAP Support:

Hello Mark,

Thank you for the clear code sample. In order to close those connections it's recommended to use

destroySession instead of destroySessions.

Here is your code sample changed by me:

UserSessionContext usc = new UserSessionContext( "localhost", "APITest","Admin" ); String session = SessionManager.getInstance().createSession( usc, SessionTypes.USER_SESSION_TYPE, "" ); SessionManager.getInstance().destroySession(usc, 2); SessionManager.getInstance().destroySession(usc, 3); // Where in destroySession: Server session: '1', Repository session: '2'and User session: '3'

About the error message when using destroySessions, you are right - it should not be present and we will handle this in our next version (although its destroy all the open sessions).

Best regards,

Yaniv

-


I'm not sure what exactly Yaniv means by "next version" (SP?, Patch?, or HF?) but at least it has been acknowledged and will be fixed in the future.

Answers (0)