ClassLoader for the enums within the workflow class is different?

78 views
Skip to first unread message

Eugene Dzhurinsky

unread,
Oct 4, 2016, 2:45:15 PM10/4/16
to COPPER Engine
Hello!

I am using the persistent workflow now, and I have some weird problem - if I retrieve the event from within the workflow through the wfEventResponse.getResponse() - I get the error 

java.lang.ClassCastException: my.workflow.process.SimpleSignupWorkflow$Events cannot be cast to my.workflow.process.SimpleSignupWorkflow$Events

Events is enum here. And it looks like the instance of the workflow retrieved from the database uses the different classloader rather than the engine that fires the event.

If I change the type of the Events from 

  public enum Events {
     OPEN
, CLICK
 
}


to

    public static class Events {
       
public static final String OPEN = "OPEN";
       
public static final String CLICK = "CLICK";
   
}

Everything works fine though.

Have you faced this kind of problem before?

Michael Austermann

unread,
Oct 4, 2016, 2:53:39 PM10/4/16
to copper...@googlegroups.com
..SimpleSignupWirkflow$Events seems to be an inner class/enum of your workflow.
Move all classes which are used inside and outside of the workflow classes to your "normal" source directory.
Leave only the workflow classes in the workflow source folder (or their package if you are using the classpath repo).

Copper uses a special class loader to load workflow classes, so if their folder contains other classes, this might lead to the problem that you described.
In java a class is identified by its name and the classloader that loaded it, so two classes with the same name but loaded from different class loaders are not compatible.



Von: "Eugene Dzhurinsky" <jdev...@gmail.com>
An: "COPPER Engine" <copper...@googlegroups.com>
Gesendet: Dienstag, 4. Oktober 2016 20:45:14
Betreff: [COPPER Users] ClassLoader for the enums within the workflow class is different?

--
You received this message because you are subscribed to the Google Groups "COPPER Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copper-engin...@googlegroups.com.
To post to this group, send email to copper...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copper-engine/906f0fd4-adc1-4b01-996f-a833027c4c78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Sebastian Z.

unread,
Oct 4, 2016, 5:41:38 PM10/4/16
to COPPER Engine
Hi,
I had exactly the same issue, despite the correct class locations.

After a few hours of investigation, I narrowed it down to the usage of Spring with Spring DevTools (which use a different classloader).
If you use Spring with DevTools, try adding the file "spring-devtools.properties" to your resources/META-INF/ folder (create if missing) (my full path:)

src/main/resources/META-INF/spring-devtools.properties

and add the following two lines:


restart.include.copper.core=/copper-coreengine-4.1.1.jar
restart.include.copper.spring=/
copper-spring-4.1.1.jar


Afterwards, my ClassCastExceptions were gone!

- Sebastian
Reply all
Reply to author
Forward
0 new messages