So looks like one fix may be to,
1. Have IgniteSpringBean publish an Ignite application event on Ignite
instance start from inside of its ' afterSingletonsInstantiated()' method (
@Override public void afterSingletonsInstantiated())
2. Then have SpringTransactionManager listen to the event & execute the
code currently in its 'afterPropertiesSet()' method ( @Override public void
afterPropertiesSet() throws Exception) by moving it to the event handler
method.
This way SpringTransactionManager can finish its intended custom
initialization AFTER ignite instance is started other wise the below
highlighted line will fail as its happening now,
@Override public void afterPropertiesSet() throws Exception {
assert ignite == null;
if (cfgPath != null && cfg != null) {
throw new IllegalArgumentException("Both 'configurationPath'
and 'configuration' are " +
"provided. Set only one of these properties if you need
to start a Ignite node inside of " +
"SpringCacheManager. If you already have a node
running, omit both of them and set" +
"'igniteInstanceName' property.");
}
if (cfgPath != null)
ignite = IgniteSpring.start(cfgPath, springCtx);
else if (cfg != null)
ignite = IgniteSpring.start(cfg, springCtx);
else
* ignite = Ignition.ignite(igniteInstanceName);*
if (transactionConcurrency == null)
transactionConcurrency =
ignite.configuration().getTransactionConfiguration().getDefaultTxConcurrency();
log = ignite.log();
}
Regards,
Muthu
On Thu, May 24, 2018 at 8:58 PM, mlekshma <[email protected]> wrote:
> Hi,
>
> I see that with a change introduced in 2.4 in IgniteSpringBean to delay
> ignite instance start until all other spring beans are initialized may have
> broken Ignite SpringTransactionManager
> <https://ignite.apache.org/releases/latest/javadoc/org/
> apache/ignite/transactions/spring/SpringTransactionManager.html>
> resulting in inability to configure it for Spring transaction abstraction
> of
> Ignite transactions. I really, badly need to find a way to work around
> this.
> Any ideas/suggestions anyone?
>
> Below is the line from IgniteSpringBean
> <https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/
> IgniteSpringBean.html>
> java doc
> /*"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. "
> */
>
> The problem is since SpringTransactionManager implements
> org.springframework.beans.factory.InitializingBean & in the
> afterPropertiesSet() call that spring calls it tries to look for the
> igniteInstanceName that's specified but since the instance is started only
> AFTER all other Spring beans have been initialized, it fails with
> IgniteIllegalStateException,
>
> Please see below stack trace,
>
> lass]: 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.AbstractAutowireCapableBeanFac
> tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.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.AbstractAutowireCapableBeanFac
> tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
> at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac
> tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)*
> ... 22 common frames omitted
>
> Thanks
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>