Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

java client does not terminate?


maybe i am missing something really basic, but the sample example/tutorial which shows how to connect, read/write data to a GS grid, doesn't seem to terminate. I have to manually kill it (CTRL + C).

this is the java client given at: http://docs.gigaspaces.com/tutorials/...

I couldn't locate an API either something like, gigaSpace.close() or gigaSpace.terminateConnection()

Any pointers?

thanks, -Piyush

asked 2014-01-27 00:58:13 -0600

Piyush gravatar image
edit retag flag offensive close merge delete

5 Answers

Sort by ยป oldest newest most voted

Sure. The 2 sample classes (person and program) are picked up from: http://docs.gigaspaces.com/tutorials/...

I made one change used the DataGridConnectionUtility given here: https://github.com/Gigaspaces/bestpra...

import org.openspaces.core.GigaSpace;

import com.j_spaces.core.client.SQLQuery;

public class Program {

public static void main(String[] args) {

    GigaSpace gigaSpace = DataGridConnectionUtility.getSpace( "myGrid" );

    System.out.println("Write (store) a couple of entries in the data grid:");
    gigaSpace.write(new Person(1, "Vincent", "Chase"));
    gigaSpace.write(new Person(2, "Johnny", "Drama"));

    System.out.println("Read (retrieve) an entry from the grid by its id:");
    Person result1 = gigaSpace.readById(Person.class, 1);
    System.out.println("Result: " + result1);

    System.out.println("Read an entry from the grid using a SQL-like query:");
    Person result2 = gigaSpace.read(new SQLQuery<Person>(Person.class, "firstName=?", "Johnny"));
    System.out.println("Result: " + result2);

    System.out.println("Read all entries of type Person from the grid:");
    Person[] results = gigaSpace.readMultiple(new Person());
    System.out.println("Result: " + java.util.Arrays.toString(results));


answered 2014-01-28 00:57:11 -0600

Piyush gravatar image
edit flag offensive delete link more


Please close the admin before you end your program. This should solve the problem with the hanging thread.

shay hassidim gravatar imageshay hassidim ( 2014-01-28 06:52:59 -0600 )edit

hi Shay, appologize for the delay in response. I got caught up with other stuff.

By admin I suppose you are referring to the object created inside the DataGridConnectionUtility. and admin.close() is already issued there.

However, just to be on the safe side I did issue it once more in the client Program and it has no effect. The process is still not terminating.

Piyush gravatar imagePiyush ( 2014-01-31 06:35:50 -0600 )edit

use this: UrlSpaceConfigurer.destroy()


answered 2014-01-27 09:32:13 -0600

shay hassidim gravatar image
edit flag offensive delete link more

hmm... Shay, that would destroy the space including all the objects inside it. not an option. I only want to terminate my java client gracefully.


answered 2014-01-27 10:01:14 -0600

Piyush gravatar image
edit flag offensive delete link more

absolutely not. It will simply close the connection.

answered 2014-01-27 10:03:11 -0600

shay hassidim gravatar image
edit flag offensive delete link more

the javadoc said, it'll destroy the space and I think I mixed up 2 different execution which led me to believe that the space was getting destroyed.

however, on further executions, i do see the space is still alive. having said that, the java client is still not terminating. i believe that is due to non-daemon threads being alive that are preventing the jvm from exiting.

answered 2014-01-27 10:42:15 -0600

Piyush gravatar image
edit flag offensive delete link more


Can you please post your code?

shay hassidim gravatar imageshay hassidim ( 2014-01-27 10:56:02 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-01-27 00:58:13 -0600

Seen: 2,865 times

Last updated: Jan 28 '14