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

Ask Your Question
0

Polling Container Class cast exception

Hi

I am trying to create a Polling container that accepts an array of events rather than a single event. However my implementation always throws a Class Cast Exception (because its passing a single event instead of an array). I must be doing something wrong, but I can't figure out what it is.

I also get the same exception using the sample code on the site;

@EventDriven @Polling(passArrayAsIs = true) public class SimpleBatchListener {

@ReceiveHandler
ReceiveOperationHandler receiveHandler() {
    MultiTakeReceiveOperationHandler receiveHandler = new MultiTakeReceiveOperationHandler();
    receiveHandler.setMaxEntries(100);
    return receiveHandler;
}

@EventTemplate
ManualMatchEvent unprocessedData() {
    ManualMatchEvent template = new ManualMatchEvent();
    template.setProcessed(false);
    return template;
}

@SpaceDataEvent
public ManualMatchEvent[] eventListener(ManualMatchEvent events[]) {
    //process Data within a loop
for (int i = 0; i < events.length; i++) {
    events[i].setProcessed(true);
}

return events; } }

org.openspaces.events.ListenerExecutionFailedException: Listener event method [eventListener] of class [SimpleBatchListener] threw exception; nested exception is java.lang.ClassCastException: ManualMatchEvent cannot be cast to [LManualMatchEvent; at org.openspaces.events.adapter.AbstractReflectionEventListenerAdapter.onEventWithResult(AbstractReflectionEventListenerAdapter.java:178) ~[gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at org.openspaces.events.adapter.AbstractResultEventListenerAdapter.onEvent(AbstractResultEventListenerAdapter.java:75) ~[gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at org.openspaces.events.AbstractEventListenerContainer.invokeListener(AbstractEventListenerContainer.java:194) ~[gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at org.openspaces.events.polling.AbstractPollingEventListenerContainer.doReceiveAndExecute(AbstractPollingEventListenerContainer.java:288) [gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at org.openspaces.events.polling.AbstractPollingEventListenerContainer.receiveAndExecute(AbstractPollingEventListenerContainer.java:274) [gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at org.openspaces.events.polling.SimplePollingEventListenerContainer$AsyncEventListenerInvoker.invokeListener(SimplePollingEventListenerContainer.java:721) [gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at org.openspaces.events.polling.SimplePollingEventListenerContainer$AsyncEventListenerInvoker.run(SimplePollingEventListenerContainer.java:662) [gs-openspaces-10.0.1-XAPPremium-ga.jar:10.0.1-11800-RELEASE] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_80]

asked 2015-09-02 06:13:25 -0600

M_B gravatar image
edit retag flag offensive close merge delete

Comments

Ok I solved this - I was testing this using a SimplePollingEventListenerContainer. I had to call .setPassArrayAsIs(true);

M_B gravatar imageM_B ( 2015-09-02 06:26:21 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

Since you were able to figure out that you were missing "passArrayAsIs", you may want to take another look at your pu.xml. If you are using annotations, make sure your pu.xml contains the following:

<context:component-scan base-package="com.my.package" /> 

<os-events:annotation-support />

If you are using beans:

    <bean id="eventContainer" class="org.openspaces.events.polling.SimplePollingEventListenerContainer">
...
        <property name="passArrayAsIs" value="true" />

Hope that helps,

Dixson

answered 2015-09-09 14:07:54 -0600

Dixson Huie gravatar image

updated 2015-09-09 15:02:51 -0600

edit flag offensive delete link more

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

Stats

Asked: 2015-09-02 06:13:25 -0600

Seen: 2,199 times

Last updated: Sep 09 '15