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

@Dependent scoped beans in EL expressions are prematurely destroyed with Weld versions > 1.1.4

    Details

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

      Description

      Problem

      • When using a @Dependent scoped bean in an EL expression, the bean is destroyed while it is still in use; i.e. given an expression ${foo.bar()}, #bar is invoked after foo is destroyed
      • Problem occurs with Weld versions > 1.1.4
      • E.g. JBoss 7.2 uses Weld 1.1.10; Wildfly probably uses newer versions

      Reason

      My interpretation:

      • I think we are using the CDI API incorrectly here. It appears that BeanManager#wrapExpressionFactory is exactly made for this case, i.e. it wraps a given expression factory such that any expressions produced make sure that a creational context is created for the entirety of the EL invocation => we should wrap our expression factory this way
      • This proposed fix is not trivial because
        • We do not use javax.el.ExpressionFactory in our code base but include use our own org.camunda.bpm.engine.impl.javax.el.ExpressionFactory
        • I think this requires to have one expression factory per process application (assuming different applications have different bean managers???), whereas we are currently using one expression factory per process engine
      • Thus, a pragmatic way could be to always look up beans "our" way (catch clause in https://github.com/camunda/camunda-bpm-platform/blob/master/engine-cdi/src/main/java/org/camunda/bpm/engine/cdi/impl/el/CdiResolver.java#L61-L70); not sure if that breaks anything else, though

      Related links:

        Issue Links

          Activity

          Hide
          tassilo.weidner Tassilo Weidner added a comment - - edited

          Besides the above-mentioned concerns the proposed fix would also cause a potential memory leak in a shared engine setup.
          If the CDI application is shutdown, the ExpressionFactory object consists of unreachable references due to caching performed by the engine. If the enforcement of the programmatic bean lookup breaks no test cases in all supported environments, this approach should be chosen.

          Application Server Weld Core Version Open WebBeans Version engine-cdi tests passed comment
          Apache Tomcat 6.0       CDI is not implemented
          Apache Tomcat 7.0       CDI is not implemented
          Apache Tomcat 8.0       CDI is not implemented
          JBoss Application Server 7.2 1.1.10.Final    
          wildfly 8.2.0 2.2.6.Final    
          wildfly 10.1.0 2.3.5.Final    
          JBoss EAP 6.1 1.1.13.Final    
          JBoss EAP 6.2 1.1.16.Final    
          JBoss EAP 6.3 1.1.23.Final    
          JBoss EAP 6.4 1.1.28.Final    
          JBoss EAP 7.0 2.3.3.Final    
          IBM Websphere Application Server 8.0   1.1.0 version information found in JAR file
          IBM Websphere Application Server 8.5   1.1.0 version information found in JAR file
          IBM Websphere Application Server 9.0 2.3.4.Final   version information found in JAR file
          Oracle WebLogic Server 12.2.1 2.2.13.Final   version information found in JAR file
          Oracle WebLogic Server 12R2 2.2.13.Final   version information found in JAR file

          It seems like the maven profile openwebbeans-embedded-1 is currently not executed on jenkins. If it is executed locally 12 test cases fail due to a null pointer exception. The defined Open Web Beans version in the pom.xml is 1.1.3 whereas the version used by websphere is 1.1.0. If the version is set to 1.1.0 all test cases fail because of a dependency problem.

          This misbehavior is not related to the bugfix.

          Show
          tassilo.weidner Tassilo Weidner added a comment - - edited Besides the above-mentioned concerns the proposed fix would also cause a potential memory leak in a shared engine setup. If the CDI application is shutdown, the ExpressionFactory object consists of unreachable references due to caching performed by the engine. If the enforcement of the programmatic bean lookup breaks no test cases in all supported environments, this approach should be chosen. Application Server Weld Core Version Open WebBeans Version engine-cdi tests passed comment Apache Tomcat 6.0       CDI is not implemented Apache Tomcat 7.0       CDI is not implemented Apache Tomcat 8.0       CDI is not implemented JBoss Application Server 7.2 1.1.10.Final     wildfly 8.2.0 2.2.6.Final     wildfly 10.1.0 2.3.5.Final     JBoss EAP 6.1 1.1.13.Final     JBoss EAP 6.2 1.1.16.Final     JBoss EAP 6.3 1.1.23.Final     JBoss EAP 6.4 1.1.28.Final     JBoss EAP 7.0 2.3.3.Final     IBM Websphere Application Server 8.0   1.1.0 version information found in JAR file IBM Websphere Application Server 8.5   1.1.0 version information found in JAR file IBM Websphere Application Server 9.0 2.3.4.Final   version information found in JAR file Oracle WebLogic Server 12.2.1 2.2.13.Final   version information found in JAR file Oracle WebLogic Server 12R2 2.2.13.Final   version information found in JAR file It seems like the maven profile openwebbeans-embedded-1 is currently not executed on jenkins. If it is executed locally 12 test cases fail due to a null pointer exception. The defined Open Web Beans version in the pom.xml is 1.1.3 whereas the version used by websphere is 1.1.0. If the version is set to 1.1.0 all test cases fail because of a dependency problem. This misbehavior is not related to the bugfix.

            People

            • Assignee:
              thorben.lindhauer Thorben Lindhauer
              Reporter:
              thorben.lindhauer Thorben Lindhauer
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development