Rahul Wagh
Rahul Wagh

Reputation: 494

Quarkus - Unsatisfied dependency for type org.eclipse.microprofile.jwt

I was trying to implement the JWT token for one my Quarkus application but somehow getting an exception - Unsatisfied dependency for type org.eclipse.microprofile.jwt.JsonWebToken and qualifiers [@Default]

My Quarkus application is fairly simple and having one rest endpoint -

@Path("/jwt")
@RequestScoped
public class JWTRestController {

    @Inject
    JsonWebToken jwt;

    @GET()
    @Path("permit-all")
    @PermitAll
    @Produces(MediaType.TEXT_PLAIN)
    public String hello(@Context SecurityContext ctx) {
        Principal caller =  ctx.getUserPrincipal();
        String name = caller == null ? "anonymous" : caller.getName();
        String helloReply = String.format("hello + %s, isSecure: %s, authScheme: %s", name, ctx.isSecure(), ctx.getAuthenticationScheme());
        return helloReply;
    }

}

But when i try to run my quarkus application -

gradlew quarkusDev

Log stacktrace

> Task :quarkusDev
Port 5005 in use, not starting in debug mode

2020-04-05 15:57:49,789 INFO  [org.jbo.threads] (main) JBoss Threads version 3.0.1.Final
2020-04-05 15:57:50,158 ERROR [io.qua.dev.DevModeMain] (main) Failed to start Quarkus: java.lang.RuntimeException: 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: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.eclipse.microprofile.jwt.JsonWebToken and qual
ifiers [@Default]
        - java member: com.jhooq.JWTRestController#jwt
        - declared on CLASS bean [types=[com.jhooq.JWTRestController, java.lang.Object], qualifiers=[@Default, @Any], target=com.jhooq.JWTRestController]
        at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:910)
        at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:232)
        at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:130)
        at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:291)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

Am i really missing something here?

Here is my build.gradle

plugins {
    id 'java'
    id 'io.quarkus'
}

repositories {
     mavenLocal()
     mavenCentral()
}

dependencies {
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
    implementation 'io.quarkus:quarkus-resteasy'

    testImplementation 'io.quarkus:quarkus-junit5'
    testImplementation 'io.rest-assured:rest-assured'
    testImplementation 'io.quarkus:quarkus-smallrye-jwt'
    testImplementation 'io.quarkus:quarkus-resteasy-jsonb'
    implementation 'org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1'
}

group 'com.jhooq'
version '1.0.0-SNAPSHOT'

compileJava {
    options.compilerArgs << '-parameters'
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}


Upvotes: 0

Views: 4267

Answers (1)

Ladicek
Ladicek

Reputation: 6587

The problem lies here:

testImplementation 'io.quarkus:quarkus-smallrye-jwt'
testImplementation 'io.quarkus:quarkus-resteasy-jsonb'
implementation 'org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1'

The quarkus-smallrye-jwt and quarkus-resteasy-jsonb dependencies are part of the application, not part of tests. These must be implementation, not testImplementation.

At the same time, you can remove implementation 'org.eclipse.microprofile.jwt:microprofile-jwt-auth-api:1.1.1', this it's brought in transitively by quarkus-smallrye-jwt.

Upvotes: 2

Related Questions