Keycloak 17: Unsatisfied dependency for type org.keycloak.models.KeycloakSession and qualifiers [@Default]

We are using keycloak as IDP and have some custom plugins/Spi, we are in process of updating our keycloak instance to version 17 Quarkas distribution and the SPIs began to break (error below) during keycloak build process. I’ve made sure that there are no keycloak libraries packed as part of jar.

The SPI looks like below and have corresponding entries in Manifest file under Manifest/services/org.keycloak.services.resource.RealmResourceProviderFactory

Custom SPI/plugin

public class SwaggerJsonRetrieverFactory implements RealmResourceProviderFactory {
    @Override
    public RealmResourceProvider create(KeycloakSession session) {
        return new SwaggerJsonRetriever(session);
    }


    @Override
    public void init(Config.Scope config) {

    }


    @Override
    public void postInit(KeycloakSessionFactory factory) {

    }


    @Override
    public void close() {

    }

    @Override
    public String getId() {
        return "swagger.json";
    }
}

My pom.xml looks like below

<dependencies>
		<dependency>
			<groupId>org.keycloak</groupId>
			<artifactId>keycloak-core</artifactId>
			<scope>provided</scope>
			<version>${keycloak.version}</version>
		</dependency>
		<dependency>
			<groupId>org.keycloak</groupId>
			<artifactId>keycloak-server-spi</artifactId>
			<version>${keycloak.version}</version>
		</dependency>
		<dependency>
			<groupId>org.keycloak</groupId>
			<artifactId>keycloak-services</artifactId>
			<scope>provided</scope>
			<version>${keycloak.version}</version>
		</dependency>
		<dependency>
			<groupId>org.keycloak</groupId>
			<artifactId>keycloak-server-spi-private</artifactId>
			<scope>provided</scope>
			<version>${keycloak.version}</version>
		</dependency>
		<dependency>
			<groupId>io.swagger</groupId>
			<artifactId>swagger-parser</artifactId>
			<version>1.0.22</version>
		</dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-classic</artifactId>
			<version>${logback.version}</version>
		</dependency>
		<dependency>
			<groupId>ch.qos.logback</groupId>
			<artifactId>logback-core</artifactId>
			<version>${logback.version}</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
			<version>${jackson-dataformat-yaml.version}</version>
		</dependency>
		
	</dependencies>

The error which I’m getting

 io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 2 deployment problems: 
[1] Unsatisfied dependency for type org.keycloak.models.KeycloakSession and qualifiers [@Default]
	- java member: com.abc.swagger.SwaggerJsonRetriever().session
	- declared on CLASS bean [types=[com.abc.swagger.SwaggerJsonRetriever, java.lang.Object], qualifiers=[@Default, @Any], target=com.abc.swagger.SwaggerJsonRetriever]
[2] Unsatisfied dependency for type org.keycloak.models.KeycloakSession and qualifiers [@Default]

Is there any configuration which I’m missing, any help will be appreciated.

The issue was with Provider implementation, I was using Path annotation at class level due to which it was treated as bean, but after moving path annotation to method level the endpoints are not getting registered with quarkas, my provider looks like below and the path which I’m expecting to be registered is http://localhost:8080/auth/realms/master/swagger.json

@Api(value="Swagger definition",description = "Swagger definition")
public class SwaggerJsonRetriever implements RealmResourceProvider {


    @Context
    private HttpRequest request;

    @Context
    private  KeycloakSession session;

  
    @Override
    public Object getResource() {
        return this;
    }

    public SwaggerJsonRetriever(KeycloakSession session){
        this.session = session;
        request = session.getContext().getContextObject(HttpRequest.class);
    }

  
    
    @OPTIONS
    @Path("/swagger.json")
    @NoCache
    @Produces(MediaType.APPLICATION_JSON)
    public Response getPreflight() {
        return Cors.add(request, Response.ok())
                .allowedMethods("GET")
                .auth()
                .preflight()
                .build();
    }

    @GET
    @Path("/swagger.json")
    @Produces(MediaType.APPLICATION_JSON)
    public Response  get() throws IOException {
        try {
            // cache swagger files content to serve it from cache instead of reading it from 
            // files every time
            return getResponse(Response.Status.OK, readSwaggerFiles(), MediaType.APPLICATION_JSON_TYPE);
        }catch (Exception  e) {
            localLogger.errorv("Internal Server Error " + e.toString()  );
            return getResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage(), MediaType.APPLICATION_JSON_TYPE);
        }
    }
    
}