You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by ignite_user2016 <ri...@gmail.com> on 2018/10/09 17:56:34 UTC

Ignite on Spring Boot 2.0

Hello..

I am using Ignite with Spring boot version 1.5.8, all works well but when I
try to upgrade my spring boot app to 2.0.1 version some how
SpringCacheManager does not work.

Here is my piece of code - 

   /**
     * Provides SpringCacheManager to enable 2nd level caching on Ignite
     *
     * @return SpringCacheManager
     */
    @Bean
    public SpringCacheManager SpringCacheManager() {
        SpringCacheManager springCacheManager = new SpringCacheManager();
        springCacheManager.setGridName("WebGrid");
        return springCacheManager;
    }


During debug, I found out that following piece of code does not work - 

this.ignite = Ignition.ignite(this.igniteInstanceName);


So somehow, It cant join the existing instance on spring boot 2.0

Please note that ignite instance starts correctly but when it tries to join
it, it cant find the grid instance.

Did anyone experienced such issue ? 




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Ignite on Spring Boot 2.0

Posted by ignite_user2016 <ri...@gmail.com>.
I will share a sample application soon.. stay tuned ...



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Ignite on Spring Boot 2.0

Posted by Stanislav Lukyanov <st...@gmail.com>.
Ignite 2.0 is FAR from being recent :)
Try Ignite 2.6. If it doesn’t work, share configuration, logs and code that starts Ignite.

Thanks,
Stan

From: ignite_user2016
Sent: 9 октября 2018 г. 22:00
To: user@ignite.apache.org
Subject: Re: Ignite on Spring Boot 2.0

Small update - 

I also upgraded ignite to recent version but no use.

Current version is Ignite 2.0





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Ignite on Spring Boot 2.0

Posted by ignite_user2016 <ri...@gmail.com>.
Small update - 

I also upgraded ignite to recent version but no use.

Current version is Ignite 2.0





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite on Spring Boot 2.0

Posted by ignite_user2016 <ri...@gmail.com>.
Attaching sample project on spring boot 1 in which Spring Cache Manager
initialize correctly. sb1-cache-app.7z
<http://apache-ignite-users.70518.x6.nabble.com/file/t871/sb1-cache-app.7z>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite on Spring Boot 2.0

Posted by Rishi Yagnik <ri...@gmail.com>.
I found a way to solve this issue..

thank you so much for your help ...

On Fri, Oct 12, 2018 at 9:24 AM ignite_user2016 <ri...@gmail.com>
wrote:

> yes agree it is trivial but my ignite configuration stays in XML files so I
> would have to pull that XML configuration in code..
>
> I am still wondering why this piece of code stopped working ?
>
> 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" +
>                     "'gridName' property.");
>         }
>
>         if (cfgPath != null)
>             ignite = IgniteSpring.start(cfgPath, springCtx);
>         else if (cfg != null)
>             ignite = IgniteSpring.start(cfg, springCtx);
>         else
>             ignite = Ignition.ignite(gridName);
>
> so it mean with newer version there is no way Ignition can connect to
> ignite
> with grid name ..
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


-- 
Rishi Yagnik

RE: Ignite on Spring Boot 2.0

Posted by ignite_user2016 <ri...@gmail.com>.
yes agree it is trivial but my ignite configuration stays in XML files so I
would have to pull that XML configuration in code.. 

I am still wondering why this piece of code stopped working ? 

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" +
                    "'gridName' property.");
        }

        if (cfgPath != null)
            ignite = IgniteSpring.start(cfgPath, springCtx);
        else if (cfg != null)
            ignite = IgniteSpring.start(cfg, springCtx);
        else
            ignite = Ignition.ignite(gridName);

so it mean with newer version there is no way Ignition can connect to ignite
with grid name ..



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Ignite on Spring Boot 2.0

Posted by Stanislav Lukyanov <st...@gmail.com>.
Uhm, don’t have a tested example but it seems pretty trivial.
It would be something like
    @Bean
    public SpringCacheManager SpringCacheManager() {
        IgniteConfiguration cfg = new IgniteConfiguration();
        cfg.setIgniteInstanceName("WebGrid");
        // set more Ignite parameters if needed

        SpringCacheManager springCacheManager = new SpringCacheManager();
        springCacheManager.setConfiguration(cfg);
        return springCacheManager;
    }

Stan

From: ignite_user2016
Sent: 11 октября 2018 г. 20:13
To: user@ignite.apache.org
Subject: RE: Ignite on Spring Boot 2.0

Do you have any sample here ? the bean define in ignite configuration would
not work with spring boot context. we need to instantiate spring cache
manager with in spring boot context.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


RE: Ignite on Spring Boot 2.0

Posted by ignite_user2016 <ri...@gmail.com>.
Do you have any sample here ? the bean define in ignite configuration would
not work with spring boot context. we need to instantiate spring cache
manager with in spring boot context.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

RE: Ignite on Spring Boot 2.0

Posted by Stanislav Lukyanov <st...@gmail.com>.
Looks like you’re not actually starting Ignite there.
You need to either
- Provide Ignite configuration path via SpringcacheManager.configurationPath
- Provide Ignite configuration bean via SpringcacheManager.configuration
- Start Ignite manually in the same JVM prior to the SB app initialization
If you don’t know what’s better, try the second option.
Refer to the SpringCacheManager Javadoc: 
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/cache/spring/SpringCacheManager.html

I don’t know what has changed since you used spring boot 1.5.8 – perhaps you’ve been 
using an older Ignite version which had a bit different behavior.
In any case, the options above is how you’re supposed to use it in Ignite 2.6.

Stan

From: ignite_user2016
Sent: 10 октября 2018 г. 1:06
To: user@ignite.apache.org
Subject: Re: Ignite on Spring Boot 2.0

Please find sample project running on SB 2.0.. when I try to instantiate it
gives following exception - 

2018-10-09 16:54:28.207  WARN 14068 --- [           main]
io.undertow.servlet                      : UT015020: Path /* is secured for
some HTTP methods, however it is not secured for [HEAD, DELETE, POST, GET,
CONNECT, OPTIONS, PUT]
[2018-10-09 16:54:30,636][ERROR][main][SpringApplication] Application run
failed
class org.apache.ignite.IgniteIllegalStateException: Ignite instance with
provided name doesn't exist. Did you call Ignition.start(..) to start an
Ignite instance? [name=WebGrid]
	at org.apache.ignite.internal.IgnitionEx.grid(IgnitionEx.java:1383)
	at org.apache.ignite.Ignition.ignite(Ignition.java:535)
	at
org.apache.ignite.cache.spring.SpringCacheManager.onApplicationEvent(SpringCacheManager.java:334)
	at
org.apache.ignite.cache.spring.SpringCacheManager.onApplicationEvent(SpringCacheManager.java:146)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888)
	at
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
	at
org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
	at demo.SB20CacheApplication.main(SB20CacheApplication.java:28)
sb20-cache-app.7z
<http://apache-ignite-users.70518.x6.nabble.com/file/t871/sb20-cache-app.7z>  
cache_log.txt
<http://apache-ignite-users.70518.x6.nabble.com/file/t871/cache_log.txt>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Ignite on Spring Boot 2.0

Posted by ignite_user2016 <ri...@gmail.com>.
Please find sample project running on SB 2.0.. when I try to instantiate it
gives following exception - 

2018-10-09 16:54:28.207  WARN 14068 --- [           main]
io.undertow.servlet                      : UT015020: Path /* is secured for
some HTTP methods, however it is not secured for [HEAD, DELETE, POST, GET,
CONNECT, OPTIONS, PUT]
[2018-10-09 16:54:30,636][ERROR][main][SpringApplication] Application run
failed
class org.apache.ignite.IgniteIllegalStateException: Ignite instance with
provided name doesn't exist. Did you call Ignition.start(..) to start an
Ignite instance? [name=WebGrid]
	at org.apache.ignite.internal.IgnitionEx.grid(IgnitionEx.java:1383)
	at org.apache.ignite.Ignition.ignite(Ignition.java:535)
	at
org.apache.ignite.cache.spring.SpringCacheManager.onApplicationEvent(SpringCacheManager.java:334)
	at
org.apache.ignite.cache.spring.SpringCacheManager.onApplicationEvent(SpringCacheManager.java:146)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888)
	at
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
	at
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
	at
org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
	at demo.SB20CacheApplication.main(SB20CacheApplication.java:28)
sb20-cache-app.7z
<http://apache-ignite-users.70518.x6.nabble.com/file/t871/sb20-cache-app.7z>  
cache_log.txt
<http://apache-ignite-users.70518.x6.nabble.com/file/t871/cache_log.txt>  



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/