function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jichunjichun 

INVALID_SESSION_ID Error throws by Java application

Hi, All
 
We created 2 simple java application which triggered by windows task manager at different time to access SF.
one is triggered every 30 min and one is 1 hrs.
 
But sometime Java throws a error message, not all the time.
-------------------------------------------------------------------

2008/05/14 10:00:09 [ERROR] BatchSFToDayBreak - main((String[]) <INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Session timed out>AxisFault
 faultCode: {urn:fault.enterprise.soap.sforce.com}INVALID_SESSION_ID
 faultSubcode:
 faultString: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Session timed out
 faultActor:
 faultNode:
 faultDetail:
 {urn:fault.enterprise.soap.sforce.com}UnexpectedErrorFault:<ns1:exceptionCode>INVALID_SESSION_ID</ns1:exceptionCode><ns1:exceptionMessage>Invalid Session ID found in SessionHeader: Session timed out</ns1:exceptionMessage>

-------------------------------------------------------------------
 My java application will login again every time when triggered, and java program only run abt 1 mins. why the session will timeout? do I need to update my stub?

Thanks

 
jdengjdeng
how long do you set you binding timeout?  and how long is session time set in your sf account?
jichunjichun

Thanks a lot, jdeng

In SF side, user setup 30 mins for the session timeout. And for JAVA program, we didn't setup time out for binding before. I don't know what is the default setup for binding timeout. maybe 1 min. Anyway, I add one line code below (time out as 3 mins). Maybe it works.

binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
binding.setTimeout(180000);
lr = binding.login(userName, pwd);

werewolfwerewolf
Well anyway since your Java program already has the credentials to login, if you get this error, just re-login and try again.
jichunjichun

even setup to 5 mins for binding timeout in Java code, we are still facing this error sometime. if just run java program right away, then no error. does somebody know any solutions for this. or this is the bug of salesforce :-(

werewolfwerewolf
It's not a bug in salesforce.  Like I said, when you get that error, your session is either legitimately timed out, or you have somehow killed the binding's session ID.  Either figure out whether you're killing the session ID, or if it's a legitimate timeout, just re-login.
jichunjichun

Thanks, werewolf

I just won't get it why the session got timeout or got killed. Our java program is very simple. it runs every 30 mins to login SF to receive some data then save to another database. everytime it will login again, create new session and session ID.

Anyway. I changed the windows task manager to trigger java program every 15 mins, then no INVALID_SESSION_ID error. this issue doesn't bother us anymore but I still wish somebody could tell me the reason :-)