AnsweredAssumed Answered

Error running 5.12 unit tests with Java 7

Question asked by brianshowers on Mar 19, 2013
Latest reply on Mar 26, 2013 by brianshowers
Due to the issue with saving TaskEntry objects (originally mentioned here), we are currently using a forked and patched version of Activiti v5.11.  I wanted to upgrade to v5.12, so I was going to reapply my patch on top of the 5.12 tag and rebuild.  However, I've started getting an error running the Activiti unit tests in 5.12 under a Java 7 JVM.

Specifically, what I see is org.activiti.examples.bpmn.scripttask.ScriptTaskTest::testAutoStoreVariables() fails with the following exception:

Environment: Windows 7, Java 1.7.0_17

Test set: org.activiti.examples.bpmn.scripttask.ScriptTaskTest
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.193 sec <<< FAILURE!
testAutoStoreVariables(org.activiti.examples.bpmn.scripttask.ScriptTaskTest)  Time elapsed: 0.075 sec  <<< ERROR!
org.activiti.engine.ActivitiException: couldn't find a variable type that is able to serialize
   at org.activiti.engine.impl.variable.DefaultVariableTypes.findVariableType(
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.createVariableInstance(
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.createVariableLocal(
   at org.activiti.engine.impl.persistence.entity.VariableScopeImpl.createVariableLocal(

   at org.activiti.engine.impl.TaskServiceImpl.complete(
   at org.activiti.examples.bpmn.scripttask.ScriptTaskTest.testAutoStoreVariables(
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(
   at java.lang.reflect.Method.invoke(
   at junit.framework.TestCase.runTest(
   at org.activiti.engine.impl.test.PvmTestCase.runTest(
   at junit.framework.TestCase.runBare(
   at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(
   at junit.framework.TestResult$1.protect(
   at junit.framework.TestResult.runProtected(
   at junit.framework.TestSuite.runTest(
   at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(
   at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(
   at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(
   at java.lang.reflect.Method.invoke(
   at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(
   at com.sun.proxy.$Proxy0.invoke(Unknown Source)
   at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(
   at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(
   at org.apache.maven.surefire.booter.ForkedBooter.main(

However, if I run the same test using a Java 1.6.0_25 JVM, it passes!

I spent some time stepping through the test in the debugger, and it seems to come down to a change in the implementation.  In the Java 6 implemenation, that class implements Serializable.  So, org.activiti.engine.impl.variable.DefaultVariableTypes::findVariableType() is able to map Undefined to Serializable.

However, in Java 1.7, it appears that does not implement Serializeable.  So, no valid type can be found and an exception is thrown.

I haven't been able to track down any source code for the Undefined class, so it's a bit hard for me to tell for certain, but this test fails for me in Java 7 and passes in Java 6:

  public void testUndefinedType() {
      boolean serializable = (Undefined.instance instanceof Serializable);

While it's not that big of deal if I can't run the Activiti tests in the Java 1.7 VM, I think the issue might be bigger than that.  I think that Activiti won't be able to save script variables of an undefined type in a Java 7 JVM.