OpenJPA
  1. OpenJPA
  2. OPENJPA-1960

openjpa.InitializeEagerly breaks bean-validation integration

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0, 2.2.0
    • Fix Version/s: 2.2.0
    • Component/s: kernel, validation
    • Labels:
      None

      Description

      <property name="openjpa.InitializeEagerly" value="true"/> breaks the bean-validation integration

      AbstractBrokerFactory#makeReadOnly
      evaluates conf.isInitializeEagerly() which returns true (due to the config) and calls _conf.setReadOnly(Configuration.INIT_STATE_FROZEN)
      + at the end of AbstractBrokerFactory#initializeBroker it gets called again

      that causes:
      the created BrokerFactory gets used as argument for PersistenceProviderImpl#loadValidator which fails (with a warning or an exception depending on the validation-mode configured in the persistence.xml) because the config is in state INIT_STATE_FROZEN

        Activity

        Hide
        Albert Lee added a comment -

        Close issue in preparation for 2.2.0 release.

        Show
        Albert Lee added a comment - Close issue in preparation for 2.2.0 release.
        Hide
        Rick Curtis added a comment -

        Committed revision 1084349 to trunk.

        Show
        Rick Curtis added a comment - Committed revision 1084349 to trunk.
        Hide
        Gerhard Petracek added a comment -

        your bypass of #assertChangeable works

        Show
        Gerhard Petracek added a comment - your bypass of #assertChangeable works
        Hide
        Rick Curtis added a comment -

        Gerhard -

        Please give the attached patch a try.

        I really don't like the change, but I want to make sure I am looking at fixing the same path that you are reporting. Once I get the thumbs up from you I'll see about fixing this another way.

        Thanks,
        Rick

        Show
        Rick Curtis added a comment - Gerhard - Please give the attached patch a try. I really don't like the change, but I want to make sure I am looking at fixing the same path that you are reporting. Once I get the thumbs up from you I'll see about fixing this another way. Thanks, Rick
        Hide
        Rick Curtis added a comment -

        Attaching a test fix. The jar has a patch file of the changes, and the compiled .class change.

        Show
        Rick Curtis added a comment - Attaching a test fix. The jar has a patch file of the changes, and the compiled .class change.
        Hide
        Gerhard Petracek added a comment -

        with the default validation mode (== auto):
        WARN [btpool0-1] openjpa.Runtime - Could not create the optional validation provider. Reason returned: "Can not modify "LifecycleEventManager" because the property is not dynamic and the current configuration is read-only."

        in case of <validation-mode>CALLBACK</validation-mode> it is:
        Caused by: java.lang.RuntimeException: Can not modify "LifecycleEventManager" because the property is not dynamic and the current configuration is read-only.
        at org.apache.openjpa.lib.conf.Value.assertChangeable(Value.java:480)
        at org.apache.openjpa.lib.conf.PluginValue.setString(PluginValue.java:135)
        at org.apache.openjpa.conf.OpenJPAConfigurationImpl.setLifecycleEventManager(OpenJPAConfigurationImpl.java:1742)
        at org.apache.openjpa.persistence.validation.ValidationUtils.setupValidation(ValidationUtils.java:103)
        at org.apache.openjpa.persistence.PersistenceProviderImpl.loadValidator(PersistenceProviderImpl.java:325)
        at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:104)

        Show
        Gerhard Petracek added a comment - with the default validation mode (== auto): WARN [btpool0-1] openjpa.Runtime - Could not create the optional validation provider. Reason returned: "Can not modify "LifecycleEventManager" because the property is not dynamic and the current configuration is read-only." in case of <validation-mode>CALLBACK</validation-mode> it is: Caused by: java.lang.RuntimeException: Can not modify "LifecycleEventManager" because the property is not dynamic and the current configuration is read-only. at org.apache.openjpa.lib.conf.Value.assertChangeable(Value.java:480) at org.apache.openjpa.lib.conf.PluginValue.setString(PluginValue.java:135) at org.apache.openjpa.conf.OpenJPAConfigurationImpl.setLifecycleEventManager(OpenJPAConfigurationImpl.java:1742) at org.apache.openjpa.persistence.validation.ValidationUtils.setupValidation(ValidationUtils.java:103) at org.apache.openjpa.persistence.PersistenceProviderImpl.loadValidator(PersistenceProviderImpl.java:325) at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:104)
        Hide
        Rick Curtis added a comment -

        What is the exception / warning that you are getting?

        Thanks,
        Rick

        Show
        Rick Curtis added a comment - What is the exception / warning that you are getting? Thanks, Rick

          People

          • Assignee:
            Rick Curtis
            Reporter:
            Gerhard Petracek
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development