The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Java web-api execution

SOLVED
Go to solution
Highlighted
Carlos_211
Collector

Java web-api execution

Hi,

I've a new problem:

I execute all Examples that are privided in the web-api directory, but at the end of the execution they are not finished by theirself, but I have to press CONTROL+C to finish the execution.

Any idea abut what is happening?

Thanks, Carlos
6 REPLIES
Ganesha Sridhar
Esteemed Contributor

Re: Java web-api execution

Hello Carlos,

I have tried the Example1.java file which comes with WEB-API SDK, and the program executed without waiting for "Ctrl + C" key.

Please can you send me your Example file, so that I can try the same here.

I have attached the Example1.java which I have executed (I have not modified anything in this example file).

Regards
Ganesha Sridhara
Carlos_211
Collector

Re: Java web-api execution

Hi Ganesha,

Thanks for your answer.

I've compiled and executed your example and the problem is there.

My compilation lines are:
===========================
$ javac -classpath ..\web-api.jar Example1.java
$ java -cp ..\web-api.jar;. Example1 localhost CARLFRE servicedesk
==============================

I don't know exactly what is the problem, becouse i execute the example, and the prompt is not displayed, but I can write (without seeing my lines) and waht i write is executed.

For example:
- I execute java example
- No prompt is showed
- I write dir command and enter(for example)
- I execute java -version and enter(for example)
- I don't see anything
- I press CONTROL+C
- The prompt is showed and the dir and java -version commands had been executed.


So the problem is that the system don't show the prompt, but I think that the java example finish its executation.

Any Idea

Note: I don't enclose my file becouse the error is the same than with yours

Ciao, Carlos
Carlos_211
Collector

Re: Java web-api execution

Just one more detail.

If I execute another example(not included in servicedesk examples and without relation with service desk) it finish its execituion normally.

I enclose that stupid (very simple) file

Maybe this helps
Petr_14
Acclaimed Contributor
Solution

Re: Java web-api execution

Hi,
i have the same problem. I solved it by adding line
System.exit(1);

To the end of main function.
Now it wont wait until CTRL+C.
Carlos_211
Collector

Re: Java web-api execution

Hi, I had already solved it but I forgot close this thread.

Thanks anyway.

The problem was that I was writing return; instead you must use System.exit(n);

That examples works if you execute them from service desk as the result of a rule (as a command action).

The problem was that return doesn't give you back the promt, but when you use the script in a rule, you don't need the prompt.

That's all. Thanks

Carlos from Spain
Carlos_211
Collector

Re: Java web-api execution

Closed ;)
//Add this to "OnDomLoad" event