Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-9251

Use context class loader for loading JSON mapping target classes

    XMLWordPrintable

    Details

    • Type: Bug Report
    • Status: Closed
    • Priority: L3 - Default
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.10.0, 7.10.0-alpha3
    • Component/s: spin
    • Labels:
      None

      Description

      Related to https://github.com/camunda/camunda-spin/pull/19
      The current implementation is problematic if using Camunda BPM together with Spring Boot's Developer Tools (and possibly other non-trivial classloading environments). If the class to be mapped from JSON already was loaded from another classloader you end up with a ClassCastException like this:

      java.lang.ClassCastException: com.example.MyClassMappedFromJson cannot be cast to com.example.MyClassMappedFromJson

      This is the case if using the Spring Boot Developer Tools. Per default classes in your current project (MyClassMappedFromJson from the example) are loaded with a RestartClassLoader while Class.forName(typeIdentifer) loads the class a second time with the current class loader which produces this incompatiblity.

      Always using the context class loader fixes the problem: https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/htmlsingle/#using-boot-devtools-known-restart-limitations

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              yana.vasileva Yana Vasileva
              Reporter:
              yana.vasileva Yana Vasileva
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: