You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Mike Hummel <mh...@mhus.de> on 2020/06/04 16:00:36 UTC

Re: Karaf Cellar as Cache Provider

Hi,

sorry for delay, I will retry it in the next days.

Regards,
Mike

> On 26. May 2020, at 06:36, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
> 
> Hi,
> 
> I was mentioning dynamic import, not refresh.
> 
> To enable dynamic import you can use the bundle:dynamic-import command.
> 
> It’s just a workaround, I will improve Cellar (I’m doing a complete refactoring of Cellar anyway).
> 
> Regards
> JB
> 
>> Le 25 mai 2020 à 19:39, Mike Hummel <mh...@mhus.de> a écrit :
>> 
>> Hi,
>> 
>> yes I tried to refresh bundles in a row but even it was not successful or the wrong order...
>> 
>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>> 
>> 
>> Could you give me a hint how to enable the feature afterward?
>> 
>> Thx,
>> 
>> Mike
>> 
>> 
>>> On 25. May 2020, at 06:05, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>>> 
>>> Hi,
>>> 
>>> Did you try a refresh once installed cache bundle (without restarting Karaf) ?
>>> 
>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>> 
>>> Regards
>>> JB
>>> 
>>>> Le 24 mai 2020 à 20:56, Mike Hummel <mh...@mhus.de> a écrit :
>>>> 
>>>> After some try and error I found that the deployment order is important
>>>> 
>>>> 1)  Install cellar
>>>> feature:repo-add cellar
>>>> feature:install cellar
>>>> 
>>>> 2) THEN install JCache
>>>> cluster:bundle-install -s default mvn:javax.cache/cache-api/1.1.0
>>>> 
>>>> ...) More bundles
>>>> cluster:bundle-install -s default mvn:de.mhus.osgi/dev-cache/7.1.0-SNAPSHOT
>>>> 
>>>> 3) MUST restart karaf
>>>> shutdown -r -f
>>>> 
>>>> Now it's possible to use the cache api. (In other order it fails - reproducible)
>>>> 
>>>> But this not looks like a stable deployment.
>>>> 
>>>> Any ideas how to bring this in a stable working feature? Special the restart is strange.
>>>> 
>>>> Thx,
>>>> 
>>>> Mike
>>>> 
>>>> 
>>>>> On 24. May 2020, at 15:02, Mike Hummel <mh...@mhus.de> wrote:
>>>>> 
>>>>> Hello,
>>>>> 
>>>>> I got karaf cellar to work as expected - don't know what was the problem last time. It's really cool.
>>>>> 
>>>>> I'm using karaf 4.2.6 and cellar 4.1.3.
>>>>> 
>>>>> I want to use hazelcast caching features but I get the following exception:
>>>>> 
>>>>> 10:55:14.263 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>> java.lang.IllegalStateException: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCacheByFullName(HazelcastInstanceCacheManager.java:54)
>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCache(HazelcastInstanceCacheManager.java:45)
>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:86)
>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>> Error executing command: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>> karaf@b14e3b5c1560()>
>>>>> 
>>>>> If I install jcache
>>>>> 
>>>>> install -s mvn:javax.cache/cache-api/1.1.0
>>>>> 
>>>>> before installation of cellar I will get ...
>>>>> 
>>>>> 10:56:57.732 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>> java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>> 	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
>>>>> 	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
>>>>> 	at org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:855)
>>>>> 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>> Caused by: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:61)
>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>> 	... 4 more
>>>>> Caused by: java.lang.ClassNotFoundException: org.apache.karaf.cellar.hazelcast.HazelcastClusterManager not found by dev-cache [159]
>>>>> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
>>>>> 	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
>>>>> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
>>>>> 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
>>>>> 	... 15 more
>>>>> Error executing command: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>> karaf@200afd2d720a()>
>>>>> 
>>>>> 
>>>>> The sample project and code is found here
>>>>> 
>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/src/main/java/de/mhus/osgi/dev/cache/CmdDevHazelcast.java
>>>>> 
>>>>> The scenario description is here:
>>>>> 
>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-deploy/cellar-docker.adoc
>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/hazelcast.md
>>>>> 
>>>>> The core code snipped is:
>>>>> 
>>>>>    	HazelcastClusterManager hccm = (HazelcastClusterManager)clusterManager;
>>>>>    	HazelcastInstance inst = hccm.getInstance();
>>>>>    	ICacheManager cm = inst.getCacheManager();
>>>>>    	CacheSimpleConfig cc = inst.getConfig().getCacheConfig("test");
>>>>>    	if (cc == null) {
>>>>>    		cc = new CacheSimpleConfig();
>>>>>    		cc.setName("test");
>>>>>    		cc.setKeyType("String");
>>>>>    		cc.setValueType("String");
>>>>>    		inst.getConfig().addCacheConfig(cc);
>>>>>    	}
>>>>>    	ICache<String, String> testc = cm.getCache("test");
>>>>>    	String a = testc.get("a");
>>>>>    	System.out.println("A: " + a);
>>>>>    	testc.put("a",new Date().toString());
>>>>> 
>>>>> 
>>>>> 
>>>>> I already tried cache-api
>>>>> 
>>>>> 1.0.0-PFD - ClassNotFoundException
>>>>> 1.1.0 - ClassNotFoundException
>>>>> 1.1.1 - There is no valid JCache API library at classpath
>>>>> 
>>>>> 
>>>>> 
>>>>> Thx for help,
>>>>> Regards,
>>>>> 
>>>>> Mike
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Karaf Cellar as Cache Provider

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi Mike,

Cool, thanks !

Regards
JB

> Le 11 juin 2020 à 18:31, Mike Hummel <mh...@mhus.de> a écrit :
> 
> Hi JB,
> 
> I created KARAF-6762 <https://issues.apache.org/jira/browse/KARAF-6762>
> 
> Thx, Mike
> 
>> On 10. Jun 2020, at 06:08, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>> 
>> Hi Mike,
>> 
>> Hmmm, ok for the dynamic import.
>> 
>> Can you please create a Jira about that ? As I’m completely refactoring Cellar, I will improve the caching here.
>> 
>> Thanks,
>> Regards
>> JB
>> 
>>> Le 9 juin 2020 à 22:27, Mike Hummel <mh@mhus.de <ma...@mhus.de>> a écrit :
>>> 
>>> Hello JB,
>>> 
>>> dynamic import is not working. I tested different scenarios but without success.
>>> 
>>> I'm waiting for a change in cellar. Helpful would be a  possibility to use the existing (connected) hazelcast instance with caching capabilities.
>>> 
>>> If I have time (currently not) I will fork cellar and try my best.
>>> 
>>> Thx,
>>> 
>>> Mike
>>> 
>>> 
>>>> On 4. Jun 2020, at 18:00, Mike Hummel <mh@mhus.de <ma...@mhus.de>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> sorry for delay, I will retry it in the next days.
>>>> 
>>>> Regards,
>>>> Mike
>>>> 
>>>>> On 26. May 2020, at 06:36, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I was mentioning dynamic import, not refresh.
>>>>> 
>>>>> To enable dynamic import you can use the bundle:dynamic-import command.
>>>>> 
>>>>> It’s just a workaround, I will improve Cellar (I’m doing a complete refactoring of Cellar anyway).
>>>>> 
>>>>> Regards
>>>>> JB
>>>>> 
>>>>>> Le 25 mai 2020 à 19:39, Mike Hummel <mh@mhus.de <ma...@mhus.de>> a écrit :
>>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> yes I tried to refresh bundles in a row but even it was not successful or the wrong order...
>>>>>> 
>>>>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>>>> 
>>>>>> 
>>>>>> Could you give me a hint how to enable the feature afterward?
>>>>>> 
>>>>>> Thx,
>>>>>> 
>>>>>> Mike
>>>>>> 
>>>>>> 
>>>>>>> On 25. May 2020, at 06:05, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>>>>>>> 
>>>>>>> Hi,
>>>>>>> 
>>>>>>> Did you try a refresh once installed cache bundle (without restarting Karaf) ?
>>>>>>> 
>>>>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>>>>> 
>>>>>>> Regards
>>>>>>> JB
>>>>>>> 
>>>>>>>> Le 24 mai 2020 à 20:56, Mike Hummel <mh@mhus.de <ma...@mhus.de>> a écrit :
>>>>>>>> 
>>>>>>>> After some try and error I found that the deployment order is important
>>>>>>>> 
>>>>>>>> 1)  Install cellar
>>>>>>>> feature:repo-add cellar
>>>>>>>> feature:install cellar
>>>>>>>> 
>>>>>>>> 2) THEN install JCache
>>>>>>>> cluster:bundle-install -s default mvn:javax.cache/cache-api/1.1.0
>>>>>>>> 
>>>>>>>> ...) More bundles
>>>>>>>> cluster:bundle-install -s default mvn:de.mhus.osgi/dev-cache/7.1.0-SNAPSHOT
>>>>>>>> 
>>>>>>>> 3) MUST restart karaf
>>>>>>>> shutdown -r -f
>>>>>>>> 
>>>>>>>> Now it's possible to use the cache api. (In other order it fails - reproducible)
>>>>>>>> 
>>>>>>>> But this not looks like a stable deployment.
>>>>>>>> 
>>>>>>>> Any ideas how to bring this in a stable working feature? Special the restart is strange.
>>>>>>>> 
>>>>>>>> Thx,
>>>>>>>> 
>>>>>>>> Mike
>>>>>>>> 
>>>>>>>> 
>>>>>>>>> On 24. May 2020, at 15:02, Mike Hummel <mh@mhus.de <ma...@mhus.de>> wrote:
>>>>>>>>> 
>>>>>>>>> Hello,
>>>>>>>>> 
>>>>>>>>> I got karaf cellar to work as expected - don't know what was the problem last time. It's really cool.
>>>>>>>>> 
>>>>>>>>> I'm using karaf 4.2.6 and cellar 4.1.3.
>>>>>>>>> 
>>>>>>>>> I want to use hazelcast caching features but I get the following exception:
>>>>>>>>> 
>>>>>>>>> 10:55:14.263 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>>>>> java.lang.IllegalStateException: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCacheByFullName(HazelcastInstanceCacheManager.java:54)
>>>>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCache(HazelcastInstanceCacheManager.java:45)
>>>>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:86)
>>>>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>>>>> Error executing command: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>>>>> karaf@b14e3b5c1560()>
>>>>>>>>> 
>>>>>>>>> If I install jcache
>>>>>>>>> 
>>>>>>>>> install -s mvn:javax.cache/cache-api/1.1.0
>>>>>>>>> 
>>>>>>>>> before installation of cellar I will get ...
>>>>>>>>> 
>>>>>>>>> 10:56:57.732 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>>>>> java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
>>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:855)
>>>>>>>>> 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
>>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>>>>> Caused by: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:61)
>>>>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>>>>> 	... 4 more
>>>>>>>>> Caused by: java.lang.ClassNotFoundException: org.apache.karaf.cellar.hazelcast.HazelcastClusterManager not found by dev-cache [159]
>>>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
>>>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
>>>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
>>>>>>>>> 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
>>>>>>>>> 	... 15 more
>>>>>>>>> Error executing command: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>>>> karaf@200afd2d720a()>
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> The sample project and code is found here
>>>>>>>>> 
>>>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/src/main/java/de/mhus/osgi/dev/cache/CmdDevHazelcast.java <https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/src/main/java/de/mhus/osgi/dev/cache/CmdDevHazelcast.java>
>>>>>>>>> 
>>>>>>>>> The scenario description is here:
>>>>>>>>> 
>>>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-deploy/cellar-docker.adoc
>>>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/hazelcast.md
>>>>>>>>> 
>>>>>>>>> The core code snipped is:
>>>>>>>>> 
>>>>>>>>> 	HazelcastClusterManager hccm = (HazelcastClusterManager)clusterManager;
>>>>>>>>> 	HazelcastInstance inst = hccm.getInstance();
>>>>>>>>> 	ICacheManager cm = inst.getCacheManager();
>>>>>>>>> 	CacheSimpleConfig cc = inst.getConfig().getCacheConfig("test");
>>>>>>>>> 	if (cc == null) {
>>>>>>>>> 		cc = new CacheSimpleConfig();
>>>>>>>>> 		cc.setName("test");
>>>>>>>>> 		cc.setKeyType("String");
>>>>>>>>> 		cc.setValueType("String");
>>>>>>>>> 		inst.getConfig().addCacheConfig(cc);
>>>>>>>>> 	}
>>>>>>>>> 	ICache<String, String> testc = cm.getCache("test");
>>>>>>>>> 	String a = testc.get("a");
>>>>>>>>> 	System.out.println("A: " + a);
>>>>>>>>> 	testc.put("a",new Date().toString());
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> I already tried cache-api
>>>>>>>>> 
>>>>>>>>> 1.0.0-PFD - ClassNotFoundException
>>>>>>>>> 1.1.0 - ClassNotFoundException
>>>>>>>>> 1.1.1 - There is no valid JCache API library at classpath
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Thx for help,
>>>>>>>>> Regards,
>>>>>>>>> 
>>>>>>>>> Mike
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Karaf Cellar as Cache Provider

Posted by Mike Hummel <mh...@mhus.de>.
Hi JB,

I created KARAF-6762 <https://issues.apache.org/jira/browse/KARAF-6762>

Thx, Mike

> On 10. Jun 2020, at 06:08, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
> 
> Hi Mike,
> 
> Hmmm, ok for the dynamic import.
> 
> Can you please create a Jira about that ? As I’m completely refactoring Cellar, I will improve the caching here.
> 
> Thanks,
> Regards
> JB
> 
>> Le 9 juin 2020 à 22:27, Mike Hummel <mh...@mhus.de> a écrit :
>> 
>> Hello JB,
>> 
>> dynamic import is not working. I tested different scenarios but without success.
>> 
>> I'm waiting for a change in cellar. Helpful would be a  possibility to use the existing (connected) hazelcast instance with caching capabilities.
>> 
>> If I have time (currently not) I will fork cellar and try my best.
>> 
>> Thx,
>> 
>> Mike
>> 
>> 
>>> On 4. Jun 2020, at 18:00, Mike Hummel <mh...@mhus.de> wrote:
>>> 
>>> Hi,
>>> 
>>> sorry for delay, I will retry it in the next days.
>>> 
>>> Regards,
>>> Mike
>>> 
>>>> On 26. May 2020, at 06:36, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I was mentioning dynamic import, not refresh.
>>>> 
>>>> To enable dynamic import you can use the bundle:dynamic-import command.
>>>> 
>>>> It’s just a workaround, I will improve Cellar (I’m doing a complete refactoring of Cellar anyway).
>>>> 
>>>> Regards
>>>> JB
>>>> 
>>>>> Le 25 mai 2020 à 19:39, Mike Hummel <mh...@mhus.de> a écrit :
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> yes I tried to refresh bundles in a row but even it was not successful or the wrong order...
>>>>> 
>>>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>>> 
>>>>> 
>>>>> Could you give me a hint how to enable the feature afterward?
>>>>> 
>>>>> Thx,
>>>>> 
>>>>> Mike
>>>>> 
>>>>> 
>>>>>> On 25. May 2020, at 06:05, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>>>>>> 
>>>>>> Hi,
>>>>>> 
>>>>>> Did you try a refresh once installed cache bundle (without restarting Karaf) ?
>>>>>> 
>>>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>>>> 
>>>>>> Regards
>>>>>> JB
>>>>>> 
>>>>>>> Le 24 mai 2020 à 20:56, Mike Hummel <mh...@mhus.de> a écrit :
>>>>>>> 
>>>>>>> After some try and error I found that the deployment order is important
>>>>>>> 
>>>>>>> 1)  Install cellar
>>>>>>> feature:repo-add cellar
>>>>>>> feature:install cellar
>>>>>>> 
>>>>>>> 2) THEN install JCache
>>>>>>> cluster:bundle-install -s default mvn:javax.cache/cache-api/1.1.0
>>>>>>> 
>>>>>>> ...) More bundles
>>>>>>> cluster:bundle-install -s default mvn:de.mhus.osgi/dev-cache/7.1.0-SNAPSHOT
>>>>>>> 
>>>>>>> 3) MUST restart karaf
>>>>>>> shutdown -r -f
>>>>>>> 
>>>>>>> Now it's possible to use the cache api. (In other order it fails - reproducible)
>>>>>>> 
>>>>>>> But this not looks like a stable deployment.
>>>>>>> 
>>>>>>> Any ideas how to bring this in a stable working feature? Special the restart is strange.
>>>>>>> 
>>>>>>> Thx,
>>>>>>> 
>>>>>>> Mike
>>>>>>> 
>>>>>>> 
>>>>>>>> On 24. May 2020, at 15:02, Mike Hummel <mh...@mhus.de> wrote:
>>>>>>>> 
>>>>>>>> Hello,
>>>>>>>> 
>>>>>>>> I got karaf cellar to work as expected - don't know what was the problem last time. It's really cool.
>>>>>>>> 
>>>>>>>> I'm using karaf 4.2.6 and cellar 4.1.3.
>>>>>>>> 
>>>>>>>> I want to use hazelcast caching features but I get the following exception:
>>>>>>>> 
>>>>>>>> 10:55:14.263 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>>>> java.lang.IllegalStateException: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCacheByFullName(HazelcastInstanceCacheManager.java:54)
>>>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCache(HazelcastInstanceCacheManager.java:45)
>>>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:86)
>>>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>>>> Error executing command: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>>>> karaf@b14e3b5c1560()>
>>>>>>>> 
>>>>>>>> If I install jcache
>>>>>>>> 
>>>>>>>> install -s mvn:javax.cache/cache-api/1.1.0
>>>>>>>> 
>>>>>>>> before installation of cellar I will get ...
>>>>>>>> 
>>>>>>>> 10:56:57.732 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>>>> java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
>>>>>>>> 	at org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:855)
>>>>>>>> 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
>>>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>>>> Caused by: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:61)
>>>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>>>> 	... 4 more
>>>>>>>> Caused by: java.lang.ClassNotFoundException: org.apache.karaf.cellar.hazelcast.HazelcastClusterManager not found by dev-cache [159]
>>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
>>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
>>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
>>>>>>>> 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
>>>>>>>> 	... 15 more
>>>>>>>> Error executing command: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>>> karaf@200afd2d720a()>
>>>>>>>> 
>>>>>>>> 
>>>>>>>> The sample project and code is found here
>>>>>>>> 
>>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/src/main/java/de/mhus/osgi/dev/cache/CmdDevHazelcast.java
>>>>>>>> 
>>>>>>>> The scenario description is here:
>>>>>>>> 
>>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-deploy/cellar-docker.adoc
>>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/hazelcast.md
>>>>>>>> 
>>>>>>>> The core code snipped is:
>>>>>>>> 
>>>>>>>> 	HazelcastClusterManager hccm = (HazelcastClusterManager)clusterManager;
>>>>>>>> 	HazelcastInstance inst = hccm.getInstance();
>>>>>>>> 	ICacheManager cm = inst.getCacheManager();
>>>>>>>> 	CacheSimpleConfig cc = inst.getConfig().getCacheConfig("test");
>>>>>>>> 	if (cc == null) {
>>>>>>>> 		cc = new CacheSimpleConfig();
>>>>>>>> 		cc.setName("test");
>>>>>>>> 		cc.setKeyType("String");
>>>>>>>> 		cc.setValueType("String");
>>>>>>>> 		inst.getConfig().addCacheConfig(cc);
>>>>>>>> 	}
>>>>>>>> 	ICache<String, String> testc = cm.getCache("test");
>>>>>>>> 	String a = testc.get("a");
>>>>>>>> 	System.out.println("A: " + a);
>>>>>>>> 	testc.put("a",new Date().toString());
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> I already tried cache-api
>>>>>>>> 
>>>>>>>> 1.0.0-PFD - ClassNotFoundException
>>>>>>>> 1.1.0 - ClassNotFoundException
>>>>>>>> 1.1.1 - There is no valid JCache API library at classpath
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Thx for help,
>>>>>>>> Regards,
>>>>>>>> 
>>>>>>>> Mike
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Karaf Cellar as Cache Provider

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi Mike,

Hmmm, ok for the dynamic import.

Can you please create a Jira about that ? As I’m completely refactoring Cellar, I will improve the caching here.

Thanks,
Regards
JB

> Le 9 juin 2020 à 22:27, Mike Hummel <mh...@mhus.de> a écrit :
> 
> Hello JB,
> 
> dynamic import is not working. I tested different scenarios but without success.
> 
> I'm waiting for a change in cellar. Helpful would be a  possibility to use the existing (connected) hazelcast instance with caching capabilities.
> 
> If I have time (currently not) I will fork cellar and try my best.
> 
> Thx,
> 
> Mike
> 
> 
>> On 4. Jun 2020, at 18:00, Mike Hummel <mh...@mhus.de> wrote:
>> 
>> Hi,
>> 
>> sorry for delay, I will retry it in the next days.
>> 
>> Regards,
>> Mike
>> 
>>> On 26. May 2020, at 06:36, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>>> 
>>> Hi,
>>> 
>>> I was mentioning dynamic import, not refresh.
>>> 
>>> To enable dynamic import you can use the bundle:dynamic-import command.
>>> 
>>> It’s just a workaround, I will improve Cellar (I’m doing a complete refactoring of Cellar anyway).
>>> 
>>> Regards
>>> JB
>>> 
>>>> Le 25 mai 2020 à 19:39, Mike Hummel <mh...@mhus.de> a écrit :
>>>> 
>>>> Hi,
>>>> 
>>>> yes I tried to refresh bundles in a row but even it was not successful or the wrong order...
>>>> 
>>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>> 
>>>> 
>>>> Could you give me a hint how to enable the feature afterward?
>>>> 
>>>> Thx,
>>>> 
>>>> Mike
>>>> 
>>>> 
>>>>> On 25. May 2020, at 06:05, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> Did you try a refresh once installed cache bundle (without restarting Karaf) ?
>>>>> 
>>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>>> 
>>>>> Regards
>>>>> JB
>>>>> 
>>>>>> Le 24 mai 2020 à 20:56, Mike Hummel <mh...@mhus.de> a écrit :
>>>>>> 
>>>>>> After some try and error I found that the deployment order is important
>>>>>> 
>>>>>> 1)  Install cellar
>>>>>> feature:repo-add cellar
>>>>>> feature:install cellar
>>>>>> 
>>>>>> 2) THEN install JCache
>>>>>> cluster:bundle-install -s default mvn:javax.cache/cache-api/1.1.0
>>>>>> 
>>>>>> ...) More bundles
>>>>>> cluster:bundle-install -s default mvn:de.mhus.osgi/dev-cache/7.1.0-SNAPSHOT
>>>>>> 
>>>>>> 3) MUST restart karaf
>>>>>> shutdown -r -f
>>>>>> 
>>>>>> Now it's possible to use the cache api. (In other order it fails - reproducible)
>>>>>> 
>>>>>> But this not looks like a stable deployment.
>>>>>> 
>>>>>> Any ideas how to bring this in a stable working feature? Special the restart is strange.
>>>>>> 
>>>>>> Thx,
>>>>>> 
>>>>>> Mike
>>>>>> 
>>>>>> 
>>>>>>> On 24. May 2020, at 15:02, Mike Hummel <mh...@mhus.de> wrote:
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> I got karaf cellar to work as expected - don't know what was the problem last time. It's really cool.
>>>>>>> 
>>>>>>> I'm using karaf 4.2.6 and cellar 4.1.3.
>>>>>>> 
>>>>>>> I want to use hazelcast caching features but I get the following exception:
>>>>>>> 
>>>>>>> 10:55:14.263 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>>> java.lang.IllegalStateException: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCacheByFullName(HazelcastInstanceCacheManager.java:54)
>>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCache(HazelcastInstanceCacheManager.java:45)
>>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:86)
>>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>>> Error executing command: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>>> karaf@b14e3b5c1560()>
>>>>>>> 
>>>>>>> If I install jcache
>>>>>>> 
>>>>>>> install -s mvn:javax.cache/cache-api/1.1.0
>>>>>>> 
>>>>>>> before installation of cellar I will get ...
>>>>>>> 
>>>>>>> 10:56:57.732 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>>> java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>> 	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
>>>>>>> 	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
>>>>>>> 	at org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:855)
>>>>>>> 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
>>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>>> Caused by: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:61)
>>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>>> 	... 4 more
>>>>>>> Caused by: java.lang.ClassNotFoundException: org.apache.karaf.cellar.hazelcast.HazelcastClusterManager not found by dev-cache [159]
>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
>>>>>>> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
>>>>>>> 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
>>>>>>> 	... 15 more
>>>>>>> Error executing command: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>>> karaf@200afd2d720a()>
>>>>>>> 
>>>>>>> 
>>>>>>> The sample project and code is found here
>>>>>>> 
>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/src/main/java/de/mhus/osgi/dev/cache/CmdDevHazelcast.java
>>>>>>> 
>>>>>>> The scenario description is here:
>>>>>>> 
>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-deploy/cellar-docker.adoc
>>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/hazelcast.md
>>>>>>> 
>>>>>>> The core code snipped is:
>>>>>>> 
>>>>>>>  	HazelcastClusterManager hccm = (HazelcastClusterManager)clusterManager;
>>>>>>>  	HazelcastInstance inst = hccm.getInstance();
>>>>>>>  	ICacheManager cm = inst.getCacheManager();
>>>>>>>  	CacheSimpleConfig cc = inst.getConfig().getCacheConfig("test");
>>>>>>>  	if (cc == null) {
>>>>>>>  		cc = new CacheSimpleConfig();
>>>>>>>  		cc.setName("test");
>>>>>>>  		cc.setKeyType("String");
>>>>>>>  		cc.setValueType("String");
>>>>>>>  		inst.getConfig().addCacheConfig(cc);
>>>>>>>  	}
>>>>>>>  	ICache<String, String> testc = cm.getCache("test");
>>>>>>>  	String a = testc.get("a");
>>>>>>>  	System.out.println("A: " + a);
>>>>>>>  	testc.put("a",new Date().toString());
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> I already tried cache-api
>>>>>>> 
>>>>>>> 1.0.0-PFD - ClassNotFoundException
>>>>>>> 1.1.0 - ClassNotFoundException
>>>>>>> 1.1.1 - There is no valid JCache API library at classpath
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> Thx for help,
>>>>>>> Regards,
>>>>>>> 
>>>>>>> Mike
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Karaf Cellar as Cache Provider

Posted by Mike Hummel <mh...@mhus.de>.
Hello JB,

dynamic import is not working. I tested different scenarios but without success.

I'm waiting for a change in cellar. Helpful would be a  possibility to use the existing (connected) hazelcast instance with caching capabilities.

If I have time (currently not) I will fork cellar and try my best.

Thx,

Mike


> On 4. Jun 2020, at 18:00, Mike Hummel <mh...@mhus.de> wrote:
> 
> Hi,
> 
> sorry for delay, I will retry it in the next days.
> 
> Regards,
> Mike
> 
>> On 26. May 2020, at 06:36, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>> 
>> Hi,
>> 
>> I was mentioning dynamic import, not refresh.
>> 
>> To enable dynamic import you can use the bundle:dynamic-import command.
>> 
>> It’s just a workaround, I will improve Cellar (I’m doing a complete refactoring of Cellar anyway).
>> 
>> Regards
>> JB
>> 
>>> Le 25 mai 2020 à 19:39, Mike Hummel <mh...@mhus.de> a écrit :
>>> 
>>> Hi,
>>> 
>>> yes I tried to refresh bundles in a row but even it was not successful or the wrong order...
>>> 
>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>> 
>>> 
>>> Could you give me a hint how to enable the feature afterward?
>>> 
>>> Thx,
>>> 
>>> Mike
>>> 
>>> 
>>>> On 25. May 2020, at 06:05, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> Did you try a refresh once installed cache bundle (without restarting Karaf) ?
>>>> 
>>>> You can enable dynamic import on cellar-hazelcast (providing the hazelcast service), I think it should help.
>>>> 
>>>> Regards
>>>> JB
>>>> 
>>>>> Le 24 mai 2020 à 20:56, Mike Hummel <mh...@mhus.de> a écrit :
>>>>> 
>>>>> After some try and error I found that the deployment order is important
>>>>> 
>>>>> 1)  Install cellar
>>>>> feature:repo-add cellar
>>>>> feature:install cellar
>>>>> 
>>>>> 2) THEN install JCache
>>>>> cluster:bundle-install -s default mvn:javax.cache/cache-api/1.1.0
>>>>> 
>>>>> ...) More bundles
>>>>> cluster:bundle-install -s default mvn:de.mhus.osgi/dev-cache/7.1.0-SNAPSHOT
>>>>> 
>>>>> 3) MUST restart karaf
>>>>> shutdown -r -f
>>>>> 
>>>>> Now it's possible to use the cache api. (In other order it fails - reproducible)
>>>>> 
>>>>> But this not looks like a stable deployment.
>>>>> 
>>>>> Any ideas how to bring this in a stable working feature? Special the restart is strange.
>>>>> 
>>>>> Thx,
>>>>> 
>>>>> Mike
>>>>> 
>>>>> 
>>>>>> On 24. May 2020, at 15:02, Mike Hummel <mh...@mhus.de> wrote:
>>>>>> 
>>>>>> Hello,
>>>>>> 
>>>>>> I got karaf cellar to work as expected - don't know what was the problem last time. It's really cool.
>>>>>> 
>>>>>> I'm using karaf 4.2.6 and cellar 4.1.3.
>>>>>> 
>>>>>> I want to use hazelcast caching features but I get the following exception:
>>>>>> 
>>>>>> 10:55:14.263 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>> java.lang.IllegalStateException: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCacheByFullName(HazelcastInstanceCacheManager.java:54)
>>>>>> 	at com.hazelcast.instance.HazelcastInstanceCacheManager.getCache(HazelcastInstanceCacheManager.java:45)
>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:86)
>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>> Error executing command: There is no valid JCache API library at classpath. Please be sure that there is a JCache API library in your classpath and it is newer than `0.x` and `1.0.0-PFD` versions!
>>>>>> karaf@b14e3b5c1560()>
>>>>>> 
>>>>>> If I install jcache
>>>>>> 
>>>>>> install -s mvn:javax.cache/cache-api/1.1.0
>>>>>> 
>>>>>> before installation of cellar I will get ...
>>>>>> 
>>>>>> 10:56:57.732 ERROR [Karaf local console user karaf] Exception caught while executing command
>>>>>> java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>> 	at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
>>>>>> 	at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
>>>>>> 	at org.apache.felix.gogo.runtime.CommandSessionImpl$JobImpl.run(CommandSessionImpl.java:855)
>>>>>> 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
>>>>>> 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>>>>>> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>>>>>> 	at java.base/java.lang.Thread.run(Thread.java:834)
>>>>>> Caused by: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>> 	at de.mhus.osgi.dev.cache.CmdDevHazelcast.execute2(CmdDevHazelcast.java:61)
>>>>>> 	at de.mhus.osgi.api.karaf.AbstractCmd.execute(AbstractCmd.java:96)
>>>>>> 	at org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>>>>>> 	at org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
>>>>>> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
>>>>>> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)
>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)
>>>>>> 	at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)
>>>>>> 	... 4 more
>>>>>> Caused by: java.lang.ClassNotFoundException: org.apache.karaf.cellar.hazelcast.HazelcastClusterManager not found by dev-cache [159]
>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
>>>>>> 	at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
>>>>>> 	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2053)
>>>>>> 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
>>>>>> 	... 15 more
>>>>>> Error executing command: java.lang.NoClassDefFoundError: org/apache/karaf/cellar/hazelcast/HazelcastClusterManager
>>>>>> karaf@200afd2d720a()>
>>>>>> 
>>>>>> 
>>>>>> The sample project and code is found here
>>>>>> 
>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/src/main/java/de/mhus/osgi/dev/cache/CmdDevHazelcast.java
>>>>>> 
>>>>>> The scenario description is here:
>>>>>> 
>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-deploy/cellar-docker.adoc
>>>>>> https://github.com/mhus/mhus-osgi-dev/blob/master/dev-cache/hazelcast.md
>>>>>> 
>>>>>> The core code snipped is:
>>>>>> 
>>>>>>   	HazelcastClusterManager hccm = (HazelcastClusterManager)clusterManager;
>>>>>>   	HazelcastInstance inst = hccm.getInstance();
>>>>>>   	ICacheManager cm = inst.getCacheManager();
>>>>>>   	CacheSimpleConfig cc = inst.getConfig().getCacheConfig("test");
>>>>>>   	if (cc == null) {
>>>>>>   		cc = new CacheSimpleConfig();
>>>>>>   		cc.setName("test");
>>>>>>   		cc.setKeyType("String");
>>>>>>   		cc.setValueType("String");
>>>>>>   		inst.getConfig().addCacheConfig(cc);
>>>>>>   	}
>>>>>>   	ICache<String, String> testc = cm.getCache("test");
>>>>>>   	String a = testc.get("a");
>>>>>>   	System.out.println("A: " + a);
>>>>>>   	testc.put("a",new Date().toString());
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> I already tried cache-api
>>>>>> 
>>>>>> 1.0.0-PFD - ClassNotFoundException
>>>>>> 1.1.0 - ClassNotFoundException
>>>>>> 1.1.1 - There is no valid JCache API library at classpath
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Thx for help,
>>>>>> Regards,
>>>>>> 
>>>>>> Mike
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
>