0
votes

I'm attempting to start Ignite with some XML configs, and I'm following the documentation, but I can't get it to start. Here are my configs:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">
  <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="cacheConfiguration">
        <list>
            <!-- Partitioned cache example configuration (Atomic mode). -->
            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="default"/>
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="1"/>
                <property name="eagerTtl" value="true"/>
            </bean>
        </list>
    </property>
    <property name="expiryPolicyFactory">
        <bean class="javax.cache.expiry.CreatedExpiryPolicy" factory-method="factoryOf">
            <constructor-arg>
                <bean class="javax.cache.expiry.Duration">
                    <constructor-arg value="MINUTES"/>
                    <constructor-arg value="5"/>
                </bean>
            </constructor-arg>
        </bean>
    </property>
  </bean>
</beans>

When I try using these configs, I get these exceptions:

$ bin/ignite.sh /path/to/etc/cache.xml class org.apache.ignite.IgniteException: Failed to instantiate Spring XML application context [springUrl=file:/path/to/etc/cache.xml, err=Error creating bean with name 'ignite.cfg' defined in URL [file:/path/to/etc/cache.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'expiryPolicyFactory' of bean class [org.apache.ignite.configuration.IgniteConfiguration]: Bean property 'expiryPolicyFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?] at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1029) at org.apache.ignite.Ignition.start(Ignition.java:351) at org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:301) Caused by: class org.apache.ignite.IgniteCheckedException: Failed to instantiate Spring XML application context [springUrl=file:/path/to/etc/cache.xml, err=Error creating bean with name 'ignite.cfg' defined in URL [file:/path/to/etc/cache.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'expiryPolicyFactory' of bean class [org.apache.ignite.configuration.IgniteConfiguration]: Bean property 'expiryPolicyFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?] at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:392) at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104) at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98) at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:751) at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:952) at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:861) at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:731) at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:700) at org.apache.ignite.Ignition.start(Ignition.java:348) ... 1 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ignite.cfg' defined in URL [file:/path/to/etc/cache.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'expiryPolicyFactory' of bean class [org.apache.ignite.configuration.IgniteConfiguration]: Bean property 'expiryPolicyFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1284) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:381) ... 9 more Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'expiryPolicyFactory' of bean class [org.apache.ignite.configuration.IgniteConfiguration]: Bean property 'expiryPolicyFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? at org.springframework.beans.BeanWrapperImpl.createNotWritablePropertyException(BeanWrapperImpl.java:239) at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:435) at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:290) at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1570) ... 20 more Failed to start grid: Failed to instantiate Spring XML application context [springUrl=file:/path/to/etc/cache.xml, err=Error creating bean with name 'ignite.cfg' defined in URL [file:/path/to/etc/cache.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'expiryPolicyFactory' of bean class [org.apache.ignite.configuration.IgniteConfiguration]: Bean property 'expiryPolicyFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?]

I checked the source code for Ignite, and just like the exception states, expiryPolicyFactory is not a property on org.apache.ignite.configuration.IgniteConfiguration.

The Ignite document that I'm using for the config (for setting the expiration policy) is here: https://apacheignite.readme.io/docs/expiry-policies which states:

<bean class="org.apache.ignite.configuration.CacheConfiguration">
    ...

    <property name="expiryPolicyFactory">
        <bean class="javax.cache.expiry.CreatedExpiryPolicy" factory-method="factoryOf">
            <constructor-arg>
                <bean class="javax.cache.expiry.Duration">
                    <constructor-arg value="MINUTES"/>
                    <constructor-arg value="5"/>
                </bean>
            </constructor-arg>
        </bean>
    </property>
</bean>

(I'm using Ignite 2.7.6.)

How am I supposed to define the expiration policy for Ignite?

1

1 Answers

0
votes

I just realized that the issue is that I was putting the config in the wrong location. I got this to config work:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">
  <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="cacheConfiguration">
        <list>
            <!-- Partitioned cache example configuration (Atomic mode). -->
            <bean class="org.apache.ignite.configuration.CacheConfiguration">
                <property name="name" value="default"/>
                <property name="atomicityMode" value="ATOMIC"/>
                <property name="backups" value="1"/>
                <property name="eagerTtl" value="true"/>
                <property name="expiryPolicyFactory">
                  <bean class="javax.cache.expiry.CreatedExpiryPolicy" factory-method="factoryOf">
                      <constructor-arg>
                          <bean class="javax.cache.expiry.Duration">
                              <constructor-arg value="MINUTES"/>
                              <constructor-arg value="5"/>
                          </bean>
                      </constructor-arg>
                  </bean>
              </property>
            </bean>
        </list>
    </property>
  </bean>
</beans>