on 03-31-2008 3:09 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.