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

Ask Your Question

CastException: JINI .RemoteEvent cannot cast to EntryArrivedRemoteEvent

Hi All

I'm new to Java Spaces, and encountered this problem:

I have registered my Request Template with Jini RemoteEventListerner and trying to get an notification when an request is post by the client to the space.

the code is as follws:

public void notify(RemoteEvent anEvent) {

  try {

        EntryArrivedRemoteEvent arrivedRemoteEvent = (EntryArrivedRemoteEvent) anEvent;

        RequestObject reqObj = (RequestObject)(arrivedRemoteEvent.getEntry());

    } catch (Exception anE) {
        System.out.println("Got Request event but couldn't display it");


public class RequestObject implements Entry

When i run i get this ClassCastException.

java.lang.ClassCastException: net.jini.core.event.RemoteEvent cannot be cast to com.j_spaces.core.client.EntryArrivedRemoteEvent at Space.EventListener.notify(EventListener.java:44) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at net.jini.jeri.BasicInvocationDispatcher.invoke(BasicInvocationDispatcher.java:1126) at net.jini.jeri.BasicInvocationDispatcher.dispatch(BasicInvocationDispatcher.java:608) at com.sun.jini.jeri.internal.runtime.ObjectTable$6.run(ObjectTable.java:597) at net.jini.export.ServerContext.doWithServerContext(ServerContext.java:103) at com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch0(ObjectTable.java:595) at com.sun.jini.jeri.internal.runtime.ObjectTable$Target.access$700(ObjectTable.java:212) at com.sun.jini.jeri.internal.runtime.ObjectTable$5.run(ObjectTable.java:568) at java.security.AccessController.doPrivileged(Native Method)

    at com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(ObjectTable.java:565)
    at com.sun.jini.jeri.internal.runtime.ObjectTable$Target.dispatch(ObjectTable.java:540)
    at com.sun.jini.jeri.internal.runtime.ObjectTable$RD.dispatch(ObjectTable.java:778)
    at net.jini.jeri.connection.ServerConnectionManager$Dispatcher.dispatch(ServerConnectionManager.java:148)
    at com.sun.jini.jeri.internal.mux.MuxServer$2.run(MuxServer.java:244)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.jini.jeri.internal.mux.MuxServer$1.run(MuxServer.java:241)
    at com.sun.jini.thread.ThreadPool$Worker.run(ThreadPool.java:136)
    at java.lang.Thread.run(Thread.java:619)

Can you all please give me an advise. many thanks in advance.

madumm h4. Attachments


{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3545]{quote}

asked 2010-11-17 23:12:35 -0500

madumm gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

Are you mixing Jini and Gigaspaces jars?
How your classpath looks like?
You should not add Jini classes to your classpath when using GigaSpaces.
Please post your entire code.


  1. Files.rar

answered 2010-11-18 06:38:05 -0500

shay hassidim gravatar image
edit flag offensive delete link more


yeah, i'm using Jini in my code, what i really want to do is when the space get a Request (RequestObject see attached code) it should send a notification, that I have done, but the generated notification is a RemoteEvent of Jini, from that i can't get the Request object Details such as ServiceName, methodName etc, I have found that JSpace has "EntryArrivedRemoteEvent " which as the capability to get those data, but when i do that i get the "ClassCastException".

What i reallayy want to do is to get the Details of the Request, (Request on what methos, Service, provider ID etc). attached the code.

Can you please advice me

Many thanks in advance


  1. Files.rar
madumm gravatar imagemadumm ( 2010-11-18 21:12:37 -0500 )edit

Here is what I suggest:
- Start a space using the \gigaspaces-xap-root\bin\gsInstance script - This will start a jini lookup and a space named mySpace
- Use RequestObject POJO instead of Entry. Make sure it will have no-arg constructor and getter/setter methods for each field. See all the GigaSpaces annotations you can use below.
- Have all the jars located under \gigaspaces-xap-root\lib\required as part of your application classpath. DO NOT add anything else beyond your application classes/jars. Do not use the Jini jars.
- Use GigaSpaces notify container:

- getting notifications:

GigaSpace gigaSpace = new GigaSpaceConfigurer(new UrlSpaceConfigurer("jini://*/*/mySpace")).gigaSpace();
    notifyEventListenerContainer = new SimpleNotifyContainerConfigurer(space)
    .template(new RequestObject())
    .eventListenerAnnotation(new Object()
        public void eventHappened(RequestObject requestObject) {
        System.out.println("onEvent called Got" + requestObject);
while (true)

- writing the object:

GigaSpace gigaSpace = new GigaSpaceConfigurer(new UrlSpaceConfigurer("jini://*/*/mySpace")).gigaSpace();
RequestObject requestObject = new RequestObject(msg,sname,mname,sid,pid,cid);

See more:

When using GigaSpaces - Do not use the jini libraries. We are already embedding these internally.


shay hassidim gravatar imageshay hassidim ( 2010-11-19 00:18:13 -0500 )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: 2010-11-17 23:12:35 -0500

Seen: 50 times

Last updated: Nov 18 '10