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

Ask Your Question

Embedded spaces with disabled Lookup Service in integration tests

I already posted a question how to disabled the Lookup service in my integration tests. http://ask.gigaspaces.org/question/99... Now the lookup service is disabled (I think) but this leads me to the next problem.

My test looks like this:
I have two embedded spaces using the setup code shown below.

  1. The production code starts a thread which starts a transaction and waits (blocking take) for an object written into Space-A
  2. I write this object into Space-A from the unit test runner thread
  3. The other thread takes it and converts it into another object and writes this other object into Space-B
  4. After it has written the converted object the transaction is commited
  5. Now I do a blocking take on Space-B (in the unt test runner thread) and wait until the converted object shows up

Unfortunetly I never see the converted object appearing in Space-B.
I checked the transaction commit and this seems to work (at least no exception appears).

I am currently creating the GigaSpace instances once and re-use the same instance in the code under test as well as the test code itself. What I mean is that I changed the dependency injection config of my production code classes to inject them the GigaSpace instance that I created in the test code. So I only create the instances once and re-use them. Can this be a problem?

I am still using the DistributedJiniTxManager, can this be a problem when using embedded spaces where the lookup service is disabled?

UrlSpaceConfigurer cfg = new UrlSpaceConfigurer("/./ProcuderSpace")
                .lookupGroups(environment.getEnvironmentVariableOrDefault(ENV_LOOKUP_GROUPS, LOOKUP_GROUPS_DEFAULT))
                .addProperty("space-config.lease_manager.expiration_time_interval", "1500")
                .addProperty("com.j_spaces.core.container.directory_services.jini_lus.start-embedded-lus", "false")
                .addProperty("com.j_spaces.core.container.directory_services.jini_lus.enabled", "false")
                .addProperty("com.j_spaces.core.container.directory_services.jndi.enabled", "false")
                .addProperty("com.j_spaces.core.container.embedded-services.httpd.enabled", "false");

txManager = new DistributedJiniTxManagerConfigurer().transactionManager();
GigaSpace gigaSpace = new GigaSpaceConfigurer(configurer).transactionManager(txManager).create();

EDIT: Also I get this exceptions with the config above:

2014-12-08 16:13:04,068  WARNING [com.gigaspaces.jmx] - Failed to receive MBean Server.java.io.IOException: Cannot bind to URL [rmi://]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host:; nested exception is: 
    java.net.ConnectException: Connection refused: connect]; Caused by: java.io.IOException: Cannot bind to URL [rmi://]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host:; nested exception is: 
    java.net.ConnectException: Connection refused: connect]
    at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:826)
    at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:431)
    at com.j_spaces.jmx.JMXProvider.getMBeanServer(JMXProvider.java:142)
    at com.j_spaces.jmx.JMXProvider.registerSpaceMBean(JMXProvider.java:422)
    at com.j_spaces.core.JSpaceContainerImpl.loadSpace(JSpaceContainerImpl.java:1942)
    at com.j_spaces.core.JSpaceContainerImpl.xmlInit(JSpaceContainerImpl.java:912)
    at com.j_spaces.core.JSpaceContainerImpl.initContainer(JSpaceContainerImpl.java:542)
    at com.j_spaces.core.JSpaceContainerImpl.<init>(JSpaceContainerImpl.java:429)
    at com.j_spaces.core.client.SpaceFinder.createEmbeddedSpace(SpaceFinder.java:641)
    at com.j_spaces.core.client.SpaceFinder.findEmbeddedSpace(SpaceFinder.java:677)
    at com.j_spaces.core.client.SpaceFinder.findService(SpaceFinder.java:501)
    at com.j_spaces.core.client.SpaceFinder.findService(SpaceFinder.java:456)
    at com.j_spaces.core.client.SpaceFinder.find(SpaceFinder.java:345)
    at com.gigaspaces.client.SpaceProxyFactory.createSpaceProxy(SpaceProxyFactory.java:75)
    at org.openspaces.core.space.UrlSpaceFactoryBean.doCreateSpace(UrlSpaceFactoryBean.java:144)
    at org.openspaces.core.space.AbstractSpaceFactoryBean.afterPropertiesSet(AbstractSpaceFactoryBean.java:184)
    at org.openspaces.core.space.UrlSpaceConfigurer.create(UrlSpaceConfigurer.java:351)
    at org.openspaces.core.space.UrlSpaceConfigurer.space(UrlSpaceConfigurer.java:363)
    at org.openspaces.core.GigaSpaceConfigurer.<init>(GigaSpaceConfigurer.java:67)
    at com.XXX.ps.core.integration.AbstractEmbeddedSpaceServiceIntegrationTest.createEmbeddedSpace(AbstractEmbeddedSpaceServiceIntegrationTest.java:849)
    at com.XXX.ps.core.integration.AbstractEmbeddedSpaceServiceIntegrationTest.getOrCreateSpace(AbstractEmbeddedSpaceServiceIntegrationTest.java:860)
    at com.XXX.ps.core.integration.AbstractEmbeddedSpaceServiceIntegrationTest.createRemoteServiceRepository(AbstractEmbeddedSpaceServiceIntegrationTest.java:295)
    at com.XXX.ps.core.integration.transport.MessageTransportIntegrationTest.prepareRepository(MessageTransportIntegrationTest.java:136)
    at com.XXX.ps.core.integration.transport.MessageTransportIntegrationTest.testInit(MessageTransportIntegrationTest.java:95)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host:; nested exception is: 
    java.net.ConnectException: Connection refused: connect]
    at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:143)
    at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:226)
    at javax.naming.InitialContext.bind(InitialContext.java:419)
    at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:643)
    at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:426)
    ... 32 more
Caused by: java.rmi.ConnectException: Connection refused to host:; nested exception is: 
    java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)
    at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
    at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:137)
    ... 36 more
Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at java.net.Socket.connect(Socket.java:528)
    at java ...

asked 2014-12-06 15:29:22 -0600

leozilla gravatar image

updated 2014-12-08 09:17:09 -0600

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Hi, You say you have 2 different spaces, Space A and Space B, How do you create the proxy to space B? did you make sure you are doing the blocking take on teh converted object on Space B and not A i suggest you add some filters to the space and print something before_write and after_write to make sure the objects are there, see more information here: http://docs.gigaspaces.com/xap97/the-...

answered 2014-12-07 04:45:15 -0600

inbarc gravatar image
edit flag offensive delete link more


I create the proxy as shown above (using the UrlSpaceConfigurer). I tried to use the same proxy instance in my production code but as I already said the writes did not show up when doing the take in the test runner thread. I also tried to create another proxy in my production code and use this to make the writes, I got the same problem.

I also tried to just write and read from Space B in the test code and this works.

I guess the problem has to do with the transaction manager because in the production code I write inside a transaction.

I will also try the filters now.

leozilla gravatar imageleozilla ( 2014-12-07 15:47:08 -0600 )edit

I dont really get how this UrlSpaceConfigurer works.. what happens if I execute the code above twice in a row (using exactly the same URL)? Does it just create two proxies to the same space or does it create two different spaces?

leozilla gravatar imageleozilla ( 2014-12-07 16:11:04 -0600 )edit

Running the code above twice will create 2 spaces, if you want to connect to the space and not create it you need to use a different url : jini:////ProcuderSpace

inbarc gravatar imageinbarc ( 2014-12-08 04:11:02 -0600 )edit

But I need to enable the LookupService when I use a jini url right? or can i just write "jini://?/SpaceName"? Btw: Does your url above use 4 slashes? what kind of url is that?

leozilla gravatar imageleozilla ( 2014-12-08 09:34:08 -0600 )edit

see here all the information about the space URL:http://docs.gigaspaces.com/xap97/the-space-configuration.html my suggestion is to use remote proxy to the space since you are running 2 different spaces, you need 2 separate space proxies If that does not work, i suggest we set up a webex and review the test code together and see how to resolve it, sounds OK?

inbarc gravatar imageinbarc ( 2014-12-08 13:41:15 -0600 )edit

Thanks for your answer. I have already read the documentation about the Space URL about 5 times but I dont really see howto create the proxies for multiple embedded spaces. I will try the remote proxy again.

The webex sounds really good I think it will help me and our team a lot! Are you a GigaSpace employe?

leozilla gravatar imageleozilla ( 2014-12-09 11:06:15 -0600 )edit

Yes, I am GigaSpaces employee. and i understand that Ron Z. from GigaSpaces also approached you and would like to assist you directly. please work with Ron on this issue as well. I will sync with Ron and post an answer here once this issue is resolved.

inbarc gravatar imageinbarc ( 2014-12-10 03:31:35 -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-12-06 15:29:22 -0600

Seen: 475 times

Last updated: Dec 08 '14