Spring Boot 3
WebSocket Security
MessageMatcherDelegatingAuthorizationManager
Spring Security
Java Development

Cannot find MessageMatcherDelegatingAuthorizationManager class while trying to configure websocket security in Spring Boot 3

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

If MessageMatcherDelegatingAuthorizationManager cannot be found in a Spring Boot 3 project, the problem is usually not the import statement itself. It is almost always one of three things: the messaging-security module is missing, Spring Security versions are out of alignment, or the code was copied from a different generation of the Spring Security API.

Boot 3 uses Spring Framework 6 and Spring Security 6 style configuration. That means WebSocket message security should be approached with the current AuthorizationManager-based pattern, not older adapter-based examples.

First Check the Classpath

The class lives in Spring Security's messaging support, not in the generic web starter. That means a typical setup needs:

  • 'spring-boot-starter-security'
  • 'spring-boot-starter-websocket'
  • 'spring-security-messaging'

For Maven, the dependency section usually includes something like this:

xml
1<dependencies>
2  <dependency>
3    <groupId>org.springframework.boot</groupId>
4    <artifactId>spring-boot-starter-security</artifactId>
5  </dependency>
6  <dependency>
7    <groupId>org.springframework.boot</groupId>
8    <artifactId>spring-boot-starter-websocket</artifactId>
9  </dependency>
10  <dependency>
11    <groupId>org.springframework.security</groupId>
12    <artifactId>spring-security-messaging</artifactId>
13  </dependency>
14</dependencies>

If that module is missing, the class will not exist at compile time no matter how many imports you try.

Do Not Override Spring Security Versions Randomly

The next thing to check is version alignment. Spring Boot manages compatible Spring Security versions through its dependency management. If you manually pin one Spring Security artifact to a different version, you can end up with a classpath where examples from one version do not match the jars you actually resolved.

That is why the next command is usually more useful than more coding:

bash
mvn dependency:tree -Dincludes=org.springframework.security

Or, in Gradle:

bash
./gradlew dependencies --configuration compileClasspath

If the tree shows mixed major or minor versions, fix that first. Configuration code is not stable when the classpath itself is incoherent.

Use the Current AuthorizationManager Style

In Spring Security 6 style WebSocket security, the usual pattern is to define an AuthorizationManager<Message<?>> bean and build it with MessageMatcherDelegatingAuthorizationManager.Builder:

java
1import org.springframework.context.annotation.Bean;
2import org.springframework.context.annotation.Configuration;
3import org.springframework.messaging.Message;
4import org.springframework.messaging.simp.SimpMessageType;
5import org.springframework.security.authorization.AuthorizationManager;
6import org.springframework.security.config.annotation.web.socket.EnableWebSocketSecurity;
7import org.springframework.security.messaging.access.intercept.MessageMatcherDelegatingAuthorizationManager;
8
9@Configuration
10@EnableWebSocketSecurity
11public class WebSocketSecurityConfig {
12
13    @Bean
14    AuthorizationManager<Message<?>> messageAuthorizationManager(
15        MessageMatcherDelegatingAuthorizationManager.Builder messages
16    ) {
17        messages
18            .simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.DISCONNECT).permitAll()
19            .simpDestMatchers("/app/**").authenticated()
20            .simpSubscribeDestMatchers("/topic/public").permitAll()
21            .anyMessage().denyAll();
22
23        return messages.build();
24    }
25}

If this still does not compile after adding spring-security-messaging, you almost certainly still have a dependency-alignment issue.

Keep Broker Configuration and Security Rules Consistent

Security matchers should line up with the destinations configured in your message broker:

java
1import org.springframework.context.annotation.Configuration;
2import org.springframework.messaging.simp.config.MessageBrokerRegistry;
3import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
4import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
5import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
6
7@Configuration
8@EnableWebSocketMessageBroker
9public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
10
11    @Override
12    public void registerStompEndpoints(StompEndpointRegistry registry) {
13        registry.addEndpoint("/ws");
14    }
15
16    @Override
17    public void configureMessageBroker(MessageBrokerRegistry registry) {
18        registry.setApplicationDestinationPrefixes("/app");
19        registry.enableSimpleBroker("/topic");
20    }
21}

If the broker prefixes and the security matchers disagree, you can end up chasing the wrong bug. The missing-class error is a compile-time problem, but runtime authorization problems often come immediately after it.

Do Not Mix Old and New Examples

A lot of confusion comes from mixing:

  • Boot 3 dependencies
  • Spring Security 5 era blog posts
  • deprecated adapter-style configuration
  • current builder-based examples

Pick the configuration style that matches the dependencies you actually run. Trying to patch an outdated example one missing class at a time usually makes the security setup harder to understand.

Common Pitfalls

The most common mistake is assuming spring-boot-starter-security automatically includes messaging security support. It does not give you every optional module.

Another common issue is overriding Spring Security versions while still expecting Spring Boot's examples to compile unchanged. Once version alignment breaks, missing-class errors become very likely.

Developers also spend time debugging HTTP security even though the problem is in STOMP message authorization dependencies. Web and messaging security share concepts, but they do not live in exactly the same module set.

Finally, avoid copying examples blindly from older answers that extend deprecated classes. Boot 3 projects should use the current authorization-manager approach.

Summary

  • Missing MessageMatcherDelegatingAuthorizationManager usually means missing spring-security-messaging or broken dependency alignment.
  • Let Spring Boot manage compatible Spring Security versions whenever possible.
  • Use the current AuthorizationManager<Message<?>> bean style for WebSocket message security.
  • Keep your STOMP destination prefixes and security matchers aligned.
  • Do not mix Boot 3 code with older adapter-based Spring Security examples.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design