Ignite Spring Integration seems broken with 2.4 (upgrading from 2.3)

。_饼干妹妹 提交于 2019-12-13 04:09:39

问题


We are upgrading from 2.3 to 2.4 & realized that a change made in IgniteSpringBean which is referenced in this added line in its javadoc resulted in us moving lots of references in PostConstruct to handleContextRefresh.

"A note should be taken that Ignite instance is started after all other Spring beans have been initialized and right before Spring context is refreshed. That implies that it's not valid to reference IgniteSpringBean from any kind of Spring bean init methods like PostConstruct. If it's required to reference IgniteSpringBean for other bean initialization purposes, it should be done from a ContextRefreshedEvent listener method declared in that bean."

However this breaks ignite spring transaction configuration configured as per the suggestion there which i am not sure how to resolve. Basically we have the below in the spring application xml where both IgniteSpringBean & SpringTransactionManager are configured which was working in 2.3 but fails to start up referencing the above change with 2.4 (i will add the exception in a bit as my machine went down suddenly),

<bean id="igniteSpringBean" class="org.apache.ignite.IgniteSpringBean">
    <property name="configuration">
        <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
            <property name="igniteInstanceName" value="ObjectManagerGrid"/>
            <property name="clientMode" value="true"/>
            ...
            ...
        </bean>
    </property>
</bean>

<!-- Enable Spring transaction abstraction for Ignite transactions -->
<bean id="transactionManager" class="org.apache.ignite.transactions.spring.SpringTransactionManager">
    <property name="igniteInstanceName" value="ObjectManagerGrid"/>
    <property name="transactionConcurrency" value="PESSIMISTIC"/>
</bean>

<!-- Enable annotation-driven transaction configuration/demarcation -->
<tx:annotation-driven/>

Any clue on how to work around this problem?

Thanks!

UPDATE: Below is the exception,

ignite-object-manager - [ERROR] 2018-05-24 18:36:45.133 [main] org.springframework.boot.SpringApplication - Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is class org.apache.ignite.IgniteIllegalStateException: Ignite instance with provided name doesn't exist. Did you call Ignition.start(..) to start an Ignite instance? [name=ObjectManagerGrid] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 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:866) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at com.brocade.dcm.Application.main(Application.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) Caused by: org.apache.ignite.IgniteIllegalStateException: Ignite instance with provided name doesn't exist. Did you call Ignition.start(..) to start an Ignite instance? [name=ObjectManagerGrid] at org.apache.ignite.internal.IgnitionEx.grid(IgnitionEx.java:1376) at org.apache.ignite.Ignition.ignite(Ignition.java:530) at org.apache.ignite.transactions.spring.SpringTransactionManager.afterPropertiesSet(SpringTransactionManager.java:357) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ... 22 common frames omitted


回答1:


It was not broken, but rather fixed in IGNITE-6555.

Unfortunately it also means that you will have to find a way to defer SpringTransactionManager creation/initialization for now.

More details about the issue on user list.



来源:https://stackoverflow.com/questions/50517123/ignite-spring-integration-seems-broken-with-2-4-upgrading-from-2-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!