Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Terminating Java Service Desk Web API application

Highlighted
Harald Tempelma
Occasional Contributor

Terminating Java Service Desk Web API application

I have made a Java program using the ServiceDesk Web API interface. My program works ok, but when it is ready (i.e. main() has been ended), the program itself does not terminate. I have to shut it down using e.g. CTRl-C from a DOS command box.

This behavior does only occur when I have set-up a session to SD successfully. Whenever I do not set-up such a session, the program terminates normally.

I have tried to put the statement

session.closeConnection()

at the end of my program, but this does not help either.

Has anyone encountered similar behavior?
How can this be solved?
I am using SD 4.5 SP12.

Kind regards,
Harald...
5 REPLIES
Vasily Kamenev
Honored Contributor

Re: Terminating Java Service Desk Web API application

Hi
At the your programm you must set try-catch function and describe catch-ers trown RuntimeException , so your programm must have
catch(RuntimeException re){
re.printStackTrace()
return;
}
then you will see where programm crashed.

Vassili
Jacek Pliszka_2
Regular Collector

Re: Terminating Java Service Desk Web API application


I experience exactly same behaviour.

My solution is:

from java.lang.System import exit

exit(0)

BR,

Jacek
Harald Tempelma
Occasional Contributor

Re: Terminating Java Service Desk Web API application

The System.exit(0) does the trick, however it should not be necessary to end the Java program such (SD feature???).
Juan Paulini
Super Collector

Re: Terminating Java Service Desk Web API application

I had the same problem, it was solved in the same way, (adding System.exit(0) before closing main()).

Even some a friend tried from other computer, but it finalized it´s execution ok.

Do you know if it´s related to JRE version? I´m using J2SDK 1.4.2_09
Christian Nilss
Collector

Re: Terminating Java Service Desk Web API application

System.exit(n)
n = status code
1 = normal
!= 1 mean abnormal exit

Every java appliaction starts a runtime object and must be exited otherwise the allocated memory not will be released. The garbage collector will take care of, but it takes some time before it do that.

Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.

regards
Christian
//Add this to "OnDomLoad" event