Netflix / glisten

Ease of use Groovy library for building JVM applications with Amazon Simple Workflow (SWF)
Apache License 2.0
67 stars 31 forks source link

QUESTION: Why am I seeing ClassCastExceptions? #37

Closed fzakaria closed 8 years ago

fzakaria commented 9 years ago

When I grab the activities with the code listed in the example in my workflow such as:

@Override
void start() {
    def pendingActionPromise = activities.fetchPendingActions();
    waitFor(pendingActionPromise) { pendingActions ->

        def promises = []
        pendingActions.each { action ->
            promises << activities.applyPendingAction(action)
        }

        waitFor(allPromises(promises)) {
         status it
        }

    }
}

The call to getActivities throws ClassCastException. For some reason it won't cast AsyncCaller to the activity interface. I don't see anything different that I've setup in my code from your example.

Here is the actual error:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.netflix.glisten.impl.swf.AsyncCaller(interface com.pending.PendingActionActivities, null, com.netflix.glisten.impl.swf.AsyncCaller$DynamicActivitiesClientFactory(class com.amazonaws.services.simpleworkflow.flow.DynamicActivitiesClientImpl))' with class 'com.netflix.glisten.impl.swf.AsyncCaller' to class 'com..pending.PendingActionActivities'

fzakaria commented 9 years ago

What's odd is that if I retrieve the WorkflowOperations (not via @Delegate) then I don't see the error.

ex.

getWorkflowOperations().getActivities()
fzakaria commented 9 years ago

I made this stackoverflow to track this question: http://stackoverflow.com/questions/32151309/why-do-i-see-classcastexception-in-groovy-through-delegate-method

jdappel commented 8 years ago

@fzakaria What JDK version are you using?

fzakaria commented 8 years ago

oh boi, this was long time ago. We can close if you'd like - the context for me is gone.