Spring Session and Spring Security with Hazelcast issue

77 views
Skip to first unread message

Steve

unread,
Dec 1, 2023, 4:10:40 PM12/1/23
to Hazelcast
Hi All
I'm trying to change my Spring application to use Spring security and Hazel cast. I'm 90% there but keep getting this error. This is the Log during Startup with no errors
see here
20:42:21,331 | server | orll115108 | INFO | 1-162 | stdout | | [PWHazelcastConfig] Loading Hazelcast Instance

20:42:21,590 | server | orll115108 | WARN | 1-162 | c.h.i.AddressPicker | | [LOCAL] [aptpwCluster] [5.3.6] Ignoring TCP_KEEPCOUNT. It seems your JDK does not support jdk.net.ExtendedSocketOptions on this OS. Try upgrading to the latest JDK or check with your JDK vendor.Alternatively, on Linux, configure tcp_keepalive_probes in the kernel (affecting default keep-alive configuration for all sockets): For more info see https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/. If this isn't dealt with, idle connections could be closed prematurely.
20:42:21,590 | server | orll115108 | WARN | 1-162 | c.h.i.AddressPicker | | [LOCAL] [aptpwCluster] [5.3.6] Ignoring TCP_KEEPIDLE. It seems your JDK does not support jdk.net.ExtendedSocketOptions on this OS. Try upgrading to the latest JDK or check with your JDK vendor.Alternatively, on Linux, configure tcp_keepalive_time in the kernel (affecting default keep-alive configuration for all sockets): For more info see https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/. If this isn't dealt with, idle connections could be closed prematurely.
20:42:21,590 | server | orll115108 | WARN | 1-162 | c.h.i.AddressPicker | | [LOCAL] [aptpwCluster] [5.3.6] Ignoring TCP_KEEPINTERVAL. It seems your JDK does not support jdk.net.ExtendedSocketOptions on this OS. Try upgrading to the latest JDK or check with your JDK vendor.Alternatively, on Linux, configure tcp_keepalive_intvl in the kernel (affecting default keep-alive configuration for all sockets): For more info see https://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/. If this isn't dealt with, idle connections could be closed prematurely.
20:42:21,604 | server | orll115108 | INFO | 1-162 | c.h.s.logo | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6]
+ + o o o o---o o----o o o---o o o----o o--o--o
+ + + + | | / \ / | | / / \ | |
+ + + + + o----o o o o o----o | o o o o----o |
+ + + + | | / \ / | | \ / \ | |
+ + o o o o o---o o----o o----o o---o o o o----o o
20:42:21,604 | server | orll115108 | INFO | 1-162 | c.h.system | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Copyright (c) 2008-2023, Hazelcast, Inc. All Rights Reserved.
20:42:21,604 | server | orll115108 | INFO | 1-162 | c.h.system | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Hazelcast Platform 5.3.6 (20231109 - 9903dc9) starting at [10.72.5.164]:5701
20:42:21,604 | server | orll115108 | INFO | 1-162 | c.h.system | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Cluster name: aptpwCluster
20:42:21,604 | server | orll115108 | INFO | 1-162 | c.h.system | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Integrity Checker is disabled. Fail-fast on corrupted executables will not be performed. For more information, see the documentation for Integrity Checker.
20:42:21,606 | server | orll115108 | INFO | 1-162 | c.h.system | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] The Jet engine is disabled.
To enable the Jet engine on the members, do one of the following:
- Change member config using Java API: config.getJetConfig().setEnabled(true)
- Change XML/YAML configuration property: Set hazelcast.jet.enabled to true
- Add system property: -Dhz.jet.enabled=true (for Hazelcast embedded, works only when loading config via Config.load)
- Add environment variable: HZ_JET_ENABLED=true (recommended when running container image. For Hazelcast embedded, works only when loading config via Config.load)
20:42:21,719 | server | orll115108 | INFO | 1-162 | c.h.i.t.TpcServerBootstrap | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] TPC: disabled
20:42:21,721 | server | orll115108 | INFO | 1-162 | c.h.s.i.o.i.BackpressureRegulator | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Backpressure is enabled, maxConcurrentInvocations:27200, syncWindow: 100
20:42:21,721 | server | orll115108 | WARN | 1-162 | c.h.s.i.o.i.BackpressureRegulator | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Back pressure is enabled, but 'hazelcast.operation.backup.timeout.millis' is too small.
20:42:21,988 | server | orll115108 | INFO | 1-162 | c.h.s.security | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Enable DEBUG/FINE log level for log category com.hazelcast.system.security or use -Dhazelcast.security.recommendations system property to see security recommendations and the status of current config.
20:42:22,025 | server | orll115108 | INFO | 1-162 | c.h.i.i.Node | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Using Discovery SPI
20:42:22,028 | server | orll115108 | WARN | 1-162 | c.h.c.CPSubsystem | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] CP Subsystem is not enabled. CP data structures will operate in UNSAFE mode! Please note that UNSAFE mode will not provide strong consistency guarantees.
20:42:22,191 | server | orll115108 | INFO | 1-162 | c.h.i.d.Diagnostics | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
20:42:22,195 | server | orll115108 | INFO | 1-162 | stdout | | init: InitialMembershipEvent {[Member [10.72.5.164]:5701 - 67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596 this]}

20:42:22,195 | server | orll115108 | INFO | 1-162 | c.h.c.LifecycleService | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] [10.72.5.164]:5701 is STARTING
20:42:22,195 | server | orll115108 | INFO | 1-162 | stdout | | Lifecycle stateChanged: LifecycleEvent [state=STARTING]

20:42:22,203 | server | orll115108 | INFO | 1-184 | stdout | | memberAdded: MembershipEvent {member=Member [10.72.5.164]:5701 - 67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596 this, type=added, members=[Member [10.72.5.164]:5701 - 67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596 this]}

20:42:27,357 | server | orll115108 | INFO | 1-162 | c.h.i.c.ClusterService | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6]

Members {size:1, ver:1} [
Member [10.72.5.164]:5701 - 67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596 this
]

20:42:27,363 | server | orll115108 | INFO | 1-162 | c.h.c.LifecycleService | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] [10.72.5.164]:5701 is STARTED
20:42:27,363 | server | orll115108 | INFO | 1-162 | stdout | | Lifecycle stateChanged: LifecycleEvent [state=STARTED]

20:42:27,395 | server | orll115108 | INFO | 1-162 | c.h.i.p.i.PartitionStateManager | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] Initializing cluster partition table arrangement...
20:42:27,495 | server | orll115108 | INFO | 1-185 | stdout | | distributedObjectCreated: DistributedObjectEvent{distributedObject=IMap{name='spring:session:sessions'}, eventType=CREATED, serviceName='hz:impl:mapService', objectName='spring:session:sessions', source=67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596}

--------------------------------------------------------------------------------------------------------------------------

When i try to login I authenticate ok but then Hazelcast is throwing this error

20:42:44,108 | server | orll115108 | INFO | 1-184 | stdout | | distributedObjectCreated: DistributedObjectEvent{distributedObject=IMap{name='aptpwCluster-Map-PW_RUNNING_PROCESS'}, eventType=CREATED, serviceName='hz:impl:mapService', objectName='aptpwCluster-Map-PW_RUNNING_PROCESS', source=67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596}

20:42:44,130 | server | orll115108 | INFO | 1-186 | stdout | | distributedObjectCreated: DistributedObjectEvent{distributedObject=com.hazelcast.collection.impl.set.SetProxyImpl{service=hz:impl:setService, name=aptpwCluster-Set-PW_PENDING_PROCESS}, eventType=CREATED, serviceName='hz:impl:setService', objectName='aptpwCluster-Set-PW_PENDING_PROCESS', source=67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596}

20:42:44,132 | server | orll115108 | INFO | 1-185 | stdout | | distributedObjectCreated: DistributedObjectEvent{distributedObject=IQueue{name='aptpwCluster-Queue-PW_PENDING_PROCESS'}, eventType=CREATED, serviceName='hz:impl:queueService', objectName='aptpwCluster-Queue-PW_PENDING_PROCESS', source=67e7ba86-d3ec-4f6c-a6a8-e8b3d342d596}

20:43:00,076 | server | orll115108 | INFO | 1-209 | c.a.a.f.i.m.j.JmxMetricLoggingBean | 5ecf80e9-9fa9-4708-ad76-9e9d1684260b | Unable to log statistic for JMX object java.lang:type=MemoryPool,name=PS Old Gen and attribute Usage: java.lang:type=MemoryPool,name=PS Old Gen
20:44:00,036 | server | orll115108 | INFO | 1-209 | c.a.a.f.i.m.j.JmxMetricLoggingBean | ec1167c9-2e7c-4e68-921c-90a5f5d63cda | Unable to log statistic for JMX object java.lang:type=MemoryPool,name=PS Old Gen and attribute Usage: java.lang:type=MemoryPool,name=PS Old Gen
20:45:00,027 | server | orll115108 | INFO | 1-209 | c.a.a.f.i.m.j.JmxMetricLoggingBean | ee5d214e-13d3-478c-8bbc-4de2e0638321 | Unable to log statistic for JMX object java.lang:type=MemoryPool,name=PS Old Gen and attribute Usage: java.lang:type=MemoryPool,name=PS Old Gen
20:46:00,019 | server | orll115108 | INFO | 1-209 | c.a.a.f.i.m.j.JmxMetricLoggingBean | b628eada-af30-4872-9b36-ddb62a77ee1c | Unable to log statistic for JMX object java.lang:type=MemoryPool,name=PS Old Gen and attribute Usage: java.lang:type=MemoryPool,name=PS Old Gen
20:47:00,012 | server | orll115108 | INFO | 1-209 | c.a.a.f.i.m.j.JmxMetricLoggingBean | ffc22cda-64b7-4d1a-9aa7-e95a5f31173f | Unable to log statistic for JMX object java.lang:type=MemoryPool,name=PS Old Gen and attribute Usage: java.lang:type=MemoryPool,name=PS Old Gen
20:47:37,539 | server | orll115108 | INFO | 1-225 | c.a.a.p.m.s.i.s.f.PWAuthenticationFilter | | PWAuthenticationFilter --> attemptAuthentication
20:47:37,933 | server | orll115108 | INFO | 1-225 | c.a.a.p.m.s.i.s.f.PWAuthenticationFilter | | PWAuthenticationFilter successfulAuthentication
20:47:37,992 | server | orll115108 | ERROR | 1-186 | c.h.s.i.e.i.EventServiceImpl | | [10.72.5.164]:5701 [aptpwCluster] [5.3.6] hz.aptpwClusterInstance.event-3 caught an exception while processing:com.hazelcast.spi.impl.eventservice.impl.LocalEventDispatcher@573524c9: java.lang.IllegalArgumentException: servletContext cannot be null
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.session.web.http.HttpSessionAdapter.<init>(HttpSessionAdapter.java:62)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter.createHttpSessionEvent(SessionEventHttpSessionListenerAdapter.java:77)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter.onApplicationEvent(SessionEventHttpSessionListenerAdapter.java:63)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter.onApplicationEvent(SessionEventHttpSessionListenerAdapter.java:41)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//org.springframework.session.hazelcast.Hazelcast4IndexedSessionRepository.entryAdded(Hazelcast4IndexedSessionRepository.java:310)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.MapListenerAdaptors.lambda$null$0(MapListenerAdaptors.java:55)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.InternalMapListenerAdapter.onEvent(InternalMapListenerAdapter.java:56)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.InternalMapListenerAdapter.onEvent(InternalMapListenerAdapter.java:35)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.event.MapEventPublishingService.callListener(MapEventPublishingService.java:172)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.event.MapEventPublishingService.dispatchEntryEventData(MapEventPublishingService.java:184)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.event.MapEventPublishingService.dispatchEvent(MapEventPublishingService.java:83)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.event.MapEventPublishingService.dispatchEvent(MapEventPublishingService.java:47)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.MapService.dispatchEvent(MapService.java:134)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.map.impl.MapService.dispatchEvent(MapService.java:101)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.spi.impl.eventservice.impl.LocalEventDispatcher.run(LocalEventDispatcher.java:64)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.internal.util.executor.StripedExecutor$Worker.process(StripedExecutor.java:245)
at deployment.com.company.apt.myapp.apps_applicatiomApp-1.0.0-SNAPSHOT.ear//com.hazelcast.internal.util.executor.StripedExecutor$Worker.run(StripedExecutor.java:228)
---------------------------------------------------------------------------------------------------------------------------------
The Offending code seems to be in  my custom AbstractAuthenticationProcessingFilter here 
@Override
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain,
Authentication authResult) throws IOException, ServletException {
logger.info("PWAuthenticationFilter successfulAuthentication");
UsernamePasswordAuthenticationToken upa = (UsernamePasswordAuthenticationToken) authResult;
PWUserDetails user = (PWUserDetails) upa.getPrincipal();
HttpSession httpSession = request.getSession(true);
user.setSessionId(httpSession.getId());
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(authResult);
httpSession.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, context);
chain.doFilter(request, response);
}
Any help would be greatly appreciated
Thanks
Reply all
Reply to author
Forward
0 new messages