Hello :)
I'm trying to configure Hazelcast Client/Server topology to be able to store spring session in hazelcast.
I have a server with such configs
@Configuration
@EnableHazelcastHttpSession
public class HazelcastServerConfiguration {
@Bean
public Config hazelCastConfig() {
Config config = new Config();
config.getMapConfig(HazelcastIndexedSessionRepository.DEFAULT_SESSION_MAP_NAME)
.addMapAttributeConfig(springSessionAttributeConfig())
.addMapIndexConfig(springSessionIndexConfig());
SerializerConfig serializerConfig = new SerializerConfig();
serializerConfig.setImplementation(new HazelcastSessionSerializer()).setTypeClass(MapSession.class);
config.getSerializationConfig().addSerializerConfig(serializerConfig);
return config;
}
@Bean
public HazelcastInstance hazelcastInstance(Config config) {
return Hazelcast.newHazelcastInstance(config);
}
private MapAttributeConfig springSessionAttributeConfig() {
return new MapAttributeConfig()
.setName(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE)
.setExtractor(PrincipalNameExtractor.class.getName());
}
private MapIndexConfig springSessionIndexConfig() {
return new MapIndexConfig(HazelcastIndexedSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false);
}
}
and
@SpringBootApplication
public class NowohazelcastappApplication {
public static void main(String[] args) {
SpringApplication.run(NowohazelcastappApplication.class, args);
}
}
thats all server classes for now
and dependencies
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
......
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>3.12.11</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-hazelcast</artifactId>
</dependency>
</dependencies>
And client side configs:
@Bean
public ClientConfig clientConfig() {
ClientConfig clientConfig = new ClientConfig();
SerializerConfig serializerConfig = new SerializerConfig();
serializerConfig.setImplementation(new HazelcastSessionSerializer()).setTypeClass(MapSession.class);
clientConfig.getSerializationConfig().addSerializerConfig(serializerConfig);
return clientConfig;
}
@Bean()
public HazelcastInstance hazelcastInstance(ClientConfig clientConfig){
return HazelcastClient.newHazelcastClient(clientConfig);
}
And I`m getting this error during attemption to store session
...HazelcastSerializationException: java.lang.ClassNotFoundException: com.test.session.CustomerInSession
this is a class from the client side and i have some others classes also with such exception
Does hazelcast have any way to serialize and deserialize my CustomerInSession class (and others) without copying this class on server side ?