Error in running demo project

87 views
Skip to first unread message

Shreshth Agarwal

unread,
Jan 16, 2021, 2:05:00 AM1/16/21
to Hazelcast
Hi,

I have downloaded same spring boot demo project from below mentioned link:


I have started hazlecast 4.1.1 server on my local machine along with mancenter 

The downloaded demo application also started properly but when I hit below mentioned URL:

then below exception is thrown:

java.lang.ClassNotFoundException: javax.cache.configuration.CompleteConfiguration

Can somebody please help what I doing wrong here?

Regards,
Shreshth Agarwal


Bence Eros

unread,
Jan 16, 2021, 3:59:52 AM1/16/21
to haze...@googlegroups.com
Hello,

I couldn't reproduce the problem. After cloning the git repository and running it with mvn spring-boot:run , it worked. The javax.cache:cache-api:1.1.1 dependency is correctly added to the pom.xml. Maybe the problem is caused by a corrupted jar file on your local machine. I suggest re-building the project with mvn clean install -U so that the dependencies are re-downloaded.

Kind regards,

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/ec770cb0-f84e-414d-bc78-bb04c4bed543n%40googlegroups.com.

This message contains confidential information and is intended only for the individuals named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. If verification is required, please request a hard-copy version. -Hazelcast

Shreshth Agarwal

unread,
Jan 16, 2021, 5:31:12 AM1/16/21
to Hazelcast
Thanks for replying. after digging more, I found that problem is with hazlecast server 4.1.1 which I started on my local machine. 

If I don't start hazlecat server & only starts application then it works fine since it uses embedded instance of hazlecast but the problem occurs if I starts hazlecast instance along with mancenter.

When I look console of hazlecast server then I see the exception occurred in original post.

I tried to put the cache-api-1.1.1 jar in lib of server & then restarted the server but the same problem occurred.

Regards,
Shreshth Agarwal

Can you please help me here as  my use case is to connect with external instance of hazlecast & not embedded one

Joe Sherwin

unread,
Jan 16, 2021, 2:38:44 PM1/16/21
to haze...@googlegroups.com
If you want to use Hazelcast in the client-server topology, then it’s enough to use HazelcastClientCachingProvider instead of HazelcastServerCachingProvider in your application.properties.


You may also have to modify the hazelcast.yaml file in the resource folder of the project 

See examples here... https://github.com/hazelcast/hazelcast-code-samples/tree/master/learning-basics/configure-yaml/src/main/resources

Sent from my iPad

On Jan 16, 2021, at 5:31 AM, Shreshth Agarwal <shres...@gmail.com> wrote:

Thanks for replying. after digging more, I found that problem is with hazlecast server 4.1.1 which I started on my local machine. 

Shreshth Agarwal

unread,
Jan 18, 2021, 1:36:47 AM1/18/21
to Hazelcast
Hi,

Can you please give me reference to github example for client-server topology as I am facing issues in configuring the same?

That would be really helpful.

Regards,
Shreshth

enes....@hazelcast.com

unread,
Jan 18, 2021, 3:02:15 AM1/18/21
to Hazelcast
Hi Shreshth,

Apparently the instructions for client/server topology in the guide are not complete and I will create an issue to improve them. That being said, let me explain the steps here for now:

1) Create a cluster with the configuration file under resources and cache-api on the classpath. Using Hazelcast CLI, it looks like:

$ hz start -c src/main/resources/hazelcast.yaml -j ~/.m2/repository/javax/cache/cache-api/1.1.1/cache-api-1.1.1.jar

2) Update application.properties

spring.cache.jcache.provider=com.hazelcast.client.cache.HazelcastClientCachingProvider

3) Since hazelcast.yaml exists under resources, Spring's auto configuration will kick in after detected this file and create embedded Hazelcast by default. To prevent this, you can remove this file, or replace it with your Hazelcast client config, or disable auto configuration via:

// Application.java
@SpringBootApplication(exclude = HazelcastAutoConfiguration.class)

4) Run the application and test it.

mvn clean spring-boot:run
curl localhost:8080/books/12345    <--------- response with 3 sec delay
curl localhost:8080/books/12345    <--------- response from cache without delay

Note that when you restart the Spring app, you will get the response without delay - as it will be existing in the cache.

Regards,
Enes O.

Shreshth Agarwal

unread,
Jan 18, 2021, 4:28:18 AM1/18/21
to Hazelcast
Hi,

That would be really helpful if you improve the guide & also create a spring boot demo application for that configuration, although I have done the configuration as suggested by you & now its working fine for me. 
Now can you please help me further by letting me know that if I use native javax.cache.Cache class to put & retrieve cached value then where it can be visible in mancenter.
If I am not using the javax.cache.Cache class to put an retrieve & use the @Cacheable annotation then I am able to the see the cached values in Map in Mancenter.


Regards,
Shreshth

enes....@hazelcast.com

unread,
Jan 18, 2021, 5:08:34 AM1/18/21
to Hazelcast
> if I use native javax.cache.Cache

If you mean using Hazelcast as a cache provider here - as I denoted in my previous answer, then if you enable the statistics for the cache in Hazelcast config, you will be able to see the cache metrics on the Management Center's "Storage > Caches" section (named "books" for this example):

hazelcast.yaml

hazelcast:
--cache:
----books:
------management-enabled: true
------statistics-enabled: true


Regards,
Enes O.

Joe Sherwin

unread,
Jan 18, 2021, 8:47:29 AM1/18/21
to haze...@googlegroups.com
Try the other example...
This  example does default behavior. There's no application.properties setting to override the default. Also, making it a client-server is simply, swapping the hazelcast(.xml or .yaml) config to a hazelcast-client(.xml or .yaml)

On Jan 18, 2021, at 4:28 AM, Shreshth Agarwal <shres...@gmail.com> wrote:

Hi,
Reply all
Reply to author
Forward
0 new messages