Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-12664

ContentProperty NPE when using a configured enumerator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 4.9.8, 4.10.0
    • None
    • None
    • None

      Have a java ContentProperty with a configured enumerator.

                  <cms:property name="migrationRequired" class="fr.aws.prodige.search.properties.NeedsMigrationProperty">
                      <label i18n="false">Migration nécessaire</label>
                      <description i18n="false">Est-ce que ce projet doit faire une migration ?</description>
                      <enumeration>
                          <entry><label>Aucune</label><value>0</value></entry>
                          <entry><label>Mineure</label><value>1</value></entry>
                          <entry><label>Majeure</label><value>2</value></entry>
                      </enumeration>
                  </cms:property>
      

      during startup NPE

      Caused by: java.lang.Exception: Caught an exception trying to initialize the component application-fr.aws.prodige.search.properties.NeedsMigrationProperty-10
      	at org.ametys.runtime.plugin.component.ThreadSafeComponentManager.initialize(ThreadSafeComponentManager.java:236)
      	at org.ametys.cms.contenttype.DefaultContentType._lookupProperties(DefaultContentType.java:784)
      	... 101 more
      Caused by: org.apache.avalon.framework.configuration.ConfigurationException: An error occured while configuring the enumerator of the property required
      	at org.ametys.cms.model.properties.AbstractStaticProperty._parseAndSetEnumerator(AbstractStaticProperty.java:168)
      	at org.ametys.cms.model.properties.AbstractStaticProperty.configure(AbstractStaticProperty.java:61)
      	at org.apache.avalon.framework.container.ContainerUtil.configure(ContainerUtil.java:202)
      	at org.ametys.runtime.plugin.component.ThreadSafeComponentManager$ComponentFactory.configureAndStart(ThreadSafeComponentManager.java:401)
      	at org.ametys.runtime.plugin.component.ThreadSafeComponentManager$ComponentFactory.newInstance(ThreadSafeComponentManager.java:420)
      	at org.ametys.runtime.plugin.component.ThreadSafeComponentManager.initialize(ThreadSafeComponentManager.java:230)
      	... 102 more
      Caused by: java.lang.NullPointerException: Cannot invoke "org.ametys.cms.data.type.indexing.IndexableElementType.parseConfiguration(org.apache.avalon.framework.configuration.Configuration)" because the return value of "org.ametys.cms.model.properties.AbstractStaticProperty.getType()" is null
      	at org.ametys.cms.model.properties.AbstractStaticProperty._parseAndSetEnumerator(AbstractStaticProperty.java:157)
      	... 107 more
      

      My dirsty workaround is to initiate the type during the configuration in my property

      @Override
          public void configure(Configuration configuration) throws ConfigurationException
          {
              try
              {
                  init(ModelItemTypeExtensionPoint.ROLE_CONTENT_PROPERTY);
              }
              catch (Exception e)
              {
                  throw new ConfigurationException("Cannot initialize property " + getClass().getName(), e);
              }
              super.configure(configuration);
          }
      

            Unassigned Unassigned
            raphael Raphaël Franchet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: